How to Manage the Algorithm of Vultr Load Balancer

Updated on September 25, 2024

Vultr Load Balancer provides two traffic distribution algorithms: Least Connections, which directs traffic to the server with the fewest active connections, and Round Robin, which cycles traffic through servers in a sequential manner. These algorithms help manage how traffic is distributed based on server load or through a balanced approach. By choosing the appropriate algorithm, you can optimize traffic management according to your application’s needs.

Follow this guide to manage the algorithm for your Vultr Load Balancer on your Vultr account using the Vultr Customer Portal, API, or CLI.

  • Vultr Customer Portal
  • Vultr API
  • Vultr CLI
  1. Navigate to Products and click Load Balancer.

    Load Balancer option in products menu

  2. Click your target Load Balancer to open its management page.

    Selection of a target Load Balancer

  3. Click Configuration.

    Button to open Load Balancer configuration window

  4. Click Load Balancer.

    Button to open Load Balancer configuration window

  5. Click Algorithm and select an algorithm.

    Field to select a Load Balancer algorithm

  6. Click Save Changes.

    Button to save Load Balancer algorithm change

  1. Send a GET request to the List Load Balancer endpoint and note the target Load Balancer's ID.

    console
    $ curl "https://api.vultr.com/v2/load-balancers" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  2. Send a PATCH request to the Update Load Balancer endpoint to change the target Load Balancer's algorithm.

    console
    $ curl "https://api.vultr.com/v2/load-balancers/<loadbalancer-id>" \
        -X PATCH \                                   
        -H "Authorization: Bearer ${VULTR_API_KEY}" \
        -H "Content-Type: application/json" \
        --data '{                           
            "balancing_algorithm": "leastconn"
    }'
    
  1. List the available Load Balancers and note the target Load Balancer's ID.

    console
    $ vultr-cli load-balancer list
    
  2. Update the algorithm for the target Load Balancer.

    console
    $ vultr-cli load-balancer update <loadbalancer-id> --balancing-algorithm="leastconn"