Akka and Netty

832 views
Skip to first unread message

Christer Sandberg

unread,
Feb 13, 2012, 6:32:42 AM2/13/12
to akka...@googlegroups.com
Hi!

Our system which is exclusively built upon Akka and actors integrate a lot with other systems via sockets and Netty.
Each of the Netty clients have a factory which is used to create a new channel/connection that embeds
org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory which is created with Executors.newCachedThreadPool for
both the boss and worker threads.

Would we benefit by using a one of the executor services provided by Akka instead since we live in an actor system?
It feels a bit ugly that all the Netty client factories creates their own thread pools/executor services, but maybe this is the way to go?

Any thoughts from the experts?

/Christer

√iktor Ҡlang

unread,
Feb 13, 2012, 7:22:49 AM2/13/12
to akka...@googlegroups.com
What version are we talking about?

Cheers,
 

/Christer

--
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

Christer Sandberg

unread,
Feb 13, 2012, 8:19:07 AM2/13/12
to akka...@googlegroups.com
Ah, sorry...

Akka 2.0-M4 and Netty 3.2.7-Final

/Christer

2012/2/13 √iktor Ҡlang <viktor...@gmail.com>

√iktor Ҡlang

unread,
Feb 13, 2012, 8:34:50 AM2/13/12
to akka...@googlegroups.com
Akka 2.0-M4 uses Netty 3.3.0-Final btw

What is reused for both inbound and outbound channels:

  val executor = new OrderedMemoryAwareThreadPoolExecutor(
    settings.ExecutionPoolSize,
    settings.MaxChannelMemorySize,
    settings.MaxTotalMemorySize,
    settings.ExecutionPoolKeepalive.length,
    settings.ExecutionPoolKeepalive.unit,
    system.threadFactory)

The Netty remoting in 2.0-M4 shares the following amongst it's Active outbound connections:

  val clientChannelFactory = new NioClientSocketChannelFactory(
    Executors.newCachedThreadPool(system.threadFactory),
    Executors.newCachedThreadPool(system.threadFactory))

  private val executionHandler = new ExecutionHandler(netty.executor)

And the server:

private val factory = new NioServerSocketChannelFactory(
    Executors.newCachedThreadPool(netty.system.threadFactory),
    Executors.newCachedThreadPool(netty.system.threadFactory))

  private val executionHandler = new ExecutionHandler(netty.executor)


They are all also sharing the same HashedWheelTimer.

So essentially the remoting uses its own threads, which mean that remoting is decoupled, processing-wise, from the actors, which means that serialization etc is handled by other threads.

There's a lot of potential tuning you can make. Are you seeing any problems?

Cheers,

Christer Sandberg

unread,
Feb 13, 2012, 8:55:08 AM2/13/12
to akka...@googlegroups.com
Thanks a lot Viktor!

No, we're not having any problems att all but we have 3 different NioClientSocketChannelFactory instances (since we have 3 different clients) and it they are all created with Executors.newCachedThreadPool. I was just thinking that it might be better to share the thread pools that Akka provides. Note that I'm not talking of Netty in Akka as in remoting. These are home grown Netty client implementations for custom integration.

√iktor Ҡlang

unread,
Feb 13, 2012, 9:02:53 AM2/13/12
to akka...@googlegroups.com
On Mon, Feb 13, 2012 at 2:55 PM, Christer Sandberg <chr...@gmail.com> wrote:
> Thanks a lot Viktor!
>
> No, we're not having any problems att all but we have 3 different
> NioClientSocketChannelFactory instances (since we have 3 different clients)
> and it they are all created with Executors.newCachedThreadPool. I was just
> thinking that it might be better to share the thread pools that Akka
> provides. Note that I'm not talking of Netty in Akka as in remoting. These
> are home grown Netty client implementations for custom integration.

I don't see any really simple way to reuse that. And Akka does some
elaborate things to shutdown threadpools and replace them with lazy
new ones if they aren't used for a while etc.

Cheers,

Christer Sandberg

unread,
Feb 13, 2012, 1:11:30 PM2/13/12
to akka...@googlegroups.com
Okay, thanks very much for the info. I'll just stick to what I got then. Good to know since Akka does everything so magically good so I just had to ask ;)

√iktor Ҡlang

unread,
Feb 13, 2012, 2:11:45 PM2/13/12
to akka...@googlegroups.com

Lol, if it works then it works :-)

Reply all
Reply to author
Forward
0 new messages