Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is total_items larger than curr_items in Memcached when I have plenty of memory and items are set to never expire?

Tags:

memcached

I have a memcached instance set up with 10GB of space on an ec2 instance with plenty of memory (15 gb I believe). I'm confused to see that the stat "total_items" is larger than the curr_items stat considering that when items are written to memcache, the timeout is set to 0 (never expire). Could someone explain these stats for me and why it does not seem to have every item in the cache still?

STAT cmd_set 174978 ... STAT delete_misses 0 STAT delete_hits 0 ... STAT bytes_read 45749254 STAT bytes_written 26472821 STAT limit_maxbytes 10737418240 ... STAT bytes 25386981 STAT curr_items 99198 STAT total_items 174978 STAT evictions 0 STAT reclaimed 0

like image 514
Kevin M Avatar asked Feb 13 '23 06:02

Kevin M


1 Answers

I don't think total_items means what you think it means. It is a simple counter which increases whenever something is stored. A simple test verifies this. Store the same object twice. curr_items will be one, total_items will be two. Since your evictions and reclaims are both zero, everything that was ever stored is still there, as nothing has been evicted and no expired keys have been reclaimed. The data may have changed over time, but everything is still there.

like image 185
Mikkel Løkke Avatar answered May 13 '23 01:05

Mikkel Løkke