# An Overview of Recourse Control

+ Two layers of resource management capabilities
  + Flow control capability at the TiDB layer: 
    + Attribute: BURSTABLE
    + Token bucket algorithm
  + Priority scheduling capability at the TiKV layer
    + Attribute: PRIORITY
+ The resource control feature supports controlling TiFlash resources from TiDB v7.4.0
  
![`smart`](2013E142Logic_en_001_20230327.png)

-----------------------------------------------------------------
Two layers of resource management capabilities can be enabled separately or simultaneously. This allows the TiDB layer to control the flow of user read and write requests based on the quotas set for the resource groups, and allows the TiKV layer to schedule the requests based on the priority mapped to the read and write quota. 

TiDB flow control: TiDB flow control uses the token bucket algorithm. If there are not enough tokens in a bucket, and the resource group does not specify the BURSTABLE option, the requests to the resource group will wait for the token bucket to backfill the tokens and retry. The retry might fail due to timeout.

TiKV scheduling: You can set the absolute priority as needed. Different resources are scheduled according to the PRIORITY setting. Tasks with high PRIORITY are scheduled first. If you do not set the absolute priority, TiKV uses the value of RU_PER_SEC of each resource group to determine the priority of the read and write requests for each resource group. Based on the priorities, the storage layer uses the priority queue to schedule and process requests.

