paritytech / jsonrpsee

Rust JSON-RPC library on top of async/await
MIT License
624 stars 167 forks source link

Connection pool in client side #1212

Open venugopv opened 11 months ago

venugopv commented 11 months ago

We're trying to set up a connection pool on the client-side but haven't found a way to do so using https://docs.rs/jsonrpsee-core/0.20.1/jsonrpsee_core/index.html.

Our setup is simple: we create a few HttpClients( using https://docs.rs/jsonrpsee-http-client/latest/jsonrpsee_http_client/struct.HttpClient.html )and then make request/batch_request calls. However, it's unclear how jsonrpsee manages HTTP connections.

I've looked into jsonrpsee's HttpClient code (at https://github.com/paritytech/jsonrpsee/blob/master/client/http-client/src/transport.rs#L170), but I couldn't find where it handles connection pooling.

It would be great if we could get some more info on connection pooling usage in jsonrpsee.

niklasad1 commented 11 months ago

Hey @venugopv

The HTTP connections are handled by the hyper "connection pool" and jsonrpsee is using the default settings. So why do need to setup a special pool? Sure it would be great to document the jsonrpsee is using the hyper HTTP client that takes care of the connection pool..

I think it could be a good idea to document the connection pooling and maybe provide more fine-grained settings for the connection pool.

Are you running into some issues or why are you thinking about connection pooling?

venugopv commented 11 months ago

Hi @niklasad1, thanks for your quick response. I did look into Hyper's HTTP client connection pool, but unfortunately, jsonrpsee doesn't offer a way to configure those values. It would be great if it did.

Secondly, I couldn't find an easy way to force the jsonrpsee HTTPclient[builder] to use only HTTP/2

niklasad1 commented 11 months ago

Right, are you willing to open a PR to expose those?

I would accept such change

venugopv commented 11 months ago

@niklasad1, sure, I'm happy to do. I will consider. Just to clarify, should the pull request contain both the Hyper HTTP connection pool and HTTP/2 configuration options for jsonrpsee's HttpClient/Builder?

niklasad1 commented 11 months ago

would be nice with two different PRs but either way is fine :)