node.jsredisconnection-pooling

Node.js Redis Connection Pooling


When using node_redis Node.js module with Redis, should I just use one connection as Redis is single thread process or shall I create a pool of connections to improve performance?


Solution

  • Just use a single connection. Both Node and Redis are effectively single thread. I don't think you'll gain anything by having multiple connections. I asked a similar question before starting to develop with Redis and it seems that one client/one application is pretty effective pattern.

    Highlighting an important note from the comments on this question. (Thanks to oskarth & stockholmux)

    For long running processes like servers, it is okay to use a single long lived connection.