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

what is the difference between connection pool and "maxConnections"? #2052

Closed
PyAntony opened this issue Feb 22, 2022 · 4 comments
Closed

what is the difference between connection pool and "maxConnections"? #2052

PyAntony opened this issue Feb 22, 2022 · 4 comments
Labels
for/stackoverflow Questions are best asked on SO or Gitter

Comments

@PyAntony
Copy link
Contributor

Hi,

I've been trying to understand (for days) the distinction between "connection pool", which defaults to 500, and "maxConnections", which defaults to 2 * N processors. I thought I understood, but after reading this thread (#1222) clearly I don't. Can someone please explain the difference to me?

Documentation states a max connection pool of 500, with up to 1000 connections in "pending" state. then it says that "maxConnections" defaults to 2 * N processors??? I thought these 2 concepts were different, but reading through this thread it seems like connection pool and "maxConnections" is the same thing? please explain.

@violetagg
Copy link
Member

@PyAntony Thanks for getting in touch, but it feels like this is a question that would be better suited to Gitter or Stack Overflow. As mentioned in README, we prefer to use GitHub issues only for bugs and enhancements.

For this particular question:

As described in the ConnectionProvider builder javadoc https://projectreactor.io/docs/netty/release/api/reactor/netty/resources/ConnectionProvider.ConnectionPoolSpec.html#maxConnections-int-

If you do not specify maxConnections then the connection pools will be created with:
2 * available number of processors (but with a minimum value of 16)
If you do not specify pendingAcquireMaxCount then the connection pools will be created with:
2 * max connections

Reactor Netty provides three ways of creating a client (let's take for simplicity the HttpClient)

  • HttpClient.create() - this uses a predefined ConnectionProvider, which is created like this ConnectionProvider.create(name, 500). This means 500 maxConnections (this is explicitly specified in the ConnectionProvider builder) and 1000 pendingAcquireMaxCount (this is the default provided by the ConnectionProvider builder)
  • HttpClient.create(ConnectionProvider) - the user provides a custom ConnectionProvider
  • HttpClient.newConnection() - this disables the connection pooling

Documentation states a max connection pool of 500, with up to 1000 connections in "pending" state.

This is the predefined ConnectionProvider used for the Reactor Netty clients if you used the default construction create()

then it says that "maxConnections" defaults to 2 * N processors???

This is the default for the ConnectionProvider builder

@PyAntony
Copy link
Contributor Author

Thank you for the explanation, and sorry for asking here. It is clear now. I think this is not understandable from the documentation alone (https://projectreactor.io/docs/netty/release/reference/index.html#_connection_pool_2). Would it be possible to add a couple of sentences to documentation to clear this confusion?

@violetagg
Copy link
Member

@PyAntony Would you like to provide a PR for a change in the documentation?

@PyAntony
Copy link
Contributor Author

Sure, I'll prepare that. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for/stackoverflow Questions are best asked on SO or Gitter
Projects
None yet
Development

No branches or pull requests

2 participants