HAProxy Enterprise Documentation 1.8r2

set weight

Change the weight of a server.

Description

Use set weight to increase or decrease the weight assigned to a server, which affects how much traffic HAProxy Enterprise sends to it.

Examples

In the example below, the backend has two servers, each with an assigned weight of 100:

backend be_servers
   server server1 127.0.0.1:8080 check weight 100
   server server2 127.0.0.1:8081 check weight 100
  1. Use the get weight Runtime API command to display the current weight of a given server.

    $ echo "get weight be_servers/server1" | socat stdio tcp4-connect:127.0.0.1:9999
    100 (initial 100)

    It indicates the initial value that was set in the configuration file and the current value, which may have changed.

  2. Use set weight to change the weight of a server.

    You can pass either an absolute value or a percentage.

    $ echo "set weight be_servers/server1 50%" | socat stdio tcp4-connect:127.0.0.1:9999

    In the snippet above, we changed the server1 server's weight to 50% of its current value.

  3. Call get weight again to see the server's updated weight:

    $ echo "get weight be_servers/server1" | socat stdio tcp4-connect:127.0.0.1:9999
    50 (initial 100)

See also


Next up

Lua