-
1. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 23, 2014 7:56 AM (in response to manu_1185)moved to correct forum
-
2. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 23, 2014 8:05 AM (in response to ataylor)try setting use-nio-global-worker-pool to true, i think its false by default in the version you are using. It might pay to upgrade to as there are netty fixes in the latest versions
-
3. Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 23, 2014 8:30 AM (in response to ataylor)I am not able to find use-nio-global-worker-pool in the configuration reference for hornetq 2.3.0.Final. Where has this property to be set...in the connector config or in connection factory config?
-
4. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 23, 2014 9:09 AM (in response to ataylor)its on the connector config
-
5. Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 23, 2014 10:44 AM (in response to ataylor)Thanks, it worked. Although I don't understand why any such property is needed. Multiple threads shouldn't be needed for a single connection. A single thread, as in case of blocking IO, should be sufficient.
-
6. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 23, 2014 10:55 AM (in response to manu_1185)its per connection factory not per connection
-
7. Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 23, 2014 1:04 PM (in response to ataylor)I was creating connections from the same connection factory...even then I seeing this issue.
-
8. Re: Hornetq client creates lots of threads per connection when using nio connector
jbertram Apr 23, 2014 1:03 PM (in response to manu_1185)Can you provide an example or test-case demonstrating the issue?
-
9. Re: Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 23, 2014 2:52 PM (in response to jbertram)Attached are my configuration files, my test program and stack trace of client java process. My test program creates 10 connections from same connection factory. Given below are thread stats I grep from stack trace file:
Manus-MacBook-Pro-2:testProject manusrivastava$ grep "New I/O boss" stack.txt -c
10
Manus-MacBook-Pro-2:testProject manusrivastava$ grep "New I/O worker" stack.txt -c
240
Note: I have tested and collected the stack trace on my local mac book where Runtime.getRuntime().availableProcessors() returns 8. So I think client is creating 8*3=24 threads per connection creating a total of 240 threads for 10 connections as seen above.
PS: I am not able to post replies quickly because of some frequency limit error. Can anything be done for that?
-
hornetq-configuration.xml 3.8 KB
-
hornetq-jms.xml 11.0 KB
-
HornetQThreadTest.java 2.2 KB
-
stack.txt.zip 14.9 KB
-
-
10. Re: Re: Re: Hornetq client creates lots of threads per connection when using nio connector
jbertram Apr 23, 2014 6:23 PM (in response to manu_1185)I've tried to reproduce the behavior you're seeing on master, and I can't. I used your configuration and your client code but a thread dump shows just a handful of threads.
Can you try using 2.4.0.Final?
-
threadDump.txt.zip 2.5 KB
-
-
11. Re: Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 24, 2014 12:09 AM (in response to jbertram)I was testing using hornetq 2.3.0.Final when I was getting this issue. Can you test with this version to confirm if this is actually an issue?
I downloaded hornetq 2.4.0.Final to verify your stack trace. Things work fine there. One new behavior I noticed in the new version is that when number of connections is less than 3*number of cores, number of threads is equal to number of connections. And when number of connections exceed 3*number of cores, number of threads are equal to to 3*number of cores (making 3*number of cores an upper limit). This is a good optimization. We will try to upgrade to newer version soon to get rid of these issues.
-
12. Re: Hornetq client creates lots of threads per connection when using nio connector
manu_1185 Apr 24, 2014 6:36 AM (in response to manu_1185)Looks like I found one more issue in latest version (2.4.0.Final). In my earlier test, use-nio-global-worker-pool was true (by default).
I added <param key="use-nio-global-worker-pool" value="false"/> to the connector config to change above setting to false. I was expecting the threads to be pooled on per connection factory basis. But for 50 connections, 50 "nioEventLoopGroup" threads were created (whereas it should have been 3*number of cores worker threads). I used the same test program attached above (with 50 connections instead of 10).
After that I removed <param key="use-nio" value="true"/> from the connector configuration to test with old blocking IO. The stack trace was same....it again had 50 "nioEventLoopGroup". Somehow, pools per connection factory doesn't seem to work properly in when use-nio is true.....though global pools are working fine.
Attached is stack trace file.
-
stack.txt.zip 3.9 KB
-
-
13. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 24, 2014 6:39 AM (in response to manu_1185)I added <param key="use-nio-global-worker-pool" value="false"/> to the connector config to change above setting to false. I was expecting the threads to be pooled on per connection factory basis. But for 50 connections, 50 "nioEventLoopGroup" threads were created (whereas it should have been 3*number of cores worker threads). I used the same test program attached above (with 50 connections instead of 10).
yes i would expect that if use-nio-global-worker-pool is false.
-
14. Re: Hornetq client creates lots of threads per connection when using nio connector
ataylor Apr 24, 2014 6:41 AM (in response to ataylor)just to elaborate if use-nio-global-worker-pool is false the each connection uses its own pool, if true the the connections created by the same factory will share. can you confirm this is what you are seeing with 2.4, if not, can you post your test