Does Spring create new thread per request in rest controllers? Does Spring create new thread per request in rest controllers? spring spring

Does Spring create new thread per request in rest controllers?


It's blocking in the sense that it blocks one thread: the thread taken out of the pool of threads by the servlet container (Tomcat, Jetty, etc., not Spring) to handle your request. Fortunately, many threads are used concurrently to handle requests, otherwise the performance of any Java web application would be dramatic.

If you have, let's say, 500 concurrent requests all taking 1 minute to complete, and the pool of threads has 300 threads, then 200 requests will be queued, waiting for one of the threads to become available.


Absolutely NO since NIO!!!Spring Web runs in a web container Tomcat or Netty, it is tomcat or Netty's work to create thread, not spring mvc or spring webflux.If you use tomcat in a BIO model, it is definitely new thread per request.Netty is of course NIO, tomcat supports NIO and APR, both are non-blocking,Spring boot webmvc tomcat is default NIO, no need to worry about creating to many threads since nio.

Tomcat 8 NIO,how it works?