danielSanchezQ / warp-reverse-proxy

Fully composable warp filter that can be used as a reverse proxy.
https://github.com/danielSanchezQ/warp-reverse-proxy
MIT License
48 stars 18 forks source link

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

Closed ssankko closed 3 years ago

ssankko commented 3 years ago

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 commented 3 years ago

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

danielSanchezQ commented 3 years ago

You can test it know from the branch in this PR

ssankko commented 3 years ago

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