Memcached solves the fault of a single server.
<Beitmemcached> <add key = "name1" value = "server1: port"/> <add key = "name2" value = "server1: port, server2: port, server3: port "/> </beitmemcached>
The client I use is BeITMemcached, And the configuration file can be in two ways, such as the above Code, with a single configuration and multiple configurations
Problem:
If this memecache server fails to be configured on a single server, the cache node on the client side will not be used, affecting program running.
When multiple configurations are used, if one of them fails, When you store the data in the cache, the client will use the consistent hash algorithm to select which cache server to store based on the cached key value, if you are not lucky, you are saved to the faulty server. Sorry, writing fails.
Solution:
Use multiple configuration schemes to modify the client source code. If one of the servers fails, remove the problematic cache server from the client set when the cache operation fails, such as A, B, C Three memcache services. If B crashes, there will be exceptions when operating the cache. In this case, B will be removed from the sequence and only A and C will be used for the Operation;
Set a detection interval. During each cache operation, the faulty server will be detected after the interval. If the server returns to normal, it will be readded to the Cache Server collection.
: Http://pan.baidu.com/s/1eQtOO6Y
Other solutions:
You can use memagent to configure a cluster for memcache. However, I feel that each server has to install a software. various configurations are troublesome. My method is simple and I feel very practical.