Master Tomcat’s Core Architecture: From Server to Connector and Container

This article breaks down Tomcat’s modular architecture, explaining the roles and interactions of Server, Service, Connector, and Container components, and illustrates how requests flow through the system using detailed diagrams and a step‑by‑step analysis of the underlying pipelines.

Java Backend Technology
Java Backend Technology
Java Backend Technology
Master Tomcat’s Core Architecture: From Server to Connector and Container

1. Tomcat Top-Level Architecture

Tomcat’s top‑level container is the Server , which can contain one or more Service instances. Each Service consists of a Connector and a Container . The Connector handles socket communication and request/response conversion, while the Container manages servlets and processes requests.

A Server may contain multiple Services; each Service has a single Container but can have multiple Connectors to support different protocols (e.g., HTTP and HTTPS).

The Server’s lifecycle controls the entire Tomcat instance, as defined in server.xml (Tomcat 8.0).

2. Tomcat Top-Level Architecture Summary

(1) One Server can host multiple Services; each Service has one Container and one or more Connectors. (2) The Server governs Tomcat’s lifecycle. (3) Services expose functionality to clients. (4) Connectors accept requests and wrap them into Request/Response objects. (5) Containers encapsulate and manage servlets, handling the actual request processing.

3. The Subtle Relationship between Connector and Container

When a request arrives, it passes through the Service to the Connector, which creates Request and Response objects, then forwards them to the Container for processing. After the Container finishes, the result returns to the Connector, which sends the response back to the client via a socket.

4. Connector Architecture Analysis

The Connector uses a ProtocolHandler to manage different connection types (e.g., Http11Protocol for plain sockets, Http11NioProtocol for NIO sockets). A ProtocolHandler comprises three parts: Endpoint (handles low‑level socket connections), Processor (converts sockets into Request objects), and Adapter (passes the Request to the Container).

5. Container Architecture Analysis

The Container manages servlets and consists of four sub‑containers:

Engine – manages multiple sites; a Service can have only one Engine.

Host – represents a virtual host (site).

Context – corresponds to a web application (WEB‑INF and web.xml).

Wrapper – wraps an individual servlet.

6. How Container Processes Requests

Container processing uses a Pipeline‑Value chain, a variant of the Chain of Responsibility pattern. Each Pipeline has a final, non‑removable BaseValue . The four sub‑containers each have their own BaseValue (StandardEngineValue, StandardHostValue, StandardContextValue, StandardWrapperValue).

When a request reaches the Connector, it invokes the top‑level EnginePipeline, which sequentially executes EngineValues, then calls the Host pipeline, followed by the Context and Wrapper pipelines. The Wrapper creates a FilterChain that runs configured Filters and the target Servlet’s service method. After all Pipeline‑Values finish, the result is handed back to the Connector, which returns it to the client via the socket.

Summary

Understanding Tomcat’s layered architecture—from Server, Service, Connector, and Container to the internal pipelines—provides a clear mental model that helps developers explain Tomcat’s inner workings confidently in interviews and troubleshoot production issues effectively.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaarchitectureConnectorContainerServer
Java Backend Technology
Written by

Java Backend Technology

Focus on Java-related technologies: SSM, Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading. Occasionally cover DevOps tools like Jenkins, Nexus, Docker, and ELK. Also share technical insights from time to time, committed to Java full-stack development!

0 followers
Reader feedback

How this landed with the community

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.