Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recreating reqwest::Client forces tcp connection to be established each time. #33

Closed
ssankko opened this issue Feb 11, 2021 · 3 comments · Fixed by #34
Closed

Recreating reqwest::Client forces tcp connection to be established each time. #33

ssankko opened this issue Feb 11, 2021 · 3 comments · Fixed by #34
Labels
enhancement New feature or request

Comments

@ssankko
Copy link

ssankko commented Feb 11, 2021

Hello!

I have remote server on the other side of the globe. Simple (first) postman request to this server takes around 600ms to complete, including dns lookup and tcp handshakes.
image

Consecutive requests use cached dns and handshakes, so one request takes around 160ms.
image

Though, when i send identical request to localhost reverse proxy each request takes around 330ms. I guess establishing new connection each request takes its toll.
image

Using already existing reqwest::Client cuts time in half, resulting in around 162ms.

I propose maybe use one Client, created lazily with lazy_static.

@danielSanchezQ danielSanchezQ added the enhancement New feature or request label Feb 12, 2021
@danielSanchezQ
Copy link
Owner

danielSanchezQ commented Feb 12, 2021

Thanks! @ssankko, That sounds like a good improvement. I'll implement.
Would you mind doing some performance testing with the branch once done?

@danielSanchezQ
Copy link
Owner

You can test it know from the branch in this PR

@ssankko
Copy link
Author

ssankko commented Feb 15, 2021

@danielSanchezQ I tested it, and it sure did speed up consecutive requests!
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants