In this source code example we extend our analogy by introducing elacticity in the form of Parallelization
. Our basic actor layout will stay the same with a small change to how we implement our Librarian
:
In our Messaging
example, we implemented Librarian
as a single child actor. In this example we will change this by implementing our Librarian
as a router that supports a configurable number of Librarian
routees.
By increasing the number of Librarian
actors and parallelizing
our throughput, we significantly increase our processing speed in the face of increasing load.
- Run a terminal session and navigate to the root directory,
reactive-application-development-scala
. - Run
sbt
. - Inside the
sbt
session, enterproject chapter3_002_elasticty
. - Inside the
sbt
session, enterrun
to bootstrap the application. - Under
Enter commands [q = quit, 2c = 2 customers, etc.]:
enter5c
for 5 customers. - The
rarebook.log
file will be created in the root directory containing the application output. - You should notice a significant increase in throughput for requests being processed!