1, memcached is what, what role?
Memcached is a pure memory, KEY-VALUE,CS Architecture database service software, mainly used for database, Web server cache, to reduce the database, Web server access pressure, especially for the database, can be frequently accessed data cache to Memcache, This is done through the front-end program. For commonly used data when writing, not only to write to the database, but also to memcached memory write.
2, memcached service in the Enterprise Cluster architecture application scenario
Full cache
Hotspot Cache
Session hold
3, memcached service in different enterprise business application scenario workflow
When the program updates the data in the database, it will process the data in the database, then notify the data in the memcached to update the old cached data (can be implemented by the program, or the same MySQL MEMCA plugin to trigger the update), in short, it is important to maintain the consistency of the data. When the MEMCAD cache is exhausted, the data will be deleted according to the LRU (less recently use) algorithm, although it is possible to specify that the parameters do not delete the data using the LRU algorithm when starting memcached, but error. For high concurrency scenarios, or to warm up when the service restarts, load the data through the program into the cache.
4, memcached service distributed cluster How to realize?
1. Through the implementation of the program, so that different users to request the corresponding memcached server, of course, to mark the work beforehand, which user's data cache on which server, this method is more stupid, not smart.
2. Use the Load balancer (nginx,tengien,haproxy) to dispatch a user's request to a different memcached server
Problem: Different Server cache content is not the same, then how to guarantee the hit rate?
A: The load balancer has a variety of scheduling algorithms can use the Ip_hash algorithm can be used to ensure the consistency of the session, the algorithm is through the modulo operation, the hash value 1/the number of servers =hash value 2, the algorithm will maintain a hash table when requested to find the hash table, Find the correspondence between the request and the memcached server, achieve the consistency of the reply, and guarantee the cache hit ratio. However, the algorithm has a flaw, when the number of memcached host changes will make the previous hash data is not accurate, but also to recalculate the hash value. So this is not the best way.
3. The best way is to use a consistent hash scheduling algorithm, Tengien,haproxy,nginx (compile time to add a consistent hash of the module)
./configure--add-module=./3thparty/ngx_http_consistent_hash-master
5, memcached service characteristics and working principle is what?
CS Architecture Mode
Simple protocol
Supports the epoll/kqueue asynchronous IO model, using Libevent as the event notification mechanism
Key-value pair data type
Pure memory, high efficiency
Support for distributed
6, briefly describe the principle of memcached memory management mechanism?
The malloc memory allocation mechanism was first used, but the malloc mechanism caused memory fragmentation and now employs the slab memory management mechanism
memcached divides the memory area into several slab zones (1M in size)
The slab area is divided into several chunk memory blocks (chunks in different slab are not the same size)
Memcached maintains a memory allocation information table, which writes data to the slab partition central area that has the most chunk size and data size, which can reduce memory waste
Tip: Similar to disk Inode,block
7, memcached deletion principle and delete mechanism?
Memcached is an inert detection mechanism, does not actively detect whether the data is out of date, only when the data is get to detect whether the data expires, and when the data expires memcached only delete the index of the data, and does not free memory space, The memory space is freed only when the memcached invokes the LRU algorithm, or when the space is full
8, memcached server and client installation deployment and use of testing
9. How to realize session shared storage in a cluster?
10, how to get the status information of memcached service, for example: Hit ratio
You can log in to memcached via Telnet and use the stats command to view memcached information
by Memadmin
Nagios,cati,zabbix Monitoring Tools
11. What metrics should be monitored by nagios monitoring memcached
Shooting
12, what is Redis, what is the role?
13. What is the difference between memcached and Redis?
Memcached is a pure memory software that does not support persistent caching, and the cached data disappears after the server restarts.
Redis can cache in-memory data to disk for persistent storage
memcached 10 Ask Ten answers