4 ms·
Does anyone know why Axum is so much faster than the basic "spawn a new task to accept the connection and write the response" async webserver? I'm curious what
by adamch 5y ago
Does anyone know why Axum is so much faster than the basic "spawn a new task to accept the connection and write the response" async webserver? I'm curious what they're doing under the hood. They're both using the Tokio runtime, but Axum is based on Hyper. So I guess it boils down to how Hyper uses Tokio to efficiently accept/serve TCP connections?
EDIT: Actually I'm guessing a lot of it comes down to encoding the HTTP responses, now that I think about it.
- ibraheemdev 5y agoA lot of the difference likely comes from the fact that hyper implements HTTP keep-alive, meaning that multiple requests can be handled on the same connection, vs. having to create and terminate a conbection for every individual request.
- fasterthanlime 5y agoThat's a very good question — I feel like the article is set up in a way that you could easily take the TCP-based, hand-written server and try to match Axum/hyper's performance — implement keep-alive, be smarter about buffering, etc, and see what makes an actual difference. Of course if you reach a point where the only thing left to do is implement http/2, that... is no longer an evening project