I need to issue a long sequence of REST calls to the same server (let's call it myapi.com). At the moment, I am using the Rust library reqwest as follows:
- I create a
reqwest::Clientwith all default settings. - For each REST call:
- I use
client.post("https://myapi.com/path/to/the/api")to create areqwest::RequestBuilder. - I configure the
RequestBuilderto obtain areqwest::Request. - I
send()theRequest, read thereqwest::Response. - I drop everything except the
Client, start again.
- I use
I read in the docs that reqwest is supposed to pool connections within the same Client. Given that I always reuse the same Client, I would expect the first API call to take some more (owing to the initial TCP and HTTPS handshakes). However, I observe always a consistent, quite high latency across all requests. So, I am wondering if connections are reused at all, or re-established every time. If they are not, how do I get to recycle the same connection? I feel that latency would be drastically reduced if I could save myself some roundtrips.