Redis multiple connections opened with TIME_WAIT state
<p>I am using common redis for storing data from almost 60 systems.This common redis is used for communication between all machines. At first everything was seemed to be working fine but as I increased machines from 60 to 80 ,number of connections to redis increased and after that it didn’t start to accept any more connections causing a big problem.</p>

<p>When I started to debug the issue using  'netstat -na | grep 6379' I found out that whenever we connect to redis it opens an TCP/IP connection at particular port and didn’t release that connection and kept that connection in TIME_WAIT state for almost 60 seconds even after calling  $redis->quit() (using predis library of PHP)</p>

<p>Methods I tried to overcome this issue : </p>

<p>1) I tried to decrease timewait seconds in /proc/sys/net/ipv4/tcp_fin_timeout but it was not right solution.</p>

<p>2)I shifted from PHP to nodejs and  tried connection pooling in nodejs but no success.Here is sample code</p>

<pre><code>app.get('/setinredis',function(req,res){

 var poolRedis = require('pool-redis')({
    'host': 'localhost',
    'password': '',
    'maxConnections': 5
    });

   poolRedis.getClient(function(client, done) {

        client.get('somekey', function(err, value) {
            console.log('value from redis is:', value);
            done();
            res.send({message:"Done"});
        });
    });
</code></pre>

<p>});</p>

<p>Is there any way to solve this problem efficiently or any alternative to redis with data structure functionality.</p>

<p>Any help would be appreciated.</p>