Reputation: 2415
I created a repository with a Node.js based and a Rocket.rs based web server inside.
Consider these steps:
cargo run --release
node server.js
I observed a similar thing with actix-web too, though to a lesser extent: in that case, I only get the ~300ms delay if I haven't refreshed the tab for about 5 seconds. If I keep refreshing it, then requests finish under 5ms.
Interestingly, the delay seem to not occur if I measure via curl like this and this. I get around 4ms latency with both servers.
I noticed that Rocket and actix-web do not send Keep-Alive headers in their response. Which, if I understand it correctly, shouldn't matter for HTTP 1.1 requests.
I'm using WSL 2 with Ubuntu installed. Chrome is running in the host Windows.
Could somebody please shed some light on what's going on here?
Update: Forgot to mention that I was using nightly compiler to build the rocket server (Rocket v0.4.6 seem to require it). Changing to stable and building straight from the master branch got rid of the delay. The actix-web delay is still a bit concerning though, because I used stable compiler with that one.
Upvotes: 10
Views: 1338
Reputation: 190
Running all from windows, in node the response time is around 2-4 ms
, and in rocket 1-2 ms
. There is something weird happening on your enviroment.
Also tried on serving from WSL and same results.
Even on debug(rust) it takes on average +1ms
more than on release, it might be some weird browser issue.
Upvotes: 1