Saturday, March 15, 2014

memcached statistics status

Here is a "top" emulator for memcached statistics:
watch -n 5 "echo stats | socat unix-connect:/var/tmp/memcached.sock -"
The screen will be refreshed every 5 seconds and display results of memcached stats command. Here is a sample output:
STAT pid 16779
STAT uptime 131077
STAT time 1394862592
STAT version 1.4.13
STAT libevent 2.0.19-stable
STAT pointer_size 64
STAT rusage_user 667.997747
STAT rusage_system 988.869800
STAT curr_connections 9
STAT total_connections 178
STAT connection_structures 10
STAT reserved_fds 20
STAT cmd_get 23144897
STAT cmd_set 19181993
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 22529707
STAT get_misses 615190
STAT delete_misses 1208809
STAT delete_hits 147
STAT incr_misses 3406
STAT incr_hits 8380
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 2058033616
STAT bytes_written 2050360021
STAT limit_maxbytes 134217728
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 496615
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 3350
STAT evicted_unfetched 0
STAT bytes 5042282
STAT curr_items 16171
STAT total_items 19188509
STAT evictions 0
STAT reclaimed 3419
END
Here are some the most interesting counters explained:
  1. bytes - an amount of memory used for cache items
  2. bytes_read, bytes_written - a number of bytes received/sent
  3. cmd_get, cmd_set - a number of get/set commands received
  4. conn_yields - a number of times a maximum number of requests per event reach the limit (memcached -R argument)
  5. curr_items - a number of cache items
  6. delete_hits, delete_misses - a number of delete command received
  7. evictions - a number of cache items removed to free some memory for new cache items
  8. get_hits, get_misses - a number of get command received
  9. incr_hits, incr_misses - a number of incr command received
  10. reclaimed - a number of overwrites for expired keys
  11. rusage_system, rusage_user - a number of seconds for system/user time
  12. total_items - a counter of total cache items stored

Memcached keys statistic

It is also useful to see keys statistics. You need to enable detailed stats for that:
# enable
echo 'stats detail on' | socat unix-connect:/var/tmp/memcached.sock -
# disable
echo 'stats detail off' | socat unix-connect:/var/tmp/memcached.sock -
# dump
echo 'stats detail dump' | socat unix-connect:/var/tmp/memcached.sock - | sort
Here is a sample output:
...
PREFIX trls get 2 hit 1 set 2 del 0
PREFIX trsa get 3 hit 3 set 0 del 0
PREFIX trse get 5 hit 5 set 0 del 0
PREFIX trst get 28 hit 1 set 2 del 0
PREFIX trva get 87 hit 6 set 44 del 0
...
Note that keys are displayed to first colon (:).

No comments :

Post a Comment