How to Understand the "Stateless" Nature of TiDB Server?

This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb server是无状态的,这个“无状态”如何理解?

| username: yytest

The TiDB layer itself is stateless. In practice, multiple TiDB instances can be started, and a unified access address can be provided externally through load balancing components (such as LVS, HAProxy, or F5). Client connections can be evenly distributed across multiple TiDB instances to achieve load balancing.
I have always been confused about what “stateless” means. Could the experts please explain what “state” refers to here?

| username: DBAER | Original post link

Stateless means not storing data and having no role differentiation between nodes, such as master-slave or leader-follower.

| username: forever | Original post link

Not storing data, just like an application, I can start one process or multiple processes without affecting each other.

| username: xfworld | Original post link

You can add N nodes, and then, when the load can be sufficiently handled, you can remove N nodes. From this perspective, it will be relatively easier…

The entire process has no impact on service handling.

| username: TiDBer_QYr0vohO | Original post link

Does not store data and does not maintain any information about the client state when processing requests. Each request is independent, and the service does not rely on the state of previous requests or session information.

| username: TiDBer_小阿飞 | Original post link

Stateless means not storing specific data, so if a node goes down, it does not affect the entire cluster’s usage.
The computing resources that storage and SQL rely on are different. Storage depends on IO, while computation requires higher CPU and memory.
In TiDB, the SQL layer is stateless.
Specifically, you need to understand what “stateful” and “stateless” mean.

Stateless Service
Each client request must contain self-descriptive information to identify the client’s identity. The server does not save any information about the client requester.

Benefits of Statelessness?

  • Client requests do not depend on server information, and multiple requests do not need to access the same server.
  • The server cluster and state are transparent to the client, allowing the server to migrate and scale freely, reducing server storage pressure.

What is Stateful?
Stateful services require the server to record client information for each session to identify the client’s identity and process requests based on the user’s identity. A typical design is the session in Tomcat.
For example, login: After a user logs in, we save the login information in the server session and give the user a cookie value to record the corresponding session. Then, in the next request, the user carries the cookie value, allowing us to identify the corresponding session and find the user’s information.
For more understanding of state, please refer to 分布式系统中的“无状态”和“有状态”详解-腾讯云开发者社区-腾讯云

| username: yiduoyunQ | Original post link

Compared to PD having a leader and TiKV store having a region leader, TiDB has a GC owner, etc., the statefulness is not strong.

| username: zhaokede | Original post link

Stateless transitions, no distinction between master and slave.

| username: tony5413 | Original post link

Stateless means no data is stored. Even if all TiDB servers are lost, TiDB will not lose data.

| username: Kamner | Original post link

Stateless means you can respawn in place without losing equipment.
Stateful means you might lose equipment (data loss).

| username: 小于同学 | Original post link

Does not store data.

| username: zhanggame1 | Original post link

Stateless means that even if this node’s TiDB server along with the machine is gone, no data will be lost.

| username: TiDBer_H5NdJb5Q | Original post link

My understanding is that it doesn’t store data, so even if the machine goes down, no data will be lost. However, the query service will still be affected.

| username: 柴米油酱 | Original post link

Freely power on/off and add/delete nodes without affecting normal service.

| username: WinterLiu | Original post link

Simply put, it does not store any data other than the cluster parameters of the TiDB Server itself.

| username: 友利奈绪 | Original post link

Service downtime does not affect data storage.

| username: jiayou64 | Original post link

Stateless means that there is no data involved, and execution occurs in the server’s memory without affecting the database operation.

| username: Kongdom | Original post link

Refer to the official documentation, there are two explanations:

  1. TiDB instances themselves are stateless, and instances cannot perceive each other’s existence, so they cannot confirm whether their writes conflict with those of other TiDB instances.
  2. TiDB nodes are all stateless, and the nodes themselves do not store data. The nodes are completely equal to each other.
| username: TiDBer_q2eTrp5h | Original post link

Stateless means there is no data to be saved and no data to be persisted.

| username: 扬仔_tidb | Original post link

I understand TiDB server as nginx.