---
title: "Change the request distribution algorithm"
sidebar_label: "Change the request distribution algorithm"
sidebar_position: 3
description: "How to change the request distribution algorithm in a target group"
---

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'
import EditIcon from '@selectel/docux/icons/edit'
import Formbricks from '@theme/MDXComponents/Formbricks'

# Change the request distribution algorithm

<Tabs queryString="change-distribution-algorithm">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. In the [Control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/), on the top menu, click **Products** and select **Cloud Servers**.
    2. Go to the **Load Balancers** section → **Target Groups** tab.
    3. Open the target group page.
    4. In the **Algorithm** row, click .<EditIcon />
    5. Select an algorithm:

       * Round Robin — a round-robin algorithm. The first request is sent to one server, the next request to another, and so on until the last server is reached. Then, the cycle starts over. Requests are distributed to servers according to the specified weight.
       * Least connections — an algorithm that accounts for the number of connections to servers. A new request is sent to the server with the fewest active connections; the server weight is not taken into account.
    6. Optional: to enable the [Sticky Sessions](/cloud-servers/load-balancers/about-load-balancers.mdx#sticky-sessions) method, in the **Sticky Sessions** row click, select the **Sticky Sessions** checkbox and choose a session identifier. For the APP-cookie session identifier, enter the cookie name.<EditIcon />
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. [Open OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    2. Change the [load balancing algorithm](/cloud-servers/load-balancers/about-load-balancers.mdx#request-distribution-algorithms) for the target group:

       ```bash
       openstack loadbalancer pool set \
         --lb-algorithm <algorithm> \
         <pool>
       ```

       Specify:

       * `<algorithm>` — algorithm name: `ROUND_ROBIN` or `LEAST_CONNECTIONS`
       * `<pool>` — pool ID or name; you can view it using the `openstack loadbalancer pool list`.

    3. Optional: enable the [Sticky Sessions](/cloud-servers/load-balancers/about-load-balancers.mdx#sticky-sessions):

       ```bash
       openstack loadbalancer pool set \
         --session-persistence type=<type>,cookie_name=<name> \
         <pool>
       ```

       Specify:

       * `<type>` — session identifier: `APP_COOKIE`, `HTTP_COOKIE`, `SOURCE_IP`
       * `cookie_name=<name>` — cookie name. Specify if the session identifier `APP_COOKIE` is selected.
       * `<pool>` — pool ID or name; you can view it using the `openstack loadbalancer pool list`.
  </TabItem>
</Tabs>

<Formbricks />
