开发者

Design of "I am alive" service

I am currently designing a system where we need to know if the user is still online/logged in.

The system is开发者_开发技巧 a .Net web based, so we intend to do this using AJAX/JSONP code, which pings the server every 2 minutes.

There is a large number of users, so a ping every 2 minutes causes ca. 600 pings per second.

We therefore intend to place this service on it's own server, and store all information in memory using Velocity.

The cache will be a heirachy of named value pairs, first group then person, and a timestamp for each person.

Question is can we write directly to the velocity cache for each ping? Or will this cause locking? Should we first write to a queue and then update the cache from the queue?

At the same time as we update the cache there will be other users requesting information on a per group basis.


I think you should be able to do this if you can change your model to base each cache item around a user as apposed to being a group of users as you mentioned. If you require the ability to query these items by group, you would have to think of a way to keep an index (potentially in memory) of the keys and groups to query items by (the query would obviously be a slow point).

This would make the likelyhood of you updating the same item at the same time near nill (as each client would only be updating every 2 minutes)

This would allow you to take advantage of the Optimistic Concurrency Model for velocity as discussed on MSDN on the link below, without losing any data.

http://msdn.microsoft.com/en-us/library/ee790890.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜