views:

24

answers:

1

I am implementing an AJAX chat. No worries there but I was thinking of how to implement the server side code.

At the moment I write from a DB when a user sends and reads from the DB when a user requests his messages. I am thinking that this is not the most efficient way as I am writing and reading all the time.

My plan was to implement I windows service that would keep the messages in memory until the user requests or send it back to sender if there is no request. For scaling this might be better as I can just install the service on many servers and using a load balancer to send to the correct server?

Please tell me which way is best, service or by database?

+1  A: 

I would go with the database approach: It is more easy at the beginning to implement and test. If you provide a good API layer to the database storage you could replace the database with your service later, if you need the additional features. However scaling and load balancing can also be achieved with databases...

Tapdingo