From Akka docs :
“There are consequences to using a request, because something needs to be tracked when it expires, there must be something that connects Promise to ActorRef, and it must also be accessible via remote access. Therefore, always prefer to talk about performance, and only ask if necessary. "
But sometimes you want to send a message from outside the actor, in which case you can use ask . Using ask ensures that you get a response at the specified timeout, and sometimes what you want. However, when you use the ask pattern, you must ask yourself if you can just use Future instead.
There is a place for ask , but it should have very limited use due to the above reasons.
You do not need to use an actor on request. Some actors must be long-lived, and some not. If an actor performs a potentially dangerous or blocking operation, you can create one for each request. Whatever your application logic.
yǝsʞǝlA
source share