Skip to content

Cloudflare Load Balancing

You can configure Spectrum with Cloudflare Load Balancing to provide TCP healthchecks, failover, and traffic steering, bringing resiliency to your Spectrum applications.

For an overview of how Cloudflare Load Balancing works refer to Load Balancing components. For setup guidance refer to Add load balancing to Spectrum applications.

TCP health checks

You can configure a Cloudflare load balancer to probe any TCP port for an accepted connection, which is in addition to HTTP and HTTPS probing capabilities.

Health checks are optional within a load balancer. However, without a health check, the load balancer will distribute traffic to all endpoints in the first pool. With the health checks enabled, hosts that have gone into an error state will not receive traffic, maintaining uptime. This allows you to enable intelligent failover within a pool of hosts or amongst multiple pools.

The example below shows a TCP health check configuration for an application running on port 2408 with a refresh rate every 30 seconds. You can configure TCP health checks through the dashboard or through Cloudflare’s API.

TCP health check - Dashboard example

FieldValue
TypeTCP
Port2408

Under Advanced health check settings:

FieldValue
Interval30
Timeout5 seconds
Retries2

TCP health check - API example

Terminal window
curl 'https://api.cloudflare.com/client/v4/organizations/{organization_id}/load_balancers/monitors' \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{"description":"Spectrum Health Check","type":"tcp","port":2048,"interval":30,"retries":2,"timeout":5,"method":"connection_established"}'
{
"description": "Spectrum Health Check",
"type": "tcp",
"port": 2048,
"interval": 30,
"retries": 2,
"timeout": 5,
"method": "connection_established"
}

Traffic steering

All traffic steering policies are available for transport load balancing through Spectrum. Refer to the Load Balancing documentation to learn more about the available global traffic steering and endpoint steering options.

Weights

Endpoint weights allow you to have endpoints with different capacity or to split traffic amongst hosts for any other reason.

Weight configured within a load balancer pool will be honored with load balancing through Spectrum.

Requirements and limitations

  • This feature requires an Enterprise plan. If you would like to upgrade, contact your account team.