Akka for sub-millisecond latency applications

1,490 views
Skip to first unread message

Alistair George

unread,
Nov 6, 2013, 10:37:05 AM11/6/13
to akka...@googlegroups.com
Is there much experience using Akka and Scala for apps where the target latency is of order tens of microseconds rather than milliseconds. The kind of apps I'm thinking about can be done (with some difficulty) in Java - but you do have to accept that the target latency will be missed during GC pauses, and code and tune so that these are not too big and not too frequent.

I've found http://stackoverflow.com/questions/9951501/high-frequency-trading-in-the-jvm-with-scala-akka. One of the answers shows that the message-passing latency can be tuned to below one microsecond in test conditions, which is good enough. Given that I guess my biggest concern is whether it's possible to use Akka/Scala in a way that keeps the GC within bounds (but should I be worrying about other things?).

It's a very general question, I know, but I'd be very interested to hear of projects that have tried it and succeeded straightforwardly/succeeded with a lot of effort/given up and rewritten it in C :).

Thanks

Alistair

Akka Team

unread,
Nov 11, 2013, 7:19:08 AM11/11/13
to akka...@googlegroups.com
Hi Alistair,

you raise an interesting question, but I guess that those who can answer it do not see much value in doing so. If you want to get help evaluating Akka for your use-case don’t be afraid to shoot a mail to in...@typesafe.com.

Regards,

Roland
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.


--
Akka Team
Typesafe - The software stack for applications that scale
Blog: letitcrash.com
Twitter: @akkateam

Alistair George

unread,
Nov 11, 2013, 9:53:33 AM11/11/13
to akka...@googlegroups.com
Hi Roland,

Thanks for the reply. It's clear there's plenty of interest in the question, even if nobody's wanting to share their experience at this stage. Perhaps we'll see more in the coming months.

Cheers

Alistair


On Monday, November 11, 2013 12:19:08 PM UTC, Akka Team wrote:
Hi Alistair,

you raise an interesting question, but I guess that those who can answer it do not see much value in doing so. If you want to get help evaluating Akka for your use-case don’t be afraid to shoot a mail to in...@typesafe.com.

Regards,

Roland

On Wednesday, November 6, 2013, Alistair George wrote:
Is there much experience using Akka and Scala for apps where the target latency is of order tens of microseconds rather than milliseconds. The kind of apps I'm thinking about can be done (with some difficulty) in Java - but you do have to accept that the target latency will be missed during GC pauses, and code and tune so that these are not too big and not too frequent.

I've found http://stackoverflow.com/questions/9951501/high-frequency-trading-in-the-jvm-with-scala-akka. One of the answers shows that the message-passing latency can be tuned to below one microsecond in test conditions, which is good enough. Given that I guess my biggest concern is whether it's possible to use Akka/Scala in a way that keeps the GC within bounds (but should I be worrying about other things?).

It's a very general question, I know, but I'd be very interested to hear of projects that have tried it and succeeded straightforwardly/succeeded with a lot of effort/given up and rewritten it in C :).

Thanks

Alistair

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscribe@googlegroups.com.

To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

Akka Team

unread,
Nov 11, 2013, 10:22:58 AM11/11/13
to akka...@googlegroups.com
Hi Alistair,

that sounds very promising—perhaps. ;-)

Regards,

Roland
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.

To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.

√iktor Ҡlang

unread,
Nov 11, 2013, 10:48:38 AM11/11/13
to Akka User List
Hi Alistair,

In general companies who do HFT are quite unwilling (for obvious reasons) to discuss their technology stack, at least in my experience, which might explain the lack of feedback in this thread :)

Cheers,



To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.

To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.



--
Cheers,

Viktor Klang

Director of Engineering

Twitter: @viktorklang

Rajiv Kurian

unread,
Nov 11, 2013, 10:49:12 AM11/11/13
to akka...@googlegroups.com
My biased experience has been that writing code that achieves microsecond latency in Akka for simple systems hasn't been tough. The typical tuning phase obviously applies - judicious use of FJ pool, dedicated threads for certain actors, using the new MPSC queue where possible etc.

The typical Akka application is written with immutable case classes for communication and persistent collections for internal state. So for big systems, this style might add to GC pressure. Of course techniques like object pooling (which implies mutable objects) apply but it's not the standard Akka style, as you are exposed to a lot of concurrency gotchas that Akka tries to prevent. So even though it's relatively easy to write a low latency app, GC pauses might kill SLAs. This is not an Akka problem as much as a GC problem in my opinion.

I have never re-written an Akka system in C/C++ because my latency targets for Akka systems where never that aggressive. Projects where I used C++ had very strict performance requirements and or dealt with big data. I find using off heap Java features a pain, compared to C++. Controlling java object layout is also pure black magic. If you still want HFT like performance in Java/Scala the disruptor might be worth a look. The programming interface is not as easy as Akka's and you have to deal with bounded queues and explicit thread management (one thread per consumer/producer). The performance is as good as it gets IMHO though.

√iktor Ҡlang

unread,
Nov 11, 2013, 10:50:57 AM11/11/13
to Akka User List
I agree with Rajiv, one should always pick the best solution after trying several (in this case Disruptor), otherwise one might end up with the worst possible solution :)


--
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: http://akka.io/faq/
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages