首页 > 互联网技术 > 获取memcached统计信息

获取memcached统计信息

2010年5月9日 2,687 views 发表评论 阅读评论

1. 我们可以安装libmemcached包.使用其中的一些命令(如memstat )查看memcached的信息. (略)

2. memcached General Statistics,我们可以telnet memcached server 端口,然后运行stats命令获取输出统计.
ststs
——–
Statistic Data type Description version
pid 32u Process id of the memcached instance.
uptime 32u Uptime (in seconds) for this memcached instance.
time 32u Current time (as epoch).
version string Version string of this instance.
pointer_size string Size of pointers for this host specified in bits (32 or 64).
rusage_user 32u:32u Total user time for this instance (seconds:microseconds).
rusage_system 32u:32u Total system time for this instance (seconds:microseconds).
curr_items 32u Current number of items stored by this instance.
total_items 32u Total number of items stored during the life of this instance.
bytes 64u Current number of bytes used by this server to store items.
curr_connections 32u Current number of open connections.
total_connections 32u Total number of connections opened since the server started running.
connection_structures 32u Number of connection structures allocated by the server.
cmd_get 64u Total number of retrieval requests (get operations).
cmd_set 64u Total number of storage requests (set operations).
get_hits 64u Number of keys that have been requested and found present.
get_misses 64u Number of items that have been requested and not found.
delete_hits 64u Number of keys that have been deleted and found present. 1.3.x
delete_misses 64u Number of items that have been delete and not found. 1.3.x
incr_hits 64u Number of keys that have been incremented and found present. 1.3.x
incr_misses 64u Number of items that have been incremented and not found. 1.3.x
decr_hits 64u Number of keys that have been decremented and found present. 1.3.x
decr_misses 64u Number of items that have been decremented and not found. 1.3.x
cas_hits 64u Number of keys that have been compared and swapped and found present. 1.3.x
cas_misses 64u Number of items that have been compared and swapped and not found. 1.3.x
cas_badvalue 64u Number of keys that have been compared and swapped, but the comparison
(original) value did not match the supplied value. 1.3.x
evictions 64u Number of valid items removed from cache to free memory for new items.
bytes_read 64u Total number of bytes read by this server from network.
bytes_written 64u Total number of bytes sent by this server to network.
limit_maxbytes 32u Number of bytes this server is allowed to use for storage.
threads 32u Number of worker threads requested.
conn_yields 64u Number of yields for connections (related to the -R option). 1.4.0
最有用的信息是number of cache hits, misses, and evictions.
The most useful statistics from those given here are the number of cache hits, misses, and evictions.
A large number of get_misses may just be an indication that the cache is still being populated with information. The number should,
over time, decrease in comparison to the number of cache get_hits. If, however, you have a large number of cache misses compared
to cache hits after an extended period of execution, it may be an indication that the size of the cache is too small and you either need to
increase the total memory size, or increase the number of the memcached instances to improve the hit ratio.
A large number of evictions from the cache, particularly in comparison to the number of items stored is a sign that your cache is too
small to hold the amount of information that you regularly want to keep cached. Instead of items being retained in the cache, items are
being evicted to make way for new items keeping the turnover of items in the cache high, reducing the efficiency of the cache.

3. memcached Slabs Statistics 查看slab的分配情况.
telnet 127.0.0.1 11211
stats slabs
—————
Statistic Description
chunk_size Space allocated to each chunk within this slab class.
chunks_per_page Number of chunks within a single page for this slab class.
total_pages Number of pages allocated to this slab class.
total_chunks Number of chunks allocated to the slab class.
used_chunks Number of chunks allocated to an item..
free_chunks Number of chunks not yet allocated to items.
free_chunks_end Number of free chunks at the end of the last allocated page.
active_slabs Total number of slab classes allocated.
total_malloced Total amount of memory allocated to slab pages.
我们应该关注:chunk_size ,total_chunks,used_chunks

4. memcached Item Statistics
stats items

5.memcached Size Statistics
stats sizes #慎用,会lock cache.

6. 使用http://code.sixapart.com/svn/memcached/trunk/server/scripts/memcached-tool 这个脚本 (memcached的创造着Brad写的)
基本用法.
Usage: memcached-tool [mode]

memcached-tool 10.0.0.5:11211 display # shows slabs
memcached-tool 10.0.0.5:11211 # same. (default is display)
memcached-tool 10.0.0.5:11211 stats # shows general stats
memcached-tool 10.0.0.5:11211 move 7 9 # takes 1MB slab from class #7
# to class #9.

各列的含义为:
列 含义
# slab class编号
Item_Size Chunk大小
Max_age LRU内最旧的记录的生存时间
1MB_pages 分配给Slab的页数
Count Slab内的记录数
Full? Slab内是否含有空闲chunk
从这个脚本获得的信息对于调优非常方便

7.我编写一个脚本,收集各memcached server的信息,发送每周报告.
配置文件示例./home/ooooooo/bbbbbbb/memcached_server_list.config
# 各memcached server的一个列表.
# 格式如下:
# hostname ip_address port
ap2222 13.33.33.33 31211,11212,12501
ap3333 13.33.33.34 31211,11212,12501

………..略.

参考:mysql-memcached-en.pdf

 » 转载保留版权:老陈 » 《获取memcached统计信息》
 » 如果喜欢可以: 点此订阅本站
分类: 互联网技术 标签: ,
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.