Cache study notes (c) - memcached distributed implementation

The previous sections have been introduced memcached memory structures and deletion policies, this section focuses Laijiangjiang memcached distributed implementation, due to the memcached does not support distributed implementation on the server side. Therefore, the implementation of memcached distributed entirely by the client are implemented.

First, what is distributed

Simple, is to improve the performance of distributed systems, various components of the system will be distributed on different servers, each of the components to exchange data via a communication network, and further coordination.
To explain the concept of distributed by the following example.
It is assumed that we currently have three memcached server, our client needs to save the key as "apple", "orange", "banana" data.
Here Insert Picture Description
Here we assume that we want to save this data as a key apple, the first client in accordance with its algorithm (generally hash algorithm) to decide to save the data to the cache memcached server. The other key is to follow the same method, the same value at the time, will first select the appropriate server, making the value.

By this way more than just a distributed memcached, and memcached caching service after its increase, the cached data will be scattered when a cache server is unavailable, it will not affect other cache servers.

Second, distributed algorithm

1. take the remainder distributed algorithm

The idea here is to introduce a distributed algorithm, the algorithm is relatively simple, is to select a server based servers take the remainder were. However, what should you take it? Because we usually based on key query, so we should be taking more than using the key. In general we will not be a key value, where we can easily think of using a hash algorithm to the key, to get a value, then this value by more than can be taken to select the appropriate server.
This idea is simple and easy to implement, but there is a very important drawback is that when with the increase in business, we need to add a cache server may consume a high price. Since taking over operations previously were not in precise, the situation appears a large number of cache misses.
Here you can be added on a single server to resolve multiple instances memcached, which logically library manner, when the need to expand, only need to be split into the respective logical bank number and the same physical database.

Of course, there are other distributed algorithms, research can go their own research interested.

Summary: So far, about Memcached learning content to the end, because the current memcached does not support serialization, the data structure is relatively simple, the components are replaced by other caching software, such as: redis and so on.

Published 66 original articles · won praise 26 · views 10000 +

Guess you like

Origin blog.csdn.net/Time__Lc/article/details/103660328