# Schedules:Generating Schedules
__*Generate Schedule*__
+ Balance
  + Leader
  + Region
+ Hot region
+ Cluster topology
+ scale in
+ Failure recover
+ Region merge

------------------------------------------------------------
Different schedulers start from their own logic and requirements and consider various restrictions and constraints to generate Operators to be executed. Let's first explain what an Operator is. An Operator is a collection of operations applied to a Region that serves a certain scheduling purpose. For example, "Migrate the Leader of Region 2 to Store 5", "Migrate a replica of Region 2 to Store 1, 4, 5," and so on.
Operators can be computationally generated by PD or created manually by an external API.

Some of the more representative schedules are:

1. Balance
Distribute Regions evenly across all Stores in the cluster. It can be divided into 2 types:
  1. The leader focuses on the leader of the region, which can be thought of as the purpose of dispersing the pressure of processing client request.
  2. Region focuses on each peer in the region, with the aim of spreading the pressure on storage and avoiding disk fullness.

2. Hot region
For write hotspots, hotspot scheduling attempts to disperse the peer and leader of the hotspot region at the same time; for read hotspots, since only the leader carries the read pressure, the hotspot scheduling attempts to disperse the leader of the hotspot region. Please refer to the following sections for details.

3. Cluster topology
The topology that makes PD aware of the distribution of different nodes is to distribute individual replicas in different Region as much as possible through scheduling to ensure high availability and disaster recovery. For example, if a cluster has 3 data centers, the safest way to schedule is to place the 3 peers of the Region in different data centers, so that if any data center fails, it can continue to provide services.

4. scale in
scale in is when a Store is ready to be taken offline, and the Store is marked as Offline with the command. At this time, PD migrates the Region on the node to be offline to another node via a schedule.

5. Failure recover
Failback means that when an existing store fails and cannot be recover, the distribution of peers to Region on the corresponding store will cause a state of missing replica. At this time, PD needs to make up replicas for these Region on other nodes.

6. Region merge
Region merge refers to the process of merging adjacent small Region by scheduling to avoid large amounts of small Region or even empty Region consuming system resources after deleting data.