Backend Development 16 min read

Understanding Tomcat Configuration and Thread Pool Parameters in Spring Boot 2.7.10

This article explains the default Tomcat settings in Spring Boot 2.7.10, details core parameters such as connection queue length, max connections, thread pool sizes, keep-alive and timeout options, and demonstrates how to inspect and test these configurations with code examples and command-line tools.

Top Architect
Top Architect
Top Architect
Understanding Tomcat Configuration and Thread Pool Parameters in Spring Boot 2.7.10

The article provides a detailed guide on the built‑in Tomcat container used by Spring Boot 2.7.10, covering its default configuration, key parameters, internal thread architecture, and practical testing methods.

Overview

In Spring Boot 2.7.10 the embedded Tomcat version is 9.0.73. The default Tomcat settings are:

Connection waiting queue length (accept‑count): 100

Maximum connections (max‑connections): 8192

Minimum spare threads (min‑spare): 10

Maximum threads (max‑threads): 200

Connection timeout (connection‑timeout): 20 s

Core Parameters

Key Tomcat properties can be overridden in application.yml :

server:
  tomcat:
    # Maximum length of the connection queue
    accept-count: 100
    # Maximum number of connections
    max-connections: 8192
    threads:
      # Minimum number of worker threads created at startup
      min-spare: 10
      # Maximum number of worker threads (IO‑intensive workloads usually need 10×CPU cores)
      max: 200
    connection-timeout: 20000
    keep-alive-timeout: 20000
    max-keep-alive-requests: 100

When the number of active connections exceeds maxConnections + acceptCount + 1 , new requests cannot complete the TCP three‑way handshake and will eventually time out.

Important Parameters

AcceptCount : size of the full‑connection queue (similar to the Linux somaxconn value).

MaxConnections : total connections the server will accept.

MinSpareThread / MaxThread : thread pool limits for handling requests.

MaxKeepAliveRequests : number of requests allowed on a persistent connection before the server closes it.

ConnectionTimeout : idle time after which a connection without activity is closed (default 20 s).

KeepAliveTimeout : time to wait for the next request on a keep‑alive connection; falls back to connectionTimeout if not set.

Internal Threads

Acceptor

The Acceptor receives socket connections, configures them via setSocketOptions() , and registers them with the Poller.

public void run() {
    while (!stopCalled) {
        // wait for next request
        socket = endpoint.serverSocketAccept();
        // register socket to Poller
        endpoint.setSocketOptions(socket);
        // add to poller event queue
        poller.register(socketWrapper);
    }
}

Poller

The Poller continuously checks the NIO selector for ready events and dispatches them to the executor thread pool.

public void run() {
    while (true) {
        Iterator
iterator = selector.selectedKeys().iterator();
        while (iterator != null && iterator.hasNext()) {
            SelectionKey sk = iterator.next();
            iterator.remove();
            NioSocketWrapper socketWrapper = (NioSocketWrapper) sk.attachment();
            if (socketWrapper != null) {
                processKey(sk, socketWrapper);
                executor.execute(new SocketProcessor(socketWrapper, SocketEvent.OPEN_READ));
            }
        }
    }
}

TomcatThreadPoolExecutor

Tomcat extends the standard JDK thread pool to improve task accounting and queue handling.

public void createExecutor() {
    internalExecutor = true;
    TaskQueue taskqueue = new TaskQueue();
    TaskThreadFactory tf = new TaskThreadFactory(getName() + "-exec-", daemon, getThreadPriority());
    executor = new ThreadPoolExecutor(getMinSpareThreads(), getMaxThreads(), 60, TimeUnit.SECONDS, taskqueue, tf);
    taskqueue.setParent((ThreadPoolExecutor) executor);
}

Testing the Configuration

Example application.yml for a small test environment:

server:
  port: 8080
  tomcat:
    accept-count: 3
    max-connections: 6
    threads:
      min-spare: 2
      max: 3

Use ss -nltp or ss -nt to view the connection queue and socket states. The article shows screenshots for various concurrent connection scenarios (6, 9, 10, 11, 12 connections) and explains why connections may stay in SYN_RECV or SYN_SENT when the queue is full.

Reference Links

https://www.zhangbj.com/p/1105.html

https://www.eginnovations.com/blog/tomcat-monitoring-metrics/

JavaSpring Bootthread poolTomcatbackend configuration
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.