# Scheduling: The Processes

![`smart`](SchedulingProcessOverview_aa_002_20220509.png)

------------------------------------------------------------
As a distributed, highly available database storage, we must meet the following requirements:
- Fixed number of replica.
- replica need to be distributed across different nodes.
- After adding a new node, you can migrate a replica to another node.
- In case the node goes offline, the cluster should schedule the data replicas to be migrated to one of the surviving nodes.

In addition, we need to meet the following performance requirements:
- Maintain a uniform distribution of Leaders throughout the cluster.
- Maintain uniform storage capacity of each node.
- Maintain a uniform distribution of hotspots.
- Control the speed of Balance to avoid affecting online services.
- Manage node status, including manual online/offline nodes, and automatically offline the failed nodes.

In order to meet these requirements, we first need to collect enough information, such as the status of each node, information of each Raft Group, statistics of service access operations, etc. Secondly, we need to set up some policies. Based on this information and scheduling strategy, PD will formulate a scheduling plan that meets the requirements described above as much as possible; and finally, some basic operations are needed to complete the scheduling plan.

Since TiKV is not responsible for allocating Region, only PD has a complete perspective, so only PD nodes can complete this task, so the whole process is as follows:
1. Collect the information.
2. Generate the schedule.
3. Execute the schedule.