Memcached Client Summary

Source: Internet
Author: User
Tags memcached

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

memcached is a high-performance distributed K-V memory storage System, which maintains a hash table in memory, because it can be read in memory, so read and write fast, because the content exists in memory, the power loss will be lost, so the reliability is inferior to the DB, Now there are memcached and bdb together, called Memcachedb, which is not discussed here .

Due to its fast read-write speed, memcache is used in server-side applications to cache between Web machines and DB planes.

For Memcache, its distribution is implemented on the client side, and the client uses a consistent hash algorithm to achieve memcache distribution.

A brief description of the consistency hash:



For each memcached service node calculates its hash value, and according to the size of the hash value in order to arrange it clockwise on a circle, when there is a new key to store, calculate its hash value, and follow the clockwise lookup, found the first hash value is greater than the hash value of the key node , if it is not found, take the first machine and store it on top of the node. The advantage is that if you add a node, the access to the key with the hash value between the new node and its previous node will change, as shown in:


This greatly reduces the impact on the hit rate after increasing the machine.

However, the following conditions may occur


In this case, the amount of server1 is much larger than the amount of server2 stored (only the Server1 and server2 of the middle hash value of the key will be stored in the cache), here, the Memcache client uses the virtual node way, to achieve load balancing.

The so-called virtual node, is to set some points on this circle, so that the fall in these points within the range of a key to the above two machines up, the specific method can be, to the above two nodes, after the name with the # number, assuming we set three virtual nodes, respectively, is server1#1 server1#2 Server1#3,server2#1 server2#2 server2#3, after setting the hash value of the compute node, the node is distributed as shown


This is equivalent to adding some nodes so that the load is balanced.


These are some of the Memcache client's knowledge.

Memcached Client Summary

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.