views:

72

answers:

2

I'm working on a forum based website, the site also supports onsite messaging (ie. the users can send private messages to other users), what I'm trying to do is notify a member if they have new messages, for example by displaying the inbox link in bold and also the number of messgages, e.g. Inbox(3)

I'm a little confused how this can be implemented for a website running on a server farm, querying the database with every request seems like an overkill to me, so this is out of question, probably a shared cache should be used for this, I tend to think this a common feature for many sites including many of the large ones (running on server farms), I wonder how they implement this, any ideas are appreciated.

A: 

SO caches the questions, however every postback requeries your reputation. This can be seen by writing a couple of good answers quickly, then refreshing the front page.

The questions will only change every minute or so, but you can watch your rep go up each time.

ck
A: 

Waleed, I recommend you read the articles on high scalability. They have specific case studies on the architectures of various mega scale web applications. (See the side bar on the right side of the main page.)

The general consensus these days is that RDBMs usage in this type of application is a bottle neck. It is also probably safe to say that most of the highly scalable web applications sacrifice consistency to achieve availability.

This series should be informative of various views on the topic. A word on scalability is highly cited.

In all this, keep in mind that these folks are dealing with Flickr, Amazon, Tweeter scale issues and architectures. The solutions are somewhat radical departures from the (previously accepted) norms and unless your forum application is the next Big Thing, you may wish to first test out the conventional approach to determine if it can handle the load or not.

Thank you for your answer, I'm already a regular visitor of highscalability.com :) .. the problem with implementing that feature is that, if you decide to use your RDBMS for this, then you'll have to query the database with almost every single request, which I believe is not very scalable, on the other hand this feature is implemented on many large-scale websites hence why I asked the question, I was curious to know how they implement it. It seems to to me the only reasonable way to do it is to use a shared cache and actually this is the direction I'm currently heading ...
Waleed Eissa
Sorry, you never know! :) I would have recommended a look at Redis but sounds like you are on windows. You effectively need a distributed service layer wrapping a cluster of memory caches. Given that your backend will remain RDBMS (?) regardless, you'll also need a mechanism to (lazily) synch the front cache and the backend persistent store. Put a consistent hash in the client (web server) layer to distribute the user keys across a middle layer of mem caches. The cache layer should also periodically update the backend.