How many boss threads and worker threads in 4.0.17 version ?

4,335 views
Skip to first unread message

devid....@gmail.com

unread,
Mar 24, 2014, 8:47:44 AM3/24/14
to ne...@googlegroups.com
We are already using 3.6.6 netty in our application. Now we want to move to 4.0.17 version of netty.

I just want to know how many boss threads and worker threads are being used in 4.0.17 version. I have observed that 1 boss thread, 8 worker threads(depending on my CPU available registers). I appreciate one thing in 4.0.17 version, it is initiating worker threads on demand. Whereas, in 3.6.6 version, all worker threads are initiated at a time.

But, when my clients are disconnected, why still worker threads are in running state ? Is it not possible to send to them 'dead' state. Again, on demand we can bring them back to running state, can't we ? This is because, already in some applications most of user threads in running state.


Regards,
Devid.

Jakob Buchgraber

unread,
Mar 25, 2014, 10:15:42 AM3/25/14
to ne...@googlegroups.com, devid....@gmail.com
Hi Devid,

by default Netty creates twice as many threads as there are processors/cores. You can change that in the NioEventLoopGroup constructor (https://github.com/netty/netty/blob/4.0/transport/src/main/java/io/netty/channel/nio/NioEventLoopGroup.java#L43) or by specifying the io.netty.eventLoopThreads option.

As far as I know there is currently no way to shutdown some threads if they are idle.

Best,
Jakob

이희승 (Trustin Lee)

unread,
Mar 26, 2014, 11:08:26 PM3/26/14
to Trustin Lee
Currently, once a Netty event loop thread starts, it doesn't terminate itself until it is told to do so explicitly, and once stopped, you have to create a new event loop.  It is only started lazily.  This might change eventually, but probably not in 4.x.




--

---
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

devid....@gmail.com

unread,
Mar 27, 2014, 2:19:32 AM3/27/14
to ne...@googlegroups.com
Thanks Lee,

That would be great if changed in future releases at least. This will obviously save my heap a bit, though the running threads are very less for EventLoopGroup/ EvenLoop. 

And I have another question for you !

During Bootstrapping of web socket server on a particular port, I see the following line

f.channel().closeFuture().sync();

Reason of writing the above line, the application will wait until the server 's channel closes. 

We are starting up the web socket server during the starting of JBoss server from a RulesEngine. The code after these lines is not executed and in return we are unable to start up remaining process. 

How do I have to come out of this blocking mode  ?


-Devid.

devid....@gmail.com

unread,
Mar 27, 2014, 2:30:02 AM3/27/14
to ne...@googlegroups.com
Why my message has been deleted when I posted a reply for your explanation ? Who does this ?


On Thursday, March 27, 2014 8:38:26 AM UTC+5:30, Trustin Lee wrote:

mbat...@gmail.com

unread,
Jul 23, 2014, 7:24:49 AM7/23/14
to ne...@googlegroups.com, devid....@gmail.com
Concerning number of boss threads, as I see from my experiments netty 4 also uses only 1 thread per bound socket: I ran stress tests with ~200rps and had boss thread pool w/ 2 threads, but there was always 1 boss thread running as I was checking in thread dumps.

понедельник, 24 марта 2014 г., 16:47:44 UTC+4 пользователь devid....@gmail.com написал:

이희승 (Trustin Lee)

unread,
Jul 23, 2014, 7:08:09 PM7/23/14
to Netty Discussions
It's a mystery. I, a moderator, didn't do anything! :-)

이희승 (Trustin Lee)

unread,
Jul 23, 2014, 7:11:17 PM7/23/14
to Netty Discussions
You are correct. 'f.channel().closeFuture().sync()' will wait until the server socket is closed.  It is a useful idiom when you want to terminate your process when the server socket is closed.  For example, you could close the server socket on a certain administrative command.

However, because your application is running in a container environment, you don't really need that line.  You can just remove it, and move the lines that shut down the event loops to somewhere else, such as some life cycle listener of the container.

이희승 (Trustin Lee)

unread,
Jul 23, 2014, 7:14:49 PM7/23/14
to Netty Discussions
When you create an event loop group for boss threads, you'd better specify a non-default thread count when you construct it.  For example, our examples specify '1' for boss event loop groups.

Because an event loop group usually creates a thread in a lazy fashion, you will not have a problem as long as you create only a small number of server channels.  However, if you reuse the event loop group and keep creating server channels (e.g. restarting the server on a new port), you will eventually get unnecessarily many event loop threads.


--

---
You received this message because you are subscribed to the Google Groups "Netty discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netty+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages