Load Balancing: Configurable Origin Weights

Introduction

Weighted Load Balancing allows you to set a relative weight (from 0.00 - 1.00) for each origin within a pool. These weights will be used to calculate the percentage of traffic to be sent to all available origins within a pool. If an origin becomes unhealthy, traffic will be rebalanced to the remaining available origins according to the remaining weights.

Requirements and limitations

Origin weights are available to all Load Balancing subscription customers. Currently, the Load Balancer must be orange clouded in order to utilize origin weights. Weights will not apply to grey clouded load balancers.

How is traffic flow calculated?

The formula used is: origin weight / sum(all available origin weights) = Target % of traffic to that origin.

Example with three (3) origins:

  • Weights: A=0.25 / B=0.25 / C=0.50
  • With three (3) healthy origins (all) the traffic % to each origin will be: A=25% / B=25% / C=50%
  • With two healthy origins (A+B) and one down origin (C) the traffic % to each origin will be: A=50% / B=50%

You will need some reasonable amount of traffic under the specific health conditions to get distribution to converge to the expected values. Session Affinity (if enabled) will also affect weighting. Established sessions will not be reset with a change in relative weight.

 

How to configure

Web UI

Weights are configured within origin configuration of the UI. The value must be between 0 and 1 be a multiple of .01 (meaning 0.01 is valid. 1.01 is not). Equal values mean equal weights and distribution. A weight of zero means that we will not send traffic to that origin, but we will continue to check and report upon the healthcheck (if configured).

The Manage/Create Load Balancer UI provides a helper Percent calculation for configured origin weights. The calculated percentages assume all origins within the Load Balancer are healthy.

weighted_config.png

API

There is an object in the Pool API under the Origin object: "weight". The value must be between 0 and 1 be a multiple of .01 (meaning 0.01 is valid. 1.01 is not). A weight of zero means that we will not send traffic to that origin, but we will continue to check and report upon the healthcheck (if configured).

If you do not enter weights, all origins will default to a weight of 1 and have even distribution amongst the active origins.

# POST/PUT organizations/:organization_identifier/load_balancers/pools
{
"name": "examplepool",
"description": "Weighted Pool",
"monitor": :monitor_id,
"notification_email": "[email protected]",
"origins": [
{
"name": "server-a",
"address": "0.0.1.0",
"weight": 0.25
},
{
"name": "server-b",
"address": "0.0.2.0",
"weight": 0.25
},
{
"name": "server-c",
"address": "0.0.3.0",
"weight": 0.50
}
]
}
Still not finding what you need?

The Cloudflare team is here to help. 95% of questions can be answered using the search tool, but if you can’t find what you need, submit a support request.

Powered by Zendesk