Skip to content
Load Balancing
Visit Load Balancing on GitHub
Set theme to dark (⇧+D)

Weighted load balancing


Use weighted load balancing to send specific percentages of traffic to available origins within a pool. If an origin becomes unhealthy, traffic will be rebalanced to available origins according to their respective weights.

Important notes

When working with origin weights, note the following:

  • The value of each origin weight must be between 0 and 1, and the weight must be expressed in increments of 0.01 (a weight of 0.015 is not valid).

  • The default weight is 1.

  • The percentage of traffic to send to a pool is calculated as follows:

    Percent traffic to send to pool = origin weight for pool ÷ sum of available weights

  • Two pools with the same origin weights will receive the same traffic distribution.

  • If you do not enter weights, all origins will default to a weight of 1, distributing traffic equally among the active origins.

  • When enabled, session affinity can affect traffic distribution, since established sessions are not reset when origin weights are modified.

No traffic is sent to a Load Balancer origin of 0 weight except under the following conditions:

  • The origin is used in multiple pools and has multiple weights assigned. Check the origin in the Cloudflare Traffic App or via the List Pools API to confirm.
  • Health Checks are still sent at the expected interval for a 0-weight origin.
  • Grey-clouded Load Balancers support weights; however, DNS resolvers may cache resolved IPs for clients.

Origin weights example

Here’s an example applying weights to three origin servers:

  • Weights: Origin Server A = 0.25; Origin Server B = 0.25; Origin Server C = 0.50
  • When all origins are healthy, each origin will receive the following proportion of total traffic: A = 25%; B = 25%; C = 50%.
  • When one origin is unhealthy (such as origin C), each healthy origin will receive the following proportion of total traffic: A = 50%; B=50%.

A significant amount of traffic is required for the distribution to converge on the expected values.

Configuring weights from the Load Balancing dashboard

Configure origin weights when you create a load balancer or from the Load Balancing dashboard in the Traffic app.

Configuring weights via the Cloudflare API

To configure the weight of an origin server with the Cloudflare API, include the weight property when using the Update Pools command.

The example below uses the Update Pools command—POST /user/load_balancers/pools—to create a pool named examplepool and set weights for each of three origins.

Request (curl)

curl -X POST "" \     -H "X-Auth-Email:" \     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \     -H "Content-Type: application/json" \--data '{   "description":"Primary data center - Provider XYZ",   "name":"primary-dc-1",   "enabled":true,   "minimum_origins":2,   "monitor":"f1aba936b94213e5b8dca0c0dbf1f9cc",   "origins":[      {        "name": "server-a",        "address": "",        "weight": 0.25       },       {         "name": "server-b",         "address": "",         "weight": 0.25       },       {         "name": "server-c",         "address": "",         "weight": 0.50       }   ]}'


{  "success": true,  "errors": [],  "messages": [],  "result": {    "id": "17b5962d775c646f3f9725cbc7a53df4",    "created_on": "2014-01-01T05:20:00.12345Z",    "modified_on": "2014-01-01T05:20:00.12345Z",    "description": "Primary data center - Provider XYZ",    "name": "primary-dc-1",    "enabled": true,    "minimum_origins": 2,    "monitor": "f1aba936b94213e5b8dca0c0dbf1f9cc",    "check_regions": [      "WEU",      "ENAM"    ], "origins":[      {        "name": "server-a",        "address": "",        "weight": 0.25       },       {         "name": "server-b",         "address": "",         "weight": 0.25       },       {         "name": "server-c",         "address": "",         "weight": 0.50       }   ]}