开发者

Node.js: How Many Redis Clients?

In Node.js, would it be bes开发者_如何学Pythont to do a createClient() for each individual HTTP request or user, or would it be better to re-use the same client for all requests? Do you still get the speed of several parallel clients with just one?


In Node.js, would it be best to do a createClient() for each individual HTTP request or user, or would it be better to re-use the same client for all requests?

You should reuse the redis client connection and persist it during the lifetime of your program since establishing a new connection have some initial overhead which can be avoided with already connected client.

Do you still get the speed of several parallel clients with just one?

You might get some performance improvements with a pool of several parallel clients (limited number, not dedicated connection for each individual HTTP request or user), but the question is how would you deal with the concurrency of executed commands. Although redis is built to handle hundreds or thousands of simultaneously connected clients, connection pooling is something which, I think, should be controlled by the client library you are using. However you should use two parallel connections if you are simultaneously using redis for listening on some pub/sub channel and at the same time executing normal commands.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜