< beitmemcached > < key= "name1" value= "Server1:port"/> < Key = "name2" value= "Server1:port,server2:port,server3: Port "/></beitmemcached>
The client I use is beitmemcached, the configuration file can be in two ways, such as the above code, with a single configuration and multiple configurations
Problem:
When using a single server configuration, if this Memecache server hangs, then the client side of the cache node can not be used, affecting the operation of the program
When using multiple configurations, if one of them hangs up and you cache, the client will choose which cache server to store in accordance with your cached key value, and if you have bad luck, just save it to the problematic server, sorry, the write failed.
Solution:
Use more than one configuration scheme, modify the client source code, if one of the server hangs, when the cache operation fails, the problematic cache server to reject the client collection, such as the A,b,c three memcache services, if B hangs, in the operation of the cache, there will be an exception, This time the B is removed from the sequence, using only a,c to operate;
Set a detection interval, and each time the cache is manipulated, the problematic server is detected after the interval, and if the server returns to normal, it is re-added to the cache server collection.
How to use:
Public memcachedclient getclient () { var mc = memcachedclient.getinstance ("name2"true); return MC; }
Just add a true parameter when you get the client instance.
: Http://pan.baidu.com/s/1eQtOO6Y
Other solutions:
Can use Memagent to configure the Memcache cluster, but I feel that each server to install a software, a variety of configuration is more troublesome, my method is relatively simple, I feel is very practical.
Memcached troubleshoot a single server failure problem