Load balancers
A load balancer distributes traffic among pools according to pool health and traffic steering policies. Each load balancer is identified by its DNS hostname (lb.example.com
, dev.example.com
, etc.).
For suggestions, refer to Common load balancer configurations.
For details about DNS records, refer to DNS records for load balancing.
Cloudflare maintains keep-alive connections to improve performance and reduce cost of recurring TCP connects in the request transaction as Cloudflare proxies customer traffic from its edge network to the site's origin.
Ensure HTTP Keep-Alive connections are enabled on your origin. Cloudflare reuses open TCP connections for up to 15 minutes (900 seconds) after the last HTTP request. Origin web servers close TCP connections if too many are open. HTTP Keep-Alive helps avoid premature reset of connections for requests proxied by Cloudflare.
When using HTTP cookies to track and bind user sessions to a specific server, configure Session Affinity to parse HTTP requests by cookie header. Doing so directs each request to the correct application server even when HTTP requests share the same TCP connection due to keep-alive.
For example, F5 BIG-IP load balancers set a session cookie at the beginning of a TCP connection (if none exists) and then ignore all cookies from subsequent HTTP requests on the same TCP connection. This tends to break session affinity because Cloudflare sends multiple HTTP sessions on the same TCP connection. Configuring the load balancer to parse HTTP requests by cookie headers avoids this issue.
For step-by-step guidance, refer to Create a load balancer.
For an up-to-date list of load balancer properties, refer to Load balancer properties in the Cloudflare API documentation.
The Cloudflare API supports the following commands for load balancers.
Command | Method | Endpoint |
---|---|---|
Create Load Balancer | POST | /zones/:zone_id/load_balancers |
Delete Load Balancer | DELETE | /zones/:zone_id/load_balancers/:id |
List Load Balancers | GET | /zones/:zone_id/load_balancers |
Load Balancer Details | GET | /zones/:zone_id/load_balancers/:id |
Overwrite specific properties | PATCH | /zones/:zone_id/load_balancers/:id |
Overwrite entire Load Balancer | PUT | /zones/:zone_id/load_balancers/:id |