首页 > 代码库 > 查看、分析memcached使用状态
查看、分析memcached使用状态
检查、剖析memcached运用状况
访问量上升,数据库压力大,怎样办?好办法是在中心挡一层缓存!这个缓存需求高效,不能比数据库慢,不然服务质量受影响;假如能把数据用hash打散存储到硬盘,也是能够的,不过在内存越来越廉价的今日,仍是运用内存吧!
mysql也有自个的缓存,也是存储在内存的,但是有一个说法是:
以下是引证片段:
只能有一个实例
意味着你能存储内容的上限即是你服务器的可用内存,一台服务器能有多少内存?你又能存多少呢?
只需有写操作,mysql的query cache就失效
只需数据库内容稍有改动,那怕改动的是其他行,mysql的query cache也会失效
再说,假如mysql都抗不住了,怎样还能盼望它供给的缓存呢?
所以我能够运用memcached了!他的优点和如何用能够参阅:
以下是引证片段:
1:《Memcache和mysql交互流程操作原理》
2:《让memcached和mysql非常好的作业》
开发时面对需求是个麻烦事,更绵长而堵心的是维护,所以我更关心的是memcached运行中的状况。还好的是,memcached的作者给咱们供给检查运行状况的指令。主要是“stats”,运用方法为 “telnet ip 端口号”,登录后运用“stats”指令。
然后你能够看见很多内容,详细能够参阅:《memcacche stats》
以下是引证片段:
pid = process id
uptime = number of seconds since the process was started
time = current time
version = memcached version
rusage_user = seconds the cpu has devoted to the process as the user http://www.haomad.com
rusage_system = seconds the cpu has devoted to the process as the system http://www.metabase.cn
curr_items = total number of items currently in memcache
total_items = total number of items that have passed through the cache
bytes = total number of bytes currently in use by curr_items
curr_connections = total number of open connections to memcached
connection_structures = ???
cmd_get = total GET commands issued to the server
cmd_set = total SET commands issued to the server
get_hits = total number of times a GET command was able to retrieve and
return data
get_misses = total number of times a GET command was unable to retrieve and
return data
bytes_read = total number of bytes input into the server
bytes_written = total number of bytes written by the server
limit_maxbytes = total storage bytes available to the server.
着重说一下几个对观测很有用的项。