Memcached client summary, memcached Summary

Source: Internet
Author: User

Memcached client summary, memcached Summary

This article will briefly introduce the features of memcached from the perspective of memcached usage, from the client, protocol, and server.

Memcached is a high-performance distributed K-V memory storage system, which maintains a hash table in the memory, because it can be read in the memory, so the read and write speed is very fast, because the content in the memory, it will be lost after power failure, so the reliability is not as good as that of db. Now, memcached and BDB are combined together, called memcacheDB. We will not discuss it here..

Because of its fast reading and writing speed, memcache is mostly used in the cache between web machines and db layers in server applications.

For memcache, its distribution is implemented on the client. The client uses the consistent hash algorithm to implement the distributed memcache.

Brief Introduction to consistent hash:



Calculate the hash value of each memcached service node, and sort it clockwise on a circle according to the hash value size. When a new key is stored, calculate its hash value, perform a clockwise search to find the node with the first hash value greater than the hash value of the key. If the node cannot be found, take the first machine and store it on the node. The advantage is that if a node is added, only the access to the hash value key between the newly added node and the previous node changes, as shown in:


This greatly reduces the impact on the hit rate after the machine is increased.

However, the following situations may occur:


In this case, the storage volume of server1 is much larger than that of server2 (only the key of the hash values in the middle of server1 and server2 will be saved to the cache). Here, the memcache client uses virtual nodes to achieve load balancing.

The so-called virtual node is to set some points on the circle, so that a key falling in the interval of these points is attributed to the two machines above. The specific method can be: for the two nodes above, add the # Serial number after the name. Suppose we set three virtual nodes: server1 #1 server1 #2 server1 #3, server2 #1 server2 #2 server2 #3, calculate the hash value of the node after setting. shows the distribution of nodes.

 


In this way, we add some nodes, and the load is balanced.


The above is some knowledge about the memcache client.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.