title: Redis Pub Sub : Design pattern
body: <p>We are using socket i/o for lots of live data. User sends/receive the data using sockets. As we are using load balancer, we cannot use socket i/o's namespace model and instead using redis' pub/sub within socket.</p>
  
  <p>Till now, we were creating a separate redis conection for subscription per user per channel. But recently we faced an issue that of max connection reached (<code>Error: Ready check failed: ERR max number of clients reached</code>) on redis and we figured out that it is because of having too many redis connections through pub sub.</p>
  
  <p>To counter that, it occurred to me that instead of using multiple subscribe redis connections per user, why not have a one publish redis connection and one subscribe redis connection which will listen to all channels and can be achieved by:</p>
  
  <pre><code>var pub = redis.createClient();
  var sub = redis.createClient();
  sub.psubscribe('*');
  </code></pre>
  
  <p><code>sub</code> will listen to all channels. Also, we can store information about channels to which user is subscribe in socket object and handle data accordingly.</p>
  
  <p>Hopefully, I am clear with the problem statement and would like to understand how will be the performance using this design pattern?</p>