reactor-netty icon indicating copy to clipboard operation
reactor-netty copied to clipboard

Provide `ConnectionProvider` configuration for limiting the number of the connection pools

Open violetagg opened this issue 1 year ago • 6 comments

This is a follow up issue for https://github.com/reactor/reactor-netty/issues/3315#issuecomment-2188770825

violetagg avatar Jun 26 '24 08:06 violetagg

@violetagg when read from

https://projectreactor.io/docs/netty/release/api/reactor/netty/resources/ConnectionProvider.htm Build a ConnectionProvider to cache and reuse a fixed maximum number of Connection.

but here https://projectreactor.io/docs/netty/1.2.0-M4/reference/tcp-client.html Connections used by the TcpClient are never returned to the pool, but closed. When a connection is closed, a slot is freed in the pool and thus a new connection can be opened when needed.

so, how can ConnectionProvider reuse connection? any one can help?

cloudzhou avatar Aug 16 '24 06:08 cloudzhou

@cloudzhou for TCP client you cannot reuse the connections, the connection pool is used to limit the number of the connections that you can open.

violetagg avatar Aug 16 '24 07:08 violetagg

so confused about that, TCP client and reuse connections is so common and important the default implement need to pooled and reuse connections as base usage

cloudzhou avatar Aug 16 '24 08:08 cloudzhou

@cloudzhou as we pointed in the documentation https://projectreactor.io/docs/netty/1.2.0-M4/reference/tcp-client.html#connection-pool we don't know what protocol is used on top of TCP and whether the connections are recycled and ready to be reused.

violetagg avatar Aug 16 '24 08:08 violetagg

so is there a recommend way to pooled and reuse the connection? some document or open source code demo?

cloudzhou avatar Aug 16 '24 09:08 cloudzhou

@cloudzhou Take a look at R2DBC pool https://github.com/r2dbc/r2dbc-pool (it uses TcpClient)

If you have more questions let's continue on Gitter

violetagg avatar Aug 16 '24 10:08 violetagg