Databases 4 min read

How a Database Server Starts, Handles, and Completes Client Requests

The article outlines the step‑by‑step lifecycle of a database server—from system initialization and buffer allocation, through connection and thread management, request parsing, optimization, storage‑engine interaction, to final response delivery and cleanup—illustrated with diagrams of each stage.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
How a Database Server Starts, Handles, and Completes Client Requests

Startup

The initialization module reads system parameters and command‑line arguments, sets up the entire system—such as allocating buffers and initializing global variables—and starts each storage engine.

After startup completes, control is handed to the connection management module, which launches a port‑listening service ready to accept client requests.

Startup flow diagram
Startup flow diagram

Receive Request

When the connection management module receives a client request, it communicates according to the interaction protocol and then passes the connection request to the thread management module to obtain a thread.

The thread management module first performs an authorization check; if authorized, it checks the connection thread pool for a cached idle thread. If one exists, it is assigned to the client request; otherwise, a new connection thread is created.

Thread management diagram
Thread management diagram

Process Request

After the client request is paired with a connection thread, request processing begins.

If the client request is a query, it is handed to the query parser, which first determines whether it is a SELECT statement. For SELECTs, the cache query module is invoked; if the result is cached, the data is returned directly to the connection thread and sent to the client. Otherwise, the parser dispatches the request to the appropriate modules.

Uncached SELECTs are passed to the optimizer module; if the request involves table content or structural changes, it goes to the table‑change management module; updates to statistics, checks, repairs, or reorganizations are handled by the table maintenance module; replication‑related requests are sent to the replication module; and status‑collection requests are handled by the status‑report module.

Each module, upon receiving a request, first verifies whether the user has permission for the target table; if so, it checks whether the table is present in the table cache. If not cached, the table is opened and the appropriate lock is acquired.

When the table‑change management module opens a table, it examines the table’s metadata to determine the storage‑engine type and other relevant information, then invokes the corresponding storage‑engine interface for processing.

Table change handling diagram
Table change handling diagram

Complete Request

The connection thread module returns the processing result to the client, performs the necessary cleanup, and then waits for subsequent requests.

Request completion diagram
Request completion diagram
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.

Storage EngineDatabase ArchitectureQuery ProcessingThread ManagementRequest Handling
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

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.