Sean Chittenden sean at chittenden.org
Mon Dec 6 12:06:18 PST 2004

> I run a large site that is using memcached to a small degree at the 
> moment. Really it only caches things that are used on almost every 
> page, not things that are specific to a single page or to a single 
> user. As the database becomes the bottleneck instead of the webservers 
> as it is right now, I'll need to drop SELECTs and UPDATEs. Caching 
> things that are specific to individual pages will help drop the 
> selects, but won't drop the updates. I do alot of updates of the form 
> UPDATE ... SET count = count + 1 WHERE ... for stats and other 
> logging, that could be combined into single queries over time. The 
> various hit counters, banner view counters, etc, could all be done in 
> the form of incr some memcached entry, then once a minute zero them 
> and do a single query of the form UPDATE ... SET count = count + (sum 
> of all from the memcached entry) WHERE ..., greatly reducing the 
> UPDATE query count. How hard would it be to create a command similar 
> to incr/decr that would just reset that key to 0 and return the old 
> value?
> Does anyone have a better solution to this problem, memcached related 
> or not?

Right now it's not possible to have memcached output anything when data 
expires, but it's an addition that could be added.  The best way would 
be via syslog(3), but therein lies a huge potential for a local DoS if 
lots of data gets expired.  A better approach would be to set a "log me 
on expiration" bit in the new protocol, that way there is some 
selectivity for logging.  Brad, would you mind if I added that?  -sc

Sean Chittenden

More information about the memcached mailing list