views:

24

answers:

1

Hello,

I am using the Asp.Net Caching mechanism for a highly frequent changing web app. the cache holds chat participants and their messages, and it needs to keep track of participants presence.

Data is changing very frequently, participants go in and out, and messages are sent and recieved.

The cache provides me with solutions for: - performance - reducing the number of DDL operations in the database (SQL Server) - we had a problem with the transaction log getting full.

I want to continue working this way, but I cannot rely on the cache (I can lose all data when the Cache recycles, or some of the data when the memory gets full).

The option I see right now is to save the data to the database every time the cache changes, otherwise I will lose data.

But this means many SQL update/insert statements.

someone adviced me to persist to the database evey N messages/changes, but it's still not a reliable solution. I still lose data.

Anyone has an idea?

Thanks Yaron

+1  A: 

Fix your database capacity issues. If you need to be able to reliably save n changes per second, then your database needs to be able to handle n operations per second.

Anything else (including saving every few operations) will lead to some possibility of data loss. If you can accept that data loss risk then that would work.

A distributed cache (project Velocity or otherwise) could also help (data is at least saved to multiple machines). But then needs extra hardware, and you could spend that on the capacity of the database.

Finally rather than trying to cache changes look for other opportunities to cache database reads, taking that load off might allow the rights to go through. At least until you get more usage.

Richard