Saturday, 22 April 2017

nodejs memcached if one server is down, others also do not get queried

I have 2 memcached servers, and I am using memcached nodejs client.

https://github.com/3rd-Eden/memcached#server-locations

Now the issue is , if I stop memcached from any one server, the other server also do not get any query. but it should save data on other servers altleast.

var Memcached   = require('memcached');
var memcached   = new Memcached(['127.0.0.1:11211','2nd server:11211'], {retries:0,retry:0,remove:false,failOverServers:['3rd:11211']});

// Added failure log

memcached.on('reconnecting', function( details ){ console.log( "Total downtime caused by server " + details.server + " :" + details.totalDownTime + "ms");});

memcached.on('failure', function(details) {
    console.log(new Date() + " -  - - Server " + details.server + "went down due to: " + details.messages.join( '' ) ); 
});
memcached.on('reconnecting', function(details) { 
    console.log(new Date() + " -  - - Total downtime caused by server " + details.server + " :" + details.totalDownTime + "ms");
});

memcached.on('issue', function(details) { 
    console.log(new Date() + " -  - - Server " + details.server + " has an issue: " + details.messages.join( '' ));
});

when I do

 memcached.add(key, value, expiry, function (err) { 
    if(err){
        callback(false);
    } else {    
        callback(true);
    }
 });

I get logs for failure server connect ECONNREFUSED

but the server at localhost also do not get anything saved in cache.

also there is nothing in the memcached of 3rd server

I used this command to see what's happening

memcached -vv -m 1024 -u memcache -l 127.0.0.1 -p 1121

I have memcached@2.2.2 node npm

and node version V6.0.0 and Linux RedHat Servers



via user5821368