Quickstart·续
To fetch the latest health status of all pools, use the List Pools command, paying attention to the healthy value for pools and origins (endpoints).
For troubleshooting a specific pool's health, use the Pool Health Details command.
Unexpected health status
If you notice that healthy pools are being marked unhealthy:
- Review how endpoints and pools become unhealthy.
- Refer to the Troubleshooting section.
Create a load balancer on a test subdomain
Instead of starting on your production domain, you likely should create a load balancer on a test or staging domain. This may involve temporary changes to your monitors and pools, depending on your infrastructure setup.
Starting with a test domain allows you to verify everything is working correctly before routing production traffic.
To create a Public or a Private load balancer in the dashboard:
Create a Public load balancer
- Go to Load Balancing and select Create load balancer.
- On the Load Balancer Setup, select Public load balancer
- Choose the website to which you want to add this load balancer.
- On the Hostname page:
- Enter a Hostname, which is the DNS name at which the load balancer is available. For more details on record priority, refer to DNS records for load balancing.
- From the Data Localization dropdown, select the region you would like to use on your domain.
- Toggle the orange cloud icon to update the proxy mode, which affects how traffic is routed and which IP addresses are advertised.
- Add a description for your load balancer.
- If you want session-based load balancing, toggle the Session Affinity switch.
- If you want Adaptive Routing, toggle the Adaptive Routing switch.
- Select Next.
- On the Add a Pool page:
- Select one or more existing pools or create a new pool.
- If you are going to set traffic steering to Off, re-order the pools in your load balancer to adjust the fallback order.
- If needed, update the Fallback Pool.
- If you choose to set traffic steering to Random, you can set Weights (via the API) to your pools to determine the percentage of traffic sent to each pool.
- Select Next.
- On the Monitors page:
- Review the monitors attached to your pools.
- If needed, you can attach an existing monitor or create a new monitor.
- Select Next.
- On the Traffic Steering page, choose an option for Traffic steering and select Next.
- On the Custom Rules page, select an existing rule or create a new rule.
- Select Next.
- On the Review page:
- Review your configuration and make any changes.
- Choose whether to Save as Draft or Save and Deploy.
Create a Private load balancer
- Go to Load Balancing and select Create load balancer.
- On the Load Balancer Setup, select Private load balancer
- Associate your load balancer with either a Cloudflare private IP or a specified IP address and create a description for your load balancer.
- On the Add a Pool page:
- Select one or more existing pools or create a new pool.
- If you are going to set traffic steering to Off, re-order the pools in your load balancer to adjust the fallback order.
- If needed, update the Fallback Pool.
- If you choose to set traffic steering to Random, you can set Weights (via the API) to your pools to determine the percentage of traffic sent to each pool.
- Select Next.
- On the Monitors page:
- Review the monitors attached to your pools.
- If needed, you can attach an existing monitor or create a new monitor.
- Select Next.
- On the Traffic Steering page, choose an option for Traffic steering and select Next.
- Select Next.
- On the Review page:
- Review your configuration and make any changes.
- Choose whether to Save as Draft or Save and Deploy.
For a full list of properties, refer to Create Load Balancer. If you need help with API authentication, refer to Cloudflare API documentation.
Note
Since load balancers only exist on a zone — and not an account — you may need to get the zone id with the List Zones command.
<details>
<summary>
Required API token permissions
</summary>
At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:
- <code>Load Balancers Write</code>
</details>
Create Load Balancerbash
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/load_balancers" \
--request POST \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"description": "Load Balancer for lb.example.com",
"name": "lb.example.com",
"enabled": true,
"ttl": 30,
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
"default_pools": [
"17b5962d775c646f3f9725cbc7a53df4",
"9290f38c5d07c2e2f4df57b1f61d4196",
"00920f38ce07c2e2f4df50b1f61d4194"
],
"proxied": true,
"steering_policy": "random_steering",
"session_affinity": "cookie",
"session_affinity_attributes": {
"samesite": "Auto",
"secure": "Auto",
"drain_duration": 100,
"zero_downtime_failover": "sticky"
},
"session_affinity_ttl": 5000,
"adaptive_routing": {
"failover_across_pools": true
},
"location_strategy": {
"prefer_ecs": "always",
"mode": "resolver_ip"
},
"random_steering": {
"pool_weights": {
"de90f38ced07c2e2f4df50b1f61d4194": 0.3,
"9290f38c5d07c2e2f4df57b1f61d4196": 0.5
},
"default_weight": 0.2
}
}'
The response contains the complete definition of the new load balancer.
Responsejson
{
"success": true,
"errors": [],
"messages": [],
"result": {
"id": "699d98642c564d2e855e9661899b7252",
"created_on": "2021-01-01T05:20:00.12345Z",
"modified_on": "2021-01-01T05:20:00.12345Z",
"description": "Load Balancer for lb.example.com",
"name": "lb.example.com",
"enabled": true,
"ttl": 30,
"fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
"default_pools": [
"17b5962d775c646f3f9725cbc7a53df4",
"9290f38c5d07c2e2f4df57b1f61d4196",
"00920f38ce07c2e2f4df50b1f61d4194"
],
"proxied": true,
"steering_policy": "random_steering",
"session_affinity": "cookie",
"session_affinity_attributes": {
"samesite": "Auto",
"secure": "Auto",
"drain_duration": 100,
"zero_downtime_failover": "sticky"
},
"session_affinity_ttl": 5000,
"random_steering": {
"pool_weights": {
"de90f38ced07c2e2f4df50b1f61d4194": 0.3,
"9290f38c5d07c2e2f4df57b1f61d4196": 0.5
},
"default_weight": 0.2
}
}
}
Optional - Review load balancing analytics
As you send sample requests to your test domain, review the load balancing analytics page to make sure your load balancer is distributing requests like you were expecting.
Route production traffic
Now that you have set up your load balancer and verified everything is working correctly, you can put the load balancer on a live domain or subdomain:
- If you update your pools and monitors, review the pool health again to make sure everything is working as expected.
- Confirm that your production hostname has the correct priority order of DNS records and is covered by an SSL/TLS certificate.
- Configure your load balancer to receive production traffic, which could involve either:
- Editing the Hostname of your existing load balancer.
- Updating the
CNAMErecord sending traffic to your load balancer.
Note
If you have an Enterprise account, also evaluate your application for any excluded paths. For example, you might not want the load balancer to distribute requests directed at your /admin path. For any exceptions, set up an origin rule.
Optional - Next steps
Your load balancer should be receiving production traffic (and you can confirm this by reviewing the analytics).
Though your product is officially set up, you may want to consider the following suggestions.
Usage-based notifications
Since this is a service with usage-based billing, Cloudflare recommends that you set up usage-based billing notifications to avoid unexpected bills.
To set up those notifications:
- In the Cloudflare dashboard, go to the Notifications page. Go to Notifications ↗
- On Alert Type of Usage Based Billing, click Select.
- Fill out the following information:
- Name
- Product
- Notification limit (exact metric will vary based on product)
- Notification email
Note
All plans can send alerts through webhooks. Business and higher plans can also use PagerDuty. 4. Select Save.
Additional configuration options
You may want to further customize how your load balancer routes traffic or integrate your load balancer with other Cloudflare products:
- Cloudflare Tunnel (published applications)
- Spectrum
- Perform planned maintenance
- Load shedding
- DNS persistence
- Load Balancing with the China Network
- Override HTTP Host headers
- CNAME flattening for endpoints
- Custom load balancing rules
- Integrate with PagerDuty
- Additional DNS records
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/load-balancing/get-started/quickstart/#page","headline":"Quickstart","description":"Create a load balancer with pools and monitors in a few steps.","url":"https://developers.cloudflare.com/load-balancing/get-started/quickstart/","inLanguage":"en","image":"https://developers.cloudflare.com/load-balancing/get-started/quickstart/og.png?v=ccd74bffedbc3498","dateModified":"2026-04-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
description: Route traffic based on origin health and latency. title: Adaptive routing image: https://developers.cloudflare.com/load-balancing/understand-basics/adaptive-routing/og.png?v=1c2dae2fc6226c72
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/load-balancing/llms.txt
Use this file to discover all available pages before exploring further.
Docs