I wanted to test parallel requests in my controller. I know that by default Spring can handle 200 parallel requests and we can change it by modifying this property server.tomcat.max-threads
I played a little bit with that value and found interesting thing:
When I set it to 3 when I start app I see 3 threads are being created: http-nio-8080-exec-1,2,3
When I set it to 5 I see 5 threads like that. And it continues up to 10 and stops at 10. When I set it to 15 there are still 10 threads of name http-nio-8080-exec. Could someone explain why it never exceeds 10?
If i will make controller like this
@GetMapping("test")
public String test(@RequestParam("skip") boolean skip) throws InterruptedException {
if(!skip) {
System.out.println("I'm starting waiting");
Thread.sleep(10000);
System.out.println("I stopped waiting");
}
return "dd";
}
while having server.tomcat.max-threads=200
make 10 requests like that: http://localhost:8080/test?skip=false
and 11th request like that at the same time: http://localhost:8080/test?skip=true
These first 10 requests should wait 10 secs before returning response but 11th should return immediately - the problem is that 11th request also waits, so it's blocked. Could someone explain how it works? If I have server.tomcat.max-threads set to 200 then I expect that I will be able to handle 200 independent request, am I right?