Benchmark Akka vs regular Java

I think I found *the* solution for dealing with big data / big computations in Java. That’s called Akka, and I learned about it thanks to a tip from Miguel Biraud.

I had tried several solutions to speed up things but they did not work well:

– multithreading? Yes, but there is a hard limit at the number of threads available on your computer.

– GPGPU computing? Very hard to code, and I was disappointed by the performance of Java libraries supposed to ease the pain, like Ateji.

So, Akka!

That’s a framework for Scala and Java, still evolving very much. It uses the logic of actors to distribute work. Actors can create actors, which promises a nice multiplier effect. Actors can be created by millions!

Anyway, I created a small benchmark to make sure it was easy to code, and that it delivered some speed up even with a quick and dirty test. The results:


double loop through an array of 1,000 integers
operation: product of elements of arrays

nb of actors / operations Akka (in milliseconds) Regular java (in milliseconds)
10 150 150
100 1,200 5,600
1000 11,000 56,0000

conclusion test 1: Akka is faster by a factor of 5.


double loop through an array of 10,000 integers
operation: do some complex regex ops on a random String for each of the 10,000 steps

nb of actors / operations Akka (in milliseconds) Regular java (in milliseconds)
10 348 874
100 2,231 7,600
1000 20,000 75,000

conclusion test 2: Akka is faster by a factor of 3 to 4.

The setup was painless. The code was written by adapting the Hello World example provided on the site. The documentation is not that easy to follow, and as the versions of Akka are evolving quickly it makes it harder to rely on tutorials or StackOverflow Q&A even a few months old. But the logic of operations (actors receiving and sending messages) is quite straightforward.

Note that I did not use the “demultiplier effect” of Akka (Actors launching actors), which could have improved the result. Finally, this was performed on a laptop, whereas the real promise of Akka is on distributed environments (several servers working together). I don’t have a case of use yet for that, but this benchmark suggests that Akka will be very handy for these cases.

The code of the benchmark, and the results in an Excel file:

I am Clement Levallois, and you can find examples of my work here or follow me on Twitter


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s