[Yandex Cloud documentation](../../../index.md) > [Yandex Application Load Balancer](../../index.md) > [Step-by-step guides](../index.md) > L7 load balancers > Availability zone management > Enabling and disabling a zonal shift

# Enabling and disabling a zonal shift


If an [availability zone](../../../overview/concepts/geo-scope.md) is under maintenance or fails, Yandex Cloud technicians may temporarily [disable that zone](allow-and-deny-shift.md).

You can also manually disable one or more availability zones to address the following scenarios:

* Reducing load during localized issues, e.g., after a faulty app release on your backend or an incident caused by high traffic or misconfiguration. Temporarily disabling the affected zone helps prevent service disruption or quickly restore app functionality for your users.

* Testing the resilience of your load balancer and traffic failover mechanisms. This way, you can proactively identify potential weaknesses, apply fixes, and optimize your load balancer settings in advance.

## Enabling a zonal shift {#disable-zones}

{% note warning %}

If you are using a network or an L7 load balancer in combination with an instance group [with autoscaling](../../../compute/concepts/instance-groups/scale.md#auto-scale), before disabling a zone in the load balancer, first, [disable](../../../compute/operations/instance-groups/disable-enable-zone.md#disable) this zone for the instance group. Otherwise, the instance group will continue creating instances in a zone which does not receive traffic.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the folder containing your [L7 load balancer](../../concepts/application-load-balancer.md).
  1. Navigate to **Application Load Balancer**.
  1. Select your L7 load balancer.
  1. On the **Overview** page, under **Allocation**, click **Set up zone locks**.
  1. Enable a zonal shift for one or more zones.
  1. Optionally, to set auto-off time for the zonal shift, activate **Disable block after** and specify a value from `1m` to `72h`. If no time is set, the zonal shift will be on until you disable it manually.

  1. Click **Save**.

    Your load balancer will start shifting traffic away from inactive availability zones to other zones.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. View the command description:

      ```bash
      yc application-load-balancer load-balancer disable-zones --help
      ```

  1. To start redistributing traffic, enable a zonal shift and specify its duration:

      ```bash
      yc application-load-balancer load-balancer disable-zones \
        <load_balancer_name_or_ID> \
        --zones <availability_zones>
        --duration <zonal_shift_duration>
      ```

      Where:

      * `<load_balancer_name_or_ID>`: Load balancer ID or name.
      * `--zones`: Availability zones to shift traffic away from, separated by commas.
      * `--duration`: Zonal shift duration from `1m` to `72h`.
      
         After this time, the zone will automatically recover. If this parameter is not set, the zonal shift will be on until you [disable](#enable-zones) it manually.
  
      Here is an example:

      ```bash
      yc application-load-balancer load-balancer disable-zones \
        my-balancer \
        --zones ru-central1-a \
        --duration 1h
      ```

      Result:

      ```text
      id: ds70q425egoe********
      name: my-balancer
      ...
      allocation_policy:
        locations:
          - zone_id: ru-central1-a
            subnet_id: e2lptlobccu6********
            zonal_shift_active: true
            zonal_traffic_disabled: true
          - zone_id: ru-central1-b
            subnet_id: e9bo5ir5prfi********
      ...
      ```

- API {#api}

  To enable a zonal shift, use the [DisableZones](../../api-ref/LoadBalancer/disableZones.md) REST API method for the [LoadBalancer](../../api-ref/LoadBalancer/index.md) resource or the [LoadBalancerService/DisableZones](../../api-ref/grpc/LoadBalancer/disableZones.md) gRPC API call.

{% endlist %}

## Viewing zonal shift off time {#view-zone-status}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), select the [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder) with your load balancer.
  1. Navigate to **Application Load Balancer** and select the load balancer.
  1. Under **Allocation**, next to the availability zone, view its status.

      If the zonal shift duration has been set, you will see the end time next to the zone.

{% endlist %}

## Disabling a zonal shift {#enable-zones}

{% note warning %}

If you are using a network or an L7 load balancer in combination with an instance group [with autoscaling](../../../compute/concepts/instance-groups/scale.md#auto-scale), before enabling a zone in the load balancer, first, [enable](../../../compute/operations/instance-groups/disable-enable-zone.md#enable) this zone for the instance group to distribute its instances across the zones.

{% endnote %}

{% list tabs group=instructions %}

- Management console {#console}

  1. In the [management console](https://console.yandex.cloud), navigate to the folder containing your [L7 load balancer](../../concepts/application-load-balancer.md).
  1. Navigate to **Application Load Balancer**.
  1. Select your L7 load balancer.
  1. On the **Overview** page, under **Allocation**, click **Set up zone locks**.
  1. Disable the zonal shift.
  1. Click **Save**.

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. View the description of the command for disabling a zonal shift:

      ```bash
      yc application-load-balancer load-balancer enable-zones --help
      ```

  1. Disable a zonal shift:

      ```bash
      yc application-load-balancer load-balancer enable-zones \
        <load_balancer_name_or_ID> \
        --zones <availability_zones>
      ```

      Here is an example:

      ```bash
      yc application-load-balancer load-balancer enable-zones \
        my-balancer \
        --zones ru-central1-a
      ```
      
      Result:

      ```text
      id: ds70q425egoe********
      name: my-balancer
      ...
      allocation_policy:
        locations:
          - zone_id: ru-central1-a
            subnet_id: e9bo5ir5prfi********
          - zone_id: ru-central1-b
            subnet_id: e2lptlobccu6******** 
      ...
      ```

- API {#api}

  To disable a zonal shift, use the [EnableZones](../../api-ref/LoadBalancer/enableZones.md) REST API method for the [LoadBalancer](../../api-ref/LoadBalancer/index.md) resource or the [LoadBalancerService/EnableZones](../../api-ref/grpc/LoadBalancer/enableZones.md) gRPC API call.

{% endlist %}

{% note info %}

Previously, the `start-zonal-shift` and `cancel-zonal-shift` CLI commands and the `StartZonalShift` and `CancelZonalShift` API methods were used to enable and disable zonal shifts. They are now deprecated and will soon be removed.

{% endnote %}

### Useful links {#see-also}

* [Disabling and enabling availability zones for a Yandex Compute Cloud instance group](../../../compute/operations/instance-groups/disable-enable-zone.md)
* [Disabling and enabling availability zones in Yandex Network Load Balancer](../../../network-load-balancer/operations/manage-zone/disable-enable-zone.md)