Recommended way for connection pooling?
- 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
Assessment
This issue has not been assessed yet.