# Label With High Availability

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

------------------------------------------------------------
In order to illustrate the function of the label, let's take a look at the diagram below. DCs 1 to 3 represent 3 independent data centers, Racks 1 to 6 represent 6 cabinets (racks), TiKV-1 to TiKV-12 represent 12 hosts, and each host has one TiKV instance. Next, let's look at the distribution of the 3 regions, assuming they all have 3 replica by default:

1. The distribution of Region 1 is 1 leader and 1 follower on 2 host TiKV-7 and TiKV-8 in Rack 4 cabinet, and the other follower is in Rack 6 cabinet of DC 3. The risk of this deployment is that if there is a problem with DC 2 or if there is a problem with Rack 4, it will cause Region 1 to become unavailable.

2. The distribution of Region 2 is that 1 leader and 2 followers are in different cabinets, so if there is a problem with any cabinet alone, Region 2 can be used, which is stronger than Region 1. However, if something goes wrong with IDC 1, our Region 2 is no longer available.

3. The distribution of Region 3 is that 1 leader and 2 followers are in different DCs, so that no matter if there is a problem with the DC, rack (rack) or host (TiKV), it will not affect the availability of Region 1.
Comparing the distribution of Region 1, Region 2, and Region 3, we found that different Region distributions have an impact on availability, especially if the metadata of the database is stored in some Regions, such as information schema, then a Region will not be available. This makes the entire database unusable.

However, we know that the original distribution of regions is randomly deployed by PD. PD nodes only guarantee that multiple replica of a Region will not be placed on the same TiKV node, but the concept of DC, rack (rack), and host (host) PD node is unknown.

How do I do that? So there is the concept of label, which is what we often call labeling. We can set a label (label) for each TiKV instance to identify which host (host) in which rack of which DC it is located. The PD node specifies the format of the label, so that when the PD node initially distributes the region, it can perceive the location of the DC, rack, and host according to the label set on the TiKV node, so as to maximize the distribution of high availability.