views:

405

answers:

2

What is Heart Beat Design Pattern? How is it related to ASP.NET session?

+2  A: 

A web application receives HTTP request from a user's browser. It holds session information so that (for example) a shopping cart or the state of an online game can be retained between those requests.

User's tend to leaves browser session active while they go for lunch, home for the day, or leave on a two week vacation. Hence sessions usually have some inactivity timeout, otherwise you end up with lots of server resources being used for users who are not coming back any time soon.

The heartbeat pattern described here uses Ajax (asynch) calls to tell the server the user's still here. It can be useful because rich internet apps often allow quite a bit of local working before new requests are sent to the server - hence there's a danger of sessions timing out while the user is happily using the app.

The implementation needs to be reasonably intelligent. For example, if you were to just send an ajax call to the server every thirty seconds saying "Yep still here" that would carry on while the user's on a two week vacation. So instead the heartbeat would be sent only when the user has been actively using the app.

It could be quite reasonable to "piggy-back" useful info into the heartbeat requests and responses, for example sending auto-save data to the server, or retrieving updated server info or "news".

djna
+1  A: 

This pattern is about keeping the ASP.NET Session alive.

Take a look at Heart Beat Design Pattern - Keeping Webpage Session Alive for an implementation in .NET.

BengtBe