开发者

Cache Persistence

开发者 https://www.devze.com 2022-12-18 04:02 出处:网络
I am using the Asp.Net Caching mechanism for a highly f开发者_Python百科requent changing web app.

I am using the Asp.Net Caching mechanism for a highly f开发者_Python百科requent 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


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 that 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 writes to go through. At least until you get more usage.

0

精彩评论

暂无评论...
验证码 换一张
取 消