1. Install and start memcached
Installation:
Yum-y install memcached
Start:
Chkconfig -- level 2345 memcached on
Service memcached start
View status:
Memcached-tool 127.0.0.1: 11211 stats
Important indicators:
- Cmd_get query cache times
- When _set sets the number of times key => value is set, the cache is written if no value is found.
- Total get_hits hits get_misses total missed hits
Configuration file:
2. Monitor memcached --- memadmin
Monitor Tool installation:
- 1) Yum install PHP-perl-memcache
- 2) Add extension = memcache. So to the dynamic extensions code block of VI/etc/PHP. ini.
- 3) restart the apache service
- 4) Access URL: http: // your IP/memadmin (admin/123123)
Use of monitoring tools:
Http://www.junopen.com/memadmin/
3. memcached Performance Testing Tool --- twemperf (mcpery)
A memcached performance testing tool that can simulate high-concurrency set and get operations.
Instance used:
Mcperf -- num-Conns = 1000 -- Conn-rate = 1000 -- num-CILS = 10 -- call-rate = 1000 -- timeout = 5 -- linger = 0 -- sizes = d1
Create 1000 concurrent connections. The creation speed is 1000 per second. Each connection sends 10 set requests (equivalent to 10 iterations). These 10 requests are delivered at 1000 per second; set the connection and response timeout time to 5 S, set the TCP connection disconnection time (disabled by default), and send the storage data (1 byte by default ), we set it to 1 byte (that is, the size of the value stored in memcached ).
Result field explanation:
4. memcached Optimization Method
1) The larger the stored data, the more obvious the speed of memcached processing requests as the number of concurrent requests increases. Therefore, the storage data should not be too large. If you really want to store large data, we recommend that you split it into two or more keys for storage.
2) The higher the cluster Deployment Performance (the smaller the average time consumption and the larger the throughput)
3) The key in memcached can contain a maximum of 250 English characters or 27 Chinese characters. If the key exceeds the maximum value, data cannot be stored. In addition, the official document pointed out that the value can store up to 1 MB of data, and data larger than 1 MB cannot be stored. Therefore, it is recommended that the key and value should not be too large. If the value exceeds 1 MB, we recommend that you store the data in two or more keys.
4) after the memory of memcache is full of data, the data that is stored later will not consume memory, and the oldest data will be deleted (LRU algorithm ), by default, the memcached startup parameter enables LRU (least recently used algorithms. If-M is added to the startup parameter, the LRU algorithm is not enabled. If the memory is full, an error is returned.