# Tso Assignment: Process
__*TSO Assignment Process*__

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

------------------------------------------------------------
All the logic of TiDB and PD interaction is carried out through a PD Client thread module, which is specifically responsible for obtaining TSO from PD in batch. The general workflow process is as follows:

1. When the TSO requester (transaction) needs to request a TSO, it first sends the request to the PD Client module. The PD Client module immediately return the TSO requester given by a TSFuture object, corresponding to Figure 1,2.

2. After receiving the TSFuture, the TSO requester caches it and immediately starts parse and compiling the SQL. After parse and compiling, it calls the wait method of TSFuture to wait for the TSO to return, corresponding to Figure 4.

3. At the same time, the PD Client obtains TSO to PD asynchronously via gRPC. Note that this is not a single TSO request, the PD Client will request TSO from PD immediately. When a large number of requests arrive at the PD Client in the same time period (very short), the PD Client will proceed Batch processing, these requests are sent only once as a batch request, but if the PD client receives TSO request for a long time, request are still sent to PD one by one. Corresponding figures: 3 and 5.

4. After the PD client receives the TSO returned by PD, the PD client tries to return the TSO to the corresponding TSO requester. If the TSO requester happens to call the wait method of TSFuture at this time, then the TSO requester gets the TSO, otherwise, until the TSFuture's The wait method starts waiting. Corresponding figure: 6.

In summary, the allocation of the entire TSO is an asynchronous process.