From Request to Response: How Tomcat Processes Your Web Applications
From Request to Response: How Tomcat Processes Your Web Applications
Internals of Apache Tomcat
Are you aware of the request response model that power ups your spring based application ?
Off course, most of us as a developer are using apache tomcat application server to run spring based applications today.
Let’s understand what are the components of Apache tomcat that make a request works and server the purpose with a response.
Youtube Video Link on Apache Tomcat Internals
Components of Apache Tomcat
Server
Represents the entire Catalina servlet container.
Service
Represents combination of one or more connectors that share a single Engine for processing incoming request.
Engine
It receives and process all requests from one or more connectors and returns the response.
One engine per service
HTTP Connector
Listens on TCP port number for connections, and forward request to associated engine
HTTP/1.1
HTTP 2.0
Executor(Thread Pool)
Standard Implementation – (Platform threads to execute tasks)
Virtual Thread Implementation (Java 21)
Since we have a some understanding on components of tomcat application server, now let’s have a look on how a request travels through operating system till the time it makes network calls and get our response back.
How synchronous request reaches to Servlet Container “Catalina” ?
Requests are received on HTTP protocol which is layer-7 protocol.
HTTP Protocols works on TCP Protocol which is layer-4 protocol.
That means client creates a TCP connection with server before sending a http call.
Servlet Container Catalina uses thread pool to assign one thread per request.
Assigned thread executes the business logic and goes through all spring internal classes, calls external service, database and finally prepares the response back.
In case none of the thread is available to serve the request at that moment, request will be queued in a queue maintained by Operating system.
So now let’s consolidate everything together and understand the picture along with all tomcat components.
Also, below is the flow of a request from internal’s servlet classes perspective.
Source - https://tomcat.apache.org/tomcat-9.0-doc/config/server.html
For More Information and manual reading you can visit above mentioned sourced url.
So, now by this time we have reached to a conclusion and understanding how a request gets processed by Apache Tomcat application server.
If you really like my content you can subscribe me below.
Youtube Channel - https://www.youtube.com/channel/UCpF3Y8AxzgYZnI8Zcf_G_fg
You can follow me on linkedin here - https://www.linkedin.com/in/suchait-gaurav-944479109/
Github Repo - https://github.com/suchait007