# TiDB Basic Deployment Topology

__*TiDB Topology*__

![left](./student-guide/diagram/TiDBArchitecture_aa_001_20220524.png)
-------------------------------------------------------------

| Instances | Count |
| TiDB | 3 |
| PD | 3 |
| TiKV | 3 |
| Monitoring & Grafana | 1 |


TiDB Server: Responsible for accepting client connections, executing SQL parse and optimization, and finally generating distributed execution plans. The TiDB layer itself is stateless. In practice, multiple TiDB instances can be launched. Through load balancing components (such as LVS, HAProxy, or F5), a unified access address is provided to the outside world, and client connections can be evenly distributed across multiple TiDB instances to achieve load balancing. TiDB Server itself does not store data, but only parses SQL and forwards the actual data read request to the underlying storage node TiKV (or TiFlash).

PD (Placement Driver) Server: metadata management module for the entire TiDB cluster. It stores the real-time data distribution of each TiKV node and the overall topology of the cluster, provides the TiDB Dashboard management interface, and assigns transaction IDs to distributed transaction. PD not only stores metadata, but also issues data scheduling commands to specific TiKV nodes based on the real-time data distribution status reported by the TiKV nodes. In addition, the PD itself is made up of at least 3 nodes and has high availability capabilities. It is recommended to deploy an odd number of PD nodes.

storage nodes
  TiKV Server: Responsible for storing data. From the outside, TiKV is a distributed key-value storage engine that provides transaction. The basic unit for storing data is Region. Each Region is responsible for storing data for a Key Range (the left and right open range from StartKey to EndKey), and each TiKV node is responsible for multiple Region. TiKV's API provides native support for distributed transaction at the KV key-value pair level. By default, the isolation level of SI (Snapshot Isolation) is provided, which is the core of TiDB's support for distributed transactions at the SQL level. After the SQL layer of TiDB completes the SQL parse, the SQL execution plan is converted into an actual call to the TiKV API. So, the data is all stored in TiKV. Additionally, data in TiKV is automatically maintained in multiple replica (three by default), which naturally supports high availability and automatic failover.
  
  TiFlash: TiFlash is a special class of storage nodes. Unlike normal TiKV nodes, data is stored in a columnar format inside TiFlash, and the main function is to accelerate analytical scenario.

