Running Akka 2.0 application on single thread

229 views
Skip to first unread message

Jussi Virtanen

unread,
May 23, 2012, 8:18:25 AM5/23/12
to Akka User List
Hi,

I have an Akka 2.0 application that I would like to run on a single
thread (for performance reasons). I looked into
CallingThreadDispatcher and tried to set it as the default dispatcher
for the application but run into timeouts in the startup.

Actors in my application do not perform blocking actions, but some of
them do, however, continuously poll external APIs by sending a message
to themselves:

def receive = {
case Poll => {
api.poll()
self ! Poll
}
}

Based on a quick investigation, it appears that this polling mechanism
causes the entire application to enter a busy loop when the first
actor starts using it.

I have a few questions:

Is running an Akka application on a single thread a good strategy for
a latency sensitive application?

Is using CallingThreadDispatcher in production reasonable, given its
limitations?

Assuming that both answers are true, how would I go about solving the
busy loop issue described above?


--
Jussi Virtanen

√iktor Ҡlang

unread,
May 23, 2012, 8:27:31 AM5/23/12
to akka...@googlegroups.com
Hi Jussi,

A good friend of mine, lets call him The Doc once told me:

"Thus, keep in mind that the CallingThreadDispatcher is not a general-purpose replacement for the normal dispatchers. On the other hand it may be quite useful to run your actor network on it for testing, because if it runs without dead-locking chances are very high that it will not dead-lock in production."


It you want to run on one thread only, you're SOL since the Scheduler uses a dedicated thread. BUT you can make the default dispatcher only have 1 thread and not configure any others.

Hope that helps!

Cheers,


--
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/akka-user?hl=en.




--
Viktor Klang

Akka Tech Lead
Typesafe - The software stack for applications that scale

Twitter: @viktorklang

Patrik Nordwall

unread,
May 23, 2012, 11:15:12 AM5/23/12
to akka...@googlegroups.com



23 maj 2012 kl. 14:27 skrev √iktor Ҡlang <viktor...@gmail.com>:

Hi Jussi,

A good friend of mine, lets call him The Doc once told me:

"Thus, keep in mind that the CallingThreadDispatcher is not a general-purpose replacement for the normal dispatchers. On the other hand it may be quite useful to run your actor network on it for testing, because if it runs without dead-locking chances are very high that it will not dead-lock in production."


It you want to run on one thread only, you're SOL since the Scheduler uses a dedicated thread. BUT you can make the default dispatcher only have 1 thread and not configure any others.


I'm not that sure you can start top level actors with default dispatcher configured with one thread. Might have changed since I looked last time.

I would keep default-dispatcher as is by default, but use a separate dispatcher configured with 1 thread for the latency sensitive actors, if you think that helps.

You can also test what difference the dispatcher setting throughput=1 makes for your use case. Also try difference between fork join pool and thread pool executor.

/Patrik

√iktor Ҡlang

unread,
May 23, 2012, 11:42:49 AM5/23/12
to akka...@googlegroups.com

There's much needed ticket to fix in the Performance backlog ;-)

Reply all
Reply to author
Forward
0 new messages