简体   繁体   中英

if there are 5 users calling the api at the same time or parallel then spring boot will create 5 threads for each user - spring boot

here I want to ask about the concept of threads in spring boot. what I've read, if there are 5 api calls by 5 users simultaneously then spring boot will also automatically create 5 threads to respond to those 5 calls. or it will respond to the api call only with the main thread because we don't set spring boot using async thread. is it really like that? Thank you

Yes, that's the classic approach how requests are handled.

For example, when using the embedded Tomcat, you can define the maximum amount of threads to handle client requests: https://stackoverflow.com/a/25401832/2310221

That said, there are approaches that work differently, for example reactive programming with Spring Reactor :

Project Reactor is a fully non-blocking foundation with back-pressure support included

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM