In Node.js, would it be better to create createClient () for each individual HTTP request or user, or would it be better to repeat using the same client for all requests?
You must reuse the redis client connection and keep it for the entire lifetime of your program, since establishing a new connection has some initial costs that can be avoided with an already connected client.
Do you still get the speed of multiple concurrent clients with only one?
You can get some performance improvements with a pool of several concurrent clients (a limited number, no dedicated connection for each individual HTTP request or user), but the question arises as to how you will deal with concurrency of executed commands. Although redis is built to handle hundreds or thousands of concurrently connected clients, the connection pool is what I think should be controlled by the client library used. However, you should use two parallel connections if you are using redis at the same time to listen on some pub / subchannel and at the same time execute the usual commands.
yojimbo87
source share