Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection pooling #226

Closed
RajivKurian opened this issue Jun 18, 2012 · 6 comments
Closed

Connection pooling #226

RajivKurian opened this issue Jun 18, 2012 · 6 comments

Comments

@RajivKurian
Copy link

All the examples on the net suggest using one connection and to depend on callbacks. Since node.js is single threaded is there any use of a connection pool given node's single threaded model? If the answer is yes, is there a way to use connection pool using node_redis?

@DTrejo
Copy link
Contributor

DTrejo commented Jun 18, 2012

Hey R,
node uses a connection pool under the hood (at least for HTTP, and I would imagine other protocols as well) — thus I think node_redis uses one as well.

Cheers,

D

@DTrejo DTrejo closed this as completed Jun 18, 2012
@euskode
Copy link

euskode commented Sep 14, 2012

I myself only see a single TCP connection being made from our backend server to redis over 6379 (as observed via tcptrack).

Could somebody clarify this? Does it make sense to maintain a single connection between client and server, or should node_redis be creating many connections (the way that the mongodb native node driver does it) to handle heavy loads?

@mranney
Copy link
Contributor

mranney commented Sep 14, 2012

Each client instance uses a single TCP connection. Because node_redis pipelines all commands, this ends up increasing throughput for most workloads by reducing the number of kernel/user traversals in both client and server. This is something that happens automatically, and most of the time, you shouldn't need to worry about it.

However, there are a few times when opening multiple connections is necessary. If you are doing subscribe or blocking pop, then this ties up the connection on the server side unti the command completes. If you are doing watch, then the watch commands will be shared between all activity of the server. For these cases, you need to set up a new connection.

I've toyed with automatically setting up new connections for these cases, and it ends up adding a lot of complication, especially with testing.

@superfeedr
Copy link

Matt, should we understand from your last comment that pooling is not going to be a part of node_redis?
I understand this is not useful in most cases, but as you said, there are few ones where it may actually make sense.

@subnetmarco
Copy link

+1, a connection pool is useful for high throughput applications.

@brycebaril
Copy link
Contributor

The most useful case of pooling I can think of is more of a contextual one -- where it transparently handles subscribing connections vs standard read/write connections, and possibly a separate connection for WATCH transactions. Other than that I don't objectively know where the benefit of pooling would surpass that of pipelining on a high throughput application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants