Stats reset is another undocumented feature (see this article for stats cachedump command) of Memcached
stats reset command
Telnet command : stats reset \r\n
This function will reset following stats :
- total_connections
- get, set, flush, cas, incr and decr stats
- auth_cmds and auth_errors
- bytes_read and bytes_written
- total_items will be reset but not curr_items
- evictions and reclaimed
stats reset command example
First we get the current stats :
1 |
stats |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
stats STAT pid 16963 STAT uptime 13759537 STAT time 1288017338 STAT version 1.4.5 STAT pointer_size 64 STAT rusage_user 35326.604539 STAT rusage_system 83474.312975 STAT curr_connections 443 STAT total_connections 7062593 STAT connection_structures 708 STAT cmd_get 6994013410 STAT cmd_set 285664007 STAT cmd_flush 11 STAT get_hits 6709348930 STAT get_misses 284664480 STAT delete_misses 133333 STAT delete_hits 641874 STAT incr_misses 0 [...] STAT auth_errors 0 STAT bytes_read 1078950472291 STAT bytes_written 2380539854758 STAT limit_maxbytes 1610612736 [...] STAT conn_yields 0 STAT bytes 1019869479 STAT curr_items 1019724 STAT total_items 285630709 STAT evictions 187149 STAT reclaimed 4867645 END |
Now we reset Memcached server stats
1 2 |
stats reset RESET |
The final result :
1 |
stats |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
STAT pid 16963 STAT uptime 13759736 STAT time 1288017537 STAT version 1.4.5 STAT pointer_size 64 STAT rusage_user 35327.040473 STAT rusage_system 83475.259831 STAT curr_connections 456 STAT total_connections 2 STAT connection_structures 708 STAT cmd_get 2117 STAT cmd_set 101 STAT cmd_flush 0 STAT get_hits 2018 STAT get_misses 99 STAT delete_misses 0 STAT delete_hits 0 STAT incr_misses 0 [...] STAT auth_errors 0 STAT bytes_read 154416 STAT bytes_written 689536 STAT limit_maxbytes 1610612736 [...] STAT conn_yields 0 STAT bytes 1019306738 STAT curr_items 1019534 STAT total_items 101 STAT evictions 0 STAT reclaimed 0 |
Be aware that using this function can hide you a lot of things, i find it only useful when we put a new version of cache management to reset all stats and start monitoring the new version without the stats history.
Other Memcached Resources
You can find a lot of Memcached resources on this Memcached resources page.