Can Spring Boot application handle multiple requests simultaneously?
Yes, Spring boot can handle simultaneously requests! If your servlet container is tomcat under the hood, it can handle 200 simultaneous requests.
Below snippet highlights the point, but refer original spring boot source
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
public class ServerProperties {
public static class Tomcat {
public static class Threads {
private int max = 200; // Maximum amount of worker threads
}
}
}
However, you can override this value by adding server.tomcat.threads.max
to your application.properties
or application.yml
.
Spring will manage a pool of connections and handle the distribution of entity managers (according to the minimum and maximum of connections you specify in your properties). I believe you can read more about it here: When are connections returned to the connection pool with Spring JPA (Hibernate) Entity Manager?
If you are developing web applications with Spring Boot (I mean that you have included the dependency of spring-boot-starter-web
into your pom file), Spring will automatically embed web container (Tomcat by default) and it can handle requests simultaneously just like common web containers.
And you can also change the default web container from Tomcat to Undertow or Jetty by modifying the dependencies.
As @Felipe Mariano said, you can restrict the maximum amount of worker threads for different web container in your configuration file below.
(1) For Tomcat: server.tomcat.max-threads
(2) For Undertow: server.undertow.worker-threads
(3) For Jetty: server.jetty.acceptors