# The Process of Writing Data in TiKV

+ Client (TiDB or ti-client)


+ raftstore thread
+ apply thread

+ raft log (RocksDB)
+ data (RocksDB)

+ Replicate to other TiKV instances
+ append log


+ apply to db
+ [raftstore]
+ store-pool-size = 2
+ apply-pool-size = 2
+ scheduler pool 
+ Do a restriction check before writing data, for example, checking whether the ts that is written is greater than that in the existing version. (raw_put skips this step)

+ [storage]
+ scheduler-worker-pool-size
+ Tips: 4 if the tikv cpu is less than 16c, or its defaut value is 8
![`smart`](place-holder.png)

![`smart`](place-holder.png)

![`smart`](place-holder.png)

------------------------------------------------------------
Leader
Replica

