Memcached client cluster Solution

Source: Internet
Author: User
Memcached client cluster Solution

By Mingjun Hou

  1. Cluster implementation

As a centralized cache, memcached has a central critical issue: single point of failure (spof). memcached supports the distribution of multiple instances on multiple machines, which only solves the problem of full data loss, however, when one of the machines fails, some data may be lost, and some eggs may be broken when a basket falls onto the ground. Therefore, we need to implement a backup mechanism to ensure that after some memcached fails, data can still be used, because this is also necessary for cluster.

 

 

(1) The application passes in the key to be operated, and obtains the client configured in the cluster through cachemanager.

(2) After obtaining the cache client, perform the cache operation.

(3) A. If it is a read operation, when it cannot hit, it will get data from other cache clients in the cluster. If it gets data, it will try to write it to the cache client obtained this time and return the result. (To achieve data recovery)

B. If it is an update operation, after the retrieved cache client executes the update operation, it returns immediately. the asynchronous update thread that submits commands from other machines in the update cluster to the client executes the column asynchronously. (Because the cache is obtained based on the key, asynchronous execution does not affect the query operation of this primary key)

Problem: If the timeout data is set, the copied data will become permanently valid after the data is lost.

2 localcache is used in combination with memcached to improve data acquisition efficiency ., Memcached does not have completely Zero loss. memcached communicates through socket data interaction. Therefore, the bandwidth, network I/O, and socket connections of the machine are all obstacles that restrict memcached from playing its role. One of the outstanding advantages of memcache is the timeout setting, that is, the data that is put in can be set to the validity period, which will automatically expire, in this way, some insensitive data can not be updated within a certain tolerable period, improving efficiency. According to this idea, each memcached client in the cluster can also use a local cache to cache the obtained data and set a certain expiration time to reduce the number of accesses to memcached, improve overall performance.

Therefore, each client has a built-in local cache with a timeout mechanism (using the lazy timeout mechanism). When obtaining data, first query whether the data exists locally, if it does not exist, initiate a request to memcache. After obtaining the data, cache it locally and set the validity period.

 

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.