I am building a chat feature in an asp.net mvc website ,something like stackoverflow chat.
I have a table in the db for users and chat groups.
My question is where to save these info:
Chat history 'which needs to be cleared every 3 days'.
users status 'went online, offline or away'.
A user is currently writing a message...
And some more info like these which change very fast while many users are chatting .
Is it fine to keep all these data in the same website db? Or should I create different tables away from the users table ? Or should I go with XML files?
If XML files is your choice, can you tell me a hint about how to organize the created XML files and how they will look like.
preguntado el 28 de agosto de 11 a las 03:08
I would stay away from files, mainly because it is very hard to manage file concurrency when dealing with multiple updaters (which you may have if you have, say, load-balanced web servers).
A database is a good idea, depending on your scale (relational databases on good hardware scale to hundreds if not thousands of simultaneous updaters, but often fall off a cliff after that). If you are not expecting to have hundreds of simultaneous users, a database with clients using AJAX polling or Comet connections is probably the right way to go. And don't discount the fact that almost every programmer you might hire knows how to work with a database.
Other options you might look at are message queues, whereby each client has a server-side message queue that is periodically checked, again using using AJAX polling or Comet connections. Queues are nice because you don't need to keep track of which messages the client already saw- you just take whatever is there off of the queue. Queues with topic support also make a nice way to build a stateful online/offline status.
Finally, some NoSQL databases (CouchDB, MongoDB) provide very good scaling by sharding across multiple machines, and they store hierarchical data like an XML file would (they actually use JSON to store their data), so a conversation thread would be a natural fit there.