Dynamic Backend Server Weights
Use dynamic backend server weights to adjust load balancer traffic distribution as backend server capacity changes based on HTTP health-check responses.
Backend server weight defines the proportion of traffic directed to a backend server relative to other servers in the same backend set. A backend server with a greater weight receives a proportionally larger share of new incoming traffic. A backend server with a weight of 3 receives three times the amount of traffic as a backend server with a weight of 1.
Dynamic backend server weights feature lets a load balancer adjust traffic distribution as backend capacity changes, without manual weight updates, thorough the health-checker communication. Backend servers report their weights through HTTP health-check responses. Lower weights indicate less capacity, and higher weights indicate more capacity. Configure each backend server to return the case-sensitive X-Dynamic-Backend-Weight header in its health-check response. The value must be an integer from 0 to 100. A reported weight of 0 drains the backend server.
Dynamic drain mode shouldn't replace static drain mode, which is intended for backend maintenance.
After a successful health check with a valid header, the load balancer uses the reported weight. For example, if the configured static weight is 25 and the server reports 75, the load balancer uses 75.
The load balancer uses the default weight:
- When dynamic backend server weights is first enabled, until a successful health check supplies a valid weight.
- When a successful health-check response has a missing or invalid weight header.
- OCI maintenance and recovery events.
A failed health check marks the backend as unhealthy. The load balancer applies neither the reported weight nor the default weight for that failed check.
Dynamic backend server weights is optional. While enabled, configured static weights aren't used as a fallback, and static weights specified when adding a backend are ignored. When dynamic backend server weights is disabled, the load balancer uses configured static weights, which remain unchanged until you update them.
How Traffic Distribution Changes
Dynamic backend server weights keep the selected load-balancing policy and update the weights that the policy uses:
- Round Robin: The load balancer distributes new backend server selections according to the relative weights. With two available backend servers weighted 75 and 25, the first receives about three times as many selections as the second over time. When their advertised weights change to 25 and 75, the distribution shifts toward the second backend server. This distribution is approximate over many selections. These figures aren't a guaranteed ratio in every small group of requests.
- Least Connections: The load balancer considers both active connection counts and current backend server weights. A higher weight gives a backend server more preference, but its existing connection load also affects selection. Weights of 75 and 25 don't guarantee a three-to-one traffic split.
- IP Hash: The load balancer uses the client's source IP address to select a backend server. Current weights influence how client IP addresses are distributed across backend servers. A weight change can affect which backend server is selected for a client on a later selection. The traffic split also depends on how much traffic each client sends.
TCP Health Checks
Dynamic backend server weights applies only to HTTP health checks. For TCP health checks, the API accepts and stores the settings, but traffic distribution continues to use static backend server weights.
Managing Dynamic Backend Server Weights
You can enable and configure dynamic backend server weights for a load balancer in the following ways:
- When creating a new load balancer.
- When editing a load balancer's backend set health check.
- When adding a new backend set for a load balancer.
To stop using this feature, disable it.
Enabling When Creating a Load Balancer
Enable dynamic weighted load balancing when creating a load balancer.
- Start the load balancer creation workflow as described in Creating a Load Balancer.
- On the Choose Backends page, select the Enable dynamic weighted backends option to enable dynamic backend server weights.
- Enter a value from 1 to 100 in the Default weight box. If you don't specify a value, the default is 1.
Run the oci lb load-balancer create command as described in Creating a Load Balancer. For the
backend-setsparameter values, include theis-dynamic-backend-weight-enabledparameter with the valuetruein the JSON configuration. Include thedefault-weightparameter with a value from 1 to 100. For example:oci lb load-balancer create ... --backend-sets [JSON]The backend set's JSON configuration includes the following dynamic weight settings:
{ ... "is-dynamic-backend-weight-enabled": "true", "default-weight": "<value>" }The placeholder
<value>represents a value from 1 to 100.If you omit the default weight, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.
If you specify the
default-weightparameter, you must also include theis-dynamic-backend-weight-enabledparameter with the valuetruein the same configuration, even if the dynamic backend server weights feature is already enabled.Run the CreateLoadBalancer operation as described in Creating a Load Balancer. For the
backendSetsparameter values, include theisDynamicBackendWeightEnabledparameter with the valuetrue. Include thedefaultWeightparameter with a value from 1 to 100.If you omit the
default-weightparameter, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.If you specify the
defaultWeightparameter, you must also include theisDynamicBackendWeightEnabledparameter with the valuetruein the same configuration, even if the dynamic backend server weights feature is already enabled.
Enabling When Updating the Backend Set's Health Check
You can enable dynamic backend server weights in a backend set by updating its health check.
- Update the backend set's health check as described in Editing a Load Balancer's Health Check Policy.
- Select the Enable dynamic backend weight option to enable dynamic backend server weights.
- Enter a value from 1 to 100 in the Default weight box. If you don't specify a value, the default is 1.
- Select Save changes.
Run the oci lb health-checker update command as described in Editing a Load Balancer's Health Check Policy. Include the
is-dynamic-backend-weight-enabledparameter with the valuetrue. Specify thedefault-weightparameter with a value from 1 to 100. For example:oci lb health-checker update ... --is-dynamic-backend-weight-enabled true --default-weight 3If you omit the
default-weightparameter, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.If you specify the
default-weightparameter, you must also include theis-dynamic-backend-weight-enabledparameter with the valuetruein the same configuration, even if the dynamic backend weights feature is already enabled.Run the
UpdateHealthCheckeroperation as described in Editing a Load Balancer's Health Check Policy. Include theisDynamicBackendWeightEnabledparameter with the valuetrue. Specify thedefaultWeightparameter with a value from 1 to 100.If you omit the
defaultWeightparameter, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.If you specify the
defaultWeightparameter, you must also include theisDynamicBackendWeightEnabledparameter with the valuetruein the same configuration, even if the dynamic backend server weights feature is already enabled.
Enabling When Adding a Backend Set
You can enable dynamic backend server weights when creating a backend set for a load balancer.
- Create a backend set as described in Creating a Backend Set.
- Select the Enable dynamic backend weight option to enable dynamic backend server weights.
- Enter a value from 1 to 100 in the Default weight box. If you don't specify a value, the default is 1.
- Select Create backend set.
Run the oci lb backend-set create command as described in Creating a Backend Set. Include the
is-dynamic-backend-weight-enabledparameter with the valuetrue. Specify thedefault-weightparameter with a value from 1 to 100. For example:oci lb backend-set create ... --is-dynamic-backend-weight-enabled true --default-weight 3If you omit the
default-weightparameter, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.If you specify the
default-weightparameter, you must also include theis-dynamic-backend-weight-enabledparameter with the valuetruein the same configuration, even if the dynamic backend server weights feature is already enabled.Run the CreateBackendSet operation as described in Creating a Backend Set. Include the
parameter with the valueisDynamicBackendWeightEnabledtrue. Specify thedefaultWeightparameter with a value from 1 to 100. If thedefaultWeightparameter is omitted, the default is 1.If you omit the
defaultWeightparameter, the service keeps the previously configured value. If no default weight is configured, the service uses 1 when enabling dynamic weights.If you specify the
defaultWeightparameter, you must also include theisDynamicBackendWeightEnabledparameter with the valuetruein the same configuration, even if the dynamic backend server weights feature is already enabled.
Disabling Dynamic Backend Server Weights
After you enable dynamic backend server weights on a load balancer, the feature remains enabled until you explicitly disable it. When the feature is disabled, the load balancer uses configured static backend server weights.
- Update the backend set's health check as described in Editing a Load Balancer's Health Check Policy.
- Clear the Enable dynamic backend weight option to disable dynamic backend server weights.
- Select Save changes.
Run the oci lb health-checker update command as described in Editing a Load Balancer's Health Check Policy. Include the
is-dynamic-backend-weight-enabledparameter with the valuefalse. For example:oci lb health-checker update ... --is-dynamic-backend-weight-enabled falseRun the
UpdateHealthCheckeroperation as described in Editing a Load Balancer's Health Check Policy. Include theparameter with the valueisDynamicBackendWeightEnabledfalse.