# Tidb Server Architecture

![left](./student-guide/diagram/02-TiDB-Architecture-01-01.png)
------------------------------------------------------------
In the previous lesson, we learned that TiDB Server is the SQL layer, exposing the connection endpoint of the MySQL protocol, responsible for accepting client connections, executing SQL parse and optimization, and finally generating distributed execution plans. TiDB Server itself is stateless. Multiple TiDB Server instances can be started, and a unified access address is provided through load balancing components (such as LVS, HAProxy, or F5). Client connections can be evenly distributed across multiple TiDB Server instances to achieve load balancing effects. The TiDB Server itself does not store data, but only parses the SQL and forwards the actual data read request to the underlying storage node TiKV (or TiFlash).

In this course, we will start with the internal thread pool and cache of TiDB Server and introduce the key functions and hierarchy of TiDB Server. Let's first understand the core thread pool and cache of TiDB Server.

First, let's first understand each thread pool module according to its function. We will introduce the details later:
- Modules Protocol Layer, Parse, Compile, Execute are mainly responsible for parsing and compiling (optimizing) SQL statements. After processing these modules, execution plans for SQL statements are generated.
- The modules Executor and DistSQL are mainly responsible for executing SQL execution plans in batches.
- Modules Transaction and KV are responsible for transaction-related writes.
- Modules PD Client and TiKV Client are responsible for interacting with PD and TiKV. All interaction with TiDB Server is done through them.
- Module schema load, worker and start job collaborate to complete online DDL execution.


Second, there is a cache area in the TiDB Server that caches read result sets, metadata, and login credentials, etc., which we call MemBuffer.
Finally, we will explain the role of thread pool modules and caches mentioned above in this lesson, and their collaboration will be covered in the Execution of SQL Statements course.