๐ผ๐จ๐จ๐๐จ๐จ๐๐ฃ๐ ๐๐ฅ๐ง๐๐ฃ๐ ๐ฝ๐ค๐ค๐ฉโ๐จ ๐พ๐๐ฅ๐๐๐๐ฉ๐ฎ ๐๐ค๐ง ๐พ๐ค๐ฃ๐๐ช๐ง๐ง๐๐ฃ๐ฉ ๐๐๐ฆ๐ช๐๐จ๐ฉ ๐๐๐ฃ๐๐ก๐๐ฃ๐ โ๏ธ๐
๐๐ฉ๐ซ๐ข๐ง๐ ๐๐จ๐จ๐ญ: ๐๐จ๐ฐ ๐๐๐ง๐ฒ ๐๐๐ช๐ฎ๐๐ฌ๐ญ๐ฌ ๐๐๐ง ๐๐ญ ๐๐๐ง๐๐ฅ๐ ๐๐ญ ๐๐ง๐๐?
Spring Boot has become an essential tool for Java developers, known for simplifying application development with its robust, user-friendly framework. Unsurprisingly, related interview questions about Spring Boot frequently focus on its performance and scalability.
Today, weโll tackle one such question: How many requests can Spring Boot handle simultaneously?
To clarify, the number of simultaneous requests a Spring Boot application can handle isnโt solely determined by Spring Boot itself but by the embedded web server it uses. Since the embedded web server defines this behavior, understanding how each option manages concurrent requests will provide the best answer.
๐ญ.๐๐ ๐ฝ๐น๐ผ๐ฟ๐ถ๐ป๐ด ๐๐ต๐ฒ ๐ง๐ผ๐ฝ ๐ง๐ต๐ฟ๐ฒ๐ฒ ๐ช๐ฒ๐ฏ ๐๐ผ๐ป๐๐ฎ๐ถ๐ป๐ฒ๐ฟ๐
Spring Boot applications can be configured to run with various embedded web servers, each with distinct advantages. The three main choices are Tomcat, Undertow, and Jetty.
๐ญ. ๐ง๐ผ๐บ๐ฐ๐ฎ๐
As the default embedded server for Spring Boot, Tomcat is a widely used open-source Servlet container from the Apache Software Foundation. It fully implements the Java Servlet and JavaServer Pages (JSP) specifications, supporting robust enterprise-level features like SSL, connection pooling, and more. This maturity and stability make it ideal for large, complex applications.
However, Tomcatโs comprehensive feature set makes it somewhat heavier compared to other lightweight servers, which can impact memory usage.
๐ฎ. ๐จ๐ป๐ฑ๐ฒ๐ฟ๐๐ผ๐
Developed by Red Hat, Undertow is known for its high performance, low memory usage, and modular design, making it a strong choice for handling high-concurrency applications with short connections, such as RESTful APIs. Itโs also the default container for the WildFly application server.
Undertow excels in modern web standards, supporting Servlet 3.1, WebSocket, non-blocking I/O (NIO), and HTTP/2. Its lightweight architecture and modularity make it highly suitable for microservices and cloud-native applications.
๐ฏ. ๐๐ฒ๐๐๐
Jetty, an open-source web server maintained by the Eclipse Foundation, is lightweight and designed with embeddability in mind. This makes it ideal for lightweight applications, development phases, and test environments.
With NIO support, Jetty performs well in handling concurrent connections and is frequently used in continuous integration and DevOps contexts due to its flexible, customizable architecture.
๐. ๐๐จ๐ง๐๐ข๐ ๐ฎ๐ซ๐ข๐ง๐ ๐๐๐ฑ๐ข๐ฆ๐ฎ๐ฆ ๐๐จ๐ง๐ง๐๐๐ญ๐ข๐จ๐ง๐ฌ ๐๐ง๐ ๐๐ฎ๐๐ฎ๐ ๐๐๐ฉ๐๐๐ข๐ญ๐ฒ
Get Randika Piyathissaโs stories inย yourย inbox
Join Medium for free to get updates fromย thisย writer.
In Spring Boot, using Tomcat as the default embedded server, the capacity to handle simultaneous requests is set through specific configurations in the spring-configuration-metadata.json file. For example, parameters like maxConnections (the maximum number of concurrent connections) and acceptCount (the maximum number of requests that can wait in the queue when all threads are busy) can be adjusted to manage request handling limits effectively.
To locate Tomcatโs maximum connection setting, open the configuration file and search for server.tomcat.max-connections. This parameter defines the highest number of connections Tomcat will accept simultaneously.
By default, Tomcat is configured to handle up to 8,192 simultaneous connections (8 * 1,024). At first glance, it might seem that this would allow Spring Boot to manage 8,192 requests at once. However, this isnโt entirely accurate.
While Tomcat does permit up to 8,192 connections, it also has a queue capacity for handling requests once the connection limit is reached. This means that the actual number of requests Spring Boot can handle simultaneously is the sum of Tomcatโs maximum connections and its maximum waiting queue size.
To configure this queue capacity, search for the parameter server.tomcat.accept-count in the spring-configuration-metadata.json file, which sets the maximum number of requests that can wait when all connections are in use.
๐. ๐๐๐ง๐๐ฅ๐ข๐ง๐ ๐๐จ๐ง๐๐ฎ๐ซ๐ซ๐๐ง๐ญ ๐๐๐ช๐ฎ๐๐ฌ๐ญ๐ฌ
In summary, the default capacity for handling simultaneous requests in Spring Boot equals Tomcatโs maximum connections (8,192) plus the maximum queue size (100), totaling 8,292 requests.
These values are customizable within Spring Bootโs configuration settings, allowing developers to adjust the maximum connection and queue capacities as needed. Hereโs an example of how to modify these configurations:
๐. ๐๐๐๐ข๐ญ๐ข๐จ๐ง๐๐ฅ ๐๐ข๐ฉ: ๐๐จ๐ง๐๐ข๐ ๐ฎ๐ซ๐ข๐ง๐ ๐ญ๐ก๐ ๐๐๐ ๐๐จ๐ง๐ญ๐๐ข๐ง๐๐ซ
Wondering how to switch the web container to Jetty or Undertow in Spring Boot? Hereโs how you can do it.
๐.๐ ๐๐ฐ๐ข๐ญ๐๐ก๐ข๐ง๐ ๐ญ๐จ ๐๐๐ญ๐ญ๐ฒ
To set Jetty as the web container in Spring Boot, simply update the pom.xml file as shown below:
In other words, simply exclude the default Tomcat and add the Jetty dependency.










