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?