The spray uses Akka under the hood, and Futures . It is asynchronous in the sense that incoming requests are sent to the Akku Actors, who, in turn, send the request and ultimately generate a response.
In overly simplified terms, the request arrives at the request processing handler and is asynchronously passed to another entity who may deal with routing. A request processing actor can process additional requests without blocking to process the response. A routing activator can pass a specific route handler in the same way. It can be sent to the actor with a ready-made answer.
Actors can have different types of dispatchers that determine how they interact with message processing threads, but essentially the goal is to write code that never or rarely blocks, which is what people working on Spray did.
source share