views:

253

answers:

3

Helo,

I have implemented a chat application using Comet. the request is "hang" on the server until new messages arive. It, then, returns to the client with the new messages, and goes to the server again.

My problem is:

In order to check for new messages, I poll the database every 600 ms. I perform a simple query "select...from messages where messageId > ' + lastMessageId.

In addition, in order to maintain presence, I update the database very (very) often with each user "LastKeepAliveTime".

The SQL Server transaction log is growing huge, and, at a certain point, my chat application stops working.

The chat users are not registered users, they are just random users who can leave the page at any time.

thanks Yaron

+1  A: 

Here's how to keep the transaction log from getting out of control: http://support.microsoft.com/kb/873235

Options in that article include:

  • Doing a shrink.
  • Changing the log size.
  • Configuring automatic expansion.
  • Changing the recovery model.
  • Backing up the log file regularly.

and more.

As a side note, it may be worthwhile to set up a list of users and their last activity dates that you store as objects in your application state. It would be quicker to access that way and you could persist the values less frequently.

Andy West
+1  A: 

Could you use a common cache object for the last keep alive information? It seems like its a small amount of information and you could avoid a lot of sql updates.

Josh
A: 

Switching from full mode transaction log to simple mode should solve your log growth issues.

However, I should also add that it's generally a good idea to avoid polling if you can, since it's not scalable. You might consider switching to an event-driven model using Service Broker or SqlDependency. There are other approaches to keep-alives, too.

RickNZ