Hi, @ikevin,
I’d like to clarify what is the definition of “async” in this aspect?
Sometimes people confuse async with parallel. It is possible to be async with just a single thread. If a single-threaded, synchronous (non-async) web server needs to, for example, access a remote database to satisfy a web request, then the thread servicing the web request will block on the result from the database. A second web request will be ignored until the first has completed, even though the web server is, in fact, idle waiting for a response from a remote system, in this example.
An async web server (again with just one thread) can "switch contexts" by issuing the remote DB query, then, instead of blocking, service a second request, perhaps respond, then retrieve the now available query result for the first request, and then respond to the first request.
I thought all web servers must be async because they can handle thousands/millions of connections simultaneously.
As others have pointed out, not all web servers are async. The advantage of an async web server is that it can service more requests on a single thread than a synchronous web server. Given that each thread is a resource that has OS overhead, async web servers should have better scalability, provided dispatching received requests are not bound by local resources (which they frequently are). It's worth pointing out that async web servers are not necessarily faster (note: both Iron and Rocket are synchronous Rust web frameworks, yet significantly outperform Gotham in this simple benchmark--the use case matters!): Benchmarks ? · Issue #27 · gotham-rs/gotham · GitHub
And finally, to your title question:
Why Rocket isn’t async
According to Rocket's author:
The Rust asynchronous I/O space is in heavy flux. The Tokio 0.1 release today is a milestone in reaching stability, but there's still a long road ahead. Rocket will be fully asynchronous in the future, but the approach must be made with care. Usability is of utmost importance, and performing and handling async. I/O with Rocket cannot be an exception.