google / google/tarpc

Recommended way for connection pooling?

Open
#408 4 comments 1 reaction 0 assignees View on GitHub
documentation help wanted question
Dominant language
Rust
Stars
3.7k
Forks
230
PR merge metrics
No merged PRs in 30d

Description

Is there any recommended way to do connection pooling with tarpc? There doesn't seem to be an example for doing such.

I tried to use the common connection pools for databases(deadpool and bb8) and with simulating a 100ms sleep it seems to take 1 second to fulfill requests instead of closer to 100ms. There is no issue when I run it as a single OnceCell static connection without pooling, I get 106ms which seems closer to correct

I can get around the 1 second loading issue from connection pooling by increasing the max connection count but I don't think having thousands of connections is ideal. So the workaround I did was to create a Vec>connections, and then set the max pool size to thousands and just clone the Arc based on AtomicUsize. And use StubbornTcpStream to handle the reconnects

That seems to work better and get me 117ms, but still quite a bit of a penalty. I am rather new to Rust so wanted to be sure I'm not doing anything wrong and requesting in general if it would be possible to get an example for connection pooling properly with tarpc.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.