Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is tomcat going to 200+ threads with Spring WebFlux?

I am doing a POC with Spring WebFlux on Tomcat. The stack is totally reactive and using Spring Reactor and Reactive Couchbase.

When I added load on the System, I saw that the number of threads in JVisualVM increased to 200+. Basically, reactor-http threads were limited, about 4 as expected.

But http-nio-exec threads jumped to around 200. If I run with Netty instead of Tomcat the the number of threads is limited about 30 only.

Can some one explain why Tomcat is spinning up so many threads with a Reactive Stack?

like image 913
Vikram Rawat Avatar asked Nov 18 '18 14:11

Vikram Rawat


1 Answers

Because netty has implemented an event loop mechanizm that alows for efficient handoff of incomming connections. Tomcat still uses model one thread per request.

This is a pretty intreting article on the issue:

https://kamilszymanski.github.io/resources-utilization-in-reactive-services/

like image 171
piotr szybicki Avatar answered Nov 15 '22 23:11

piotr szybicki