Routing Algorithms

Seven ways to route traffic

Every strategy runs inside a Cloudflare Worker on your account across 330+ PoPs. Switch strategies anytime with zero-downtime Worker Versions.

Strategy comparison

StrategyMechanismFailoverStickinessComplexity
Round RobinEdge-local cursorHealth-check skipNoLow
Weighted Round RobinWeighted randomHealth-check skipNoLow
IP HashDeterministic hashHealth-check skipYes (by IP)Low
Cookie Sticky SessionsCookie read/setRe-pins on failureYes (eb_lb cookie)Medium
Weighted Sticky SessionsWeighted + cookieRe-pins on failureYes (eb_lb cookie)Medium
FailoverRetry on failureAutomaticNoMedium
Geographic SteeringGeo lookupRegional fallbackNoHigh

Round Robin

Equal distribution, zero configuration

Each incoming request is sent to the next origin server in the list, cycling through all healthy servers in order. Every server gets an equal share of traffic.

How it works

The Worker maintains an edge-local rotating cursor. Request 1 goes to Origin A, Request 2 to Origin B, Request 3 to Origin C, and so on within each Cloudflare data center.

overhead
Edge-local cursor
complexity
Low
failover
Health-check skip
sticky
No
When to use
  • ✓Origins have identical CPU/RAM capacity
  • ✓Serving stateless APIs or static content
  • ✓You want the simplest possible setup
  • ✓All origins live in the same region
When not to use
  • —Origins have unequal capacity
  • —You require session stickiness

Weighted Round Robin

Proportional traffic based on server capacity

Each origin is assigned a numeric weight that determines what share of traffic it receives — matching traffic distribution to your server capacity.

How it works

The Worker uses weighted selection across healthy origins based on your configured weights (e.g., 60 / 30 / 10). Distribution converges to the configured ratios over time.

overhead
Weighted random
complexity
Low
failover
Health-check skip
sticky
No
When to use
  • ✓Origins have different capacities (e.g., 8GB vs 2GB RAM)
  • ✓Gradual rollouts (sending 10% traffic to a new node)
  • ✓Mixing dedicated and smaller standby servers
When not to use
  • —All origins are identical (use Round Robin)
  • —Strict deterministic order is required

IP Hash

Deterministic routing without cookies

The visitor IP address (CF-Connecting-IP) is hashed to map the same client consistently to the same origin server across browsers, mobile apps, and API clients.

How it works

The Worker hashes CF-Connecting-IP and maps the result to an active origin index. If an origin fails health checks, traffic redistributes across remaining healthy origins.

overhead
Deterministic hash
complexity
Low
failover
Health-check skip
sticky
Yes (by IP)
When to use
  • ✓Consistent routing needed without HTTP cookies
  • ✓API consumers or mobile apps that ignore cookies
  • ✓Origin-local cache warming
When not to use
  • —Large user groups behind a single corporate NAT/VPN IP
  • —Strict even load across uneven clients

Failover

Primary-backup with automatic recovery

Routes traffic to your primary origin first. On 5xx response, timeout, or connection failure, the Worker automatically retries the next backup origin in priority order.

How it works

Requests target the highest-priority healthy origin. If it fails or fails background health probes, traffic shifts to standby backups and automatically returns when the primary recovers.

overhead
Retry on failure
complexity
Medium
failover
Automatic
sticky
No
When to use
  • ✓Primary production server with a hot standby backup
  • ✓Active-passive disaster recovery without slow DNS TTLs
  • ✓Automatic failback when primary recovers
When not to use
  • —You want active-active load sharing across all origins simultaneously

Geographic Steering

Location-aware routing by colo, country, or continent

Uses Cloudflare edge request metadata (data center colo, country, continent) to route visitors to the nearest regional origin.

How it works

The Worker checks colo match first, then country, then continent against your origin geo tags. If no regional match is healthy, it falls back to round-robin across available origins.

overhead
Geo lookup
complexity
High
failover
Regional fallback
sticky
No
When to use
  • ✓Multi-region origins (US, EU, APAC)
  • ✓Data residency / GDPR regional routing
  • ✓Minimizing round-trip latency for global users
When not to use
  • —All origins live in a single data center

Ready to deploy your strategy?

All 7 routing strategies are included on the Free tier — up to 5 load balancers with no credit card required.