# Scheduling: Generating Schedules

+ Balance
  + Leader
  + Region
+ Hot region
+ Cluster topology
+ Scale-in
+ Failure recover
+ Region merge

------------------------------------------------------------
Different schedulers generate the to-be-executed Operators based on their own logic and requirements, considering various restrictions and constraints. Let us explain what an Operator is first. An Operator is a collection of operations applied to a Region, serving a certain scheduling purpose. For example, "migrate the Leader of Region 2 to Store 5", "migrate the replicas of Region 2 to Store 1, 4, 5", etc.

Operator can be generated by PD through calculation, or it can be manually created by external API.

The representative scheduling methods are as follows:

Balance
- Distribute the Regions evenly across all Stores in the cluster.

Hot regions
- Hot spot scheduling will try to disperse the peers and Leaders of the hot region at the same time for writing hot spots; for reading hot spots, since only the Leader bears the reading pressure, hot spot scheduling will try to disperse the Leader of the hot region. Please refer to the following chapters for details.

Cluster Topology
- Letting PD sense the topology of different nodes is to disperse different Region replicas as much as possible through scheduling, to ensure high availability and disaster tolerance. For example, if the cluster has 3 data centers, the safest scheduling method is to place the 3 Peers of the Region in different data centers, so that any data center can continue to provide services when it fails.

Scale-in
- Scale-in refers to the preparation of taking a Store offline, marking it as Offline status through commands, at which point PD will migrate the Regions on the node to be taken offline to other nodes through scheduling.

Fault recovery
- Fault recovery refers to when a Store has a fault and cannot be recovered, and a Peer distributed on the corresponding Store's Region will have a lack of replicas. At this time, PD needs to supplement replicas for these Regions on other nodes.

Region merge
- Region merge refers to the process of scheduling adjacent small Regions to be merged in order to avoid consuming system resources with a large number of small Regions or even empty Regions after data deletion.
