Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 909
Ahmed Atia Avatar asked Aug 03 '09 06:08

Ahmed Atia


People also ask

What is heartbeat session?

The Heartbeat Session is a unique sound and visual experience of your own heartbeat, an experiential dive into your own heart.

What is a heartbeat in coding?

A heartbeat is a type of a communication packet that is sent between nodes. Heartbeats are used to monitor the health of the nodes, networks and network interfaces, and to prevent cluster partitioning.

What is heartbeat mechanism?

The heartbeat mechanism monitors the connection between a manager and an agent and automates the cleanup procedure when the connection is lost. This enables both the manager and the agent to release resources that were allocated for maintaining the connection.

What is heartbeat server?

Heartbeat is a lightweight daemon that you install on a remote server to periodically check the status of your services and determine whether they are available. Unlike Metricbeat, which only tells you if your servers are up or down, Heartbeat tells you whether your services are reachable.


2 Answers

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".

like image 186
djna Avatar answered Oct 26 '22 23:10

djna


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.

like image 40
BengtBe Avatar answered Oct 26 '22 23:10

BengtBe