IronCoreLabs / ironoxide

Rust SDK for IronCore Privacy Platform
https://docs.rs/ironoxide
GNU Affero General Public License v3.0
10 stars 3 forks source link

Every request starts a new client & connection #324

Closed jmreardon-yoppworks closed 1 month ago

jmreardon-yoppworks commented 1 month ago

I've observed that every request to the IronCore server starts a new TCP (and therefore TLS connection) resulting in a time-consuming TLS handshake for every request. This appears to be due to ironoxide instantiations a new Client for every request:

https://github.com/IronCoreLabs/ironoxide/blob/95405fa3aaa5ce744a7daeac3516285a6da0bdfb/src/internal/rest.rs#L536

Per the reqwest docs, the Client has it's own connection pool and it is expected to be instantiated once and be resued. It's possible the startup time for creating a new Client is slow as well.

BobWall23 commented 1 month ago

We'll investigate adding the client to IronCoreRequest. We noticed this problem and fixed it in other products, but didn't check it here. Thanks for the report.

skeet70 commented 1 month ago

We fixed this in #325, though in our benchmarks it didn't make a performance difference either way.