What are some useful tips/tools for monitoring/tuning memcached health?

后端 未结 2 1950
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-01 09:07

Yesterday, I found this cool script \'memcache-top\' which nicely prints out stats of memcached live. It looks like,

memcache-top v0.6       (default port: 1121         


        
相关标签:
2条回答
  • 2021-02-01 09:54

    Good interface to accessing Memcached server instances is phpMemCacheAdmin.

    I prefer access from the command line using telnet.

    To make a connection to Memcached using Telnet, use the following telnet localhost 11211 command from the command line.

    If at any time you wish to terminate the Telnet session, simply type quit and hit return.

    You can get an overview of the important statistics of your Memcached server by running the stats command once connected.

    Memory is allocated in chunks internally and constantly reused. Since memory is broken into different size slabs, you do waste memory if your items do not fit perfectly into the slab the server chooses to put it in.

    So Memcached allocates your data into different "slabs" (think of these as partitions) of memory automatically, based on the size of your data, which in turn makes memory allocation more optimal.

    To list the slabs in the instance you are connected to, use the stats slab command.

    A more useful command is the stats items, which will give you a list of slabs which includes a count of the items store within each slab.

    Now that you know how to list slabs, you can browse inside each slab to list the items contained within by using the stats cachedump [slab ID] [number of items, 0 for all items] command.

    If you want to get the actual value of that item, you can use the get [key] command.

    To delete an item from the cache you can use the delete [key] command.

    0 讨论(0)
  • 2021-02-01 10:00

    For a production systems, you should really set up active monitoring (with downtime alerts, automated restarts etc.) of Memcache using something like Monit. Here is an example config: Monitoring Memcache with Monit

    0 讨论(0)
提交回复
热议问题