I am going through akka documentation & other wiki's. Can anyone tell me what is the difference between Dispatcher & Routers in Akka framework?
1 Answers
Dispatcher
and Routers
are two different concepts of Actor System. A dispatcher is basically a thread-pool, which means that dispatchers can be used to execute arbitrary code, of course, you can customize a configuration of thread pool (select between fork-join pool and thread executor, set up max/min parallelism level, check default dispatcher conf
reference.conf ). While term "Routers" is related to deployment process and specifying routing logic to route messages to a list of routees, where you can select a suitable strategy for pool/group (like RoundRobin, Broadcast, etc.), specify router paths (for a group).
From spec:
Routing: Messages can be sent via a router to efficiently route them to destination actors, known as its routees.
Dispatcher is what makes Akka Actors "tick", it is the engine of the machine so to speak, they can be used to execute arbitrary code, for instance Futures
As you see, both of them are responsible for an absolutely different part of Actor System, but you can combine both of them for customization of the same actor system configuration. For more details, check this article. HTH

- 1
- 1