O'Reilly logo

Applied Akka Patterns by Wade Waldron, Michael Nash

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Performance

Performance tuning an Akka application begins as it would with any application: first you isolate the areas of the application that have the highest cost in terms of time, and then you strive to reduce that cost.

Given that we always have a limited amount of time to apply to tuning, it makes good sense to begin with the greatest cost. Of course, it is difficult to know what this is without measurement. Therefore, as you would with any application, your first step in tuning Akka is generally to measure what takes a long time.

Many excellent performance and latency measurement tools exist for the Java Virtual Machine (JVM), and you can apply any of them to an Akka application. For instance, you can use the Gatling tool to measure the performance of an Akka application with an HTTP interface in the same way as any non-Akka application, and you can apply ScalaMeter to specific code segments.

In addition to the usual statistics on number of requests served, latency, and so on, there are a few special statistics unique to Akka that might be helpful.

Given that a slow consumer in an Akka application can become a serious runtime issue, you might need to measure mailbox size to ensure that any actor (or group of actors) isn’t growing its mailbox beyond reasonable bounds.

The time that it takes each message to be processed by a given actor is also very useful—when used in conjunction with information about the frequency of a message, it can help you narrow down bottlenecks. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required