Memcached: high-performance distributed memory cache server
features :
The U protocol is simple :
n text-line-based protocols
U - libevent -based event handling :
N Library , can realize the increase of the number of connections , O (1) performance
U Internal Memory storage mode
n data stored in memory , restart data disappears , when data reaches a certain value , based on LRU (last recently used) algorithm to delete unused caches
U Memcached distributed non-communication
n the server side does not have distributed functionality , and the implementation is distributed depending on client
N
use of Memcached :
U Save the method :
N Add: save only if the storage space does not exist the same data
N Replace: save only if the storage space has the same data
N Set: save whenever
method of getting the u
N Get: take a data
N get_multi: fetching multiple data
U Delete Data
n Delete
U increment one and minus one operation
N incr
N ADD
Slab Allocation mechanism : allocating , managing memory Mechanisms
divide the memory into blocks of a certain length , block the same size , and Select the appropriate blocks based on the size of the data.
resolves a memory fragmentation problem , but creates a waste of memory ( such as 100bytes of data to be stored in a block of )
tuning : adjusting the block size of a group based on data size
data deletion aspects of Memcached
U Memcached does not really delete data , does not monitor expired data , but checks for expiration at get , This technique is called lazy ( lazy )
U LRU overwrites the least recently used data
Memcached 's Distributed
You are fully implemented by the client : based on the key , the client's algorithm to obtain which memcached server is stored , Fetch according to the same algorithm .
The function Library of the U-client cache::memcached realizes the distributed function
N dispersion based on the remainder : that is, according to the remainder of the number of servers scattered , to obtain the hash value of the key to take the remainder
N Cons : Add or remove Servers , the cost of cache reassembly is large
U consistent Hashing dispersion algorithm
N Find the hash value of each server and configure it to
Memcached: High-performance distributed memory cache server