// routing strategies

Seven ways to
route traffic.

Each strategy is optimized for different use cases. Pick the one that fits your architecture, or switch strategies anytime without downtime. All strategies run at the edge with zero cold starts.

// quick comparison
StrategyOverheadFailoverStickyBest For
Round Robin~0msNoNoYour origins have identical capacity and specs
Weighted Round Robin~0msNoNoYour origins have different capacities (e.g., 8GB vs 2GB RAM)
IP Hash~0msNoYes (by IP)You need consistent routing without cookies
Sticky Sessions~1msYes (re-picks)Yes (by cookie)You have session-based applications (login sessions, shopping carts)
Weighted Sticky Sessions~1msYes (re-picks)Yes (by cookie)You have stateful applications with servers of different capacity
Failover~2ms (on failover)Yes (automatic)NoYou have a primary server with a hot standby
Geographic Routing~1msYes (fallback)NoYou have origins in multiple regions (US, EU, Asia)

Round Robin

Equal distribution, zero configuration

The simplest load balancing strategy. Each incoming request is sent to the next origin server in the list, cycling through all servers in order. Every server gets an equal share of traffic regardless of its capacity or current load.

How it works

The Worker maintains an internal counter. Request 1 goes to Origin A, Request 2 to Origin B, Request 3 to Origin C, Request 4 back to Origin A, and so on. The counter is edge-local, meaning each Cloudflare data center tracks its own rotation independently.

Technical details
Overhead
~0ms
Complexity
Low
Failover
No
Sticky
No
Use when
  • Your origins have identical capacity and specs
  • You are serving stateless APIs or static content
  • You want the simplest possible setup
  • All origins are in the same region
Do not use when
  • Origins have different CPU/memory capacity
  • Some origins are slower than others
  • You need session persistence

Weighted Round Robin

Proportional traffic based on server capacity

Like round robin, but each server is assigned a weight that determines what percentage of traffic it receives. A server with weight 70 gets roughly 70% of all requests, while a server with weight 30 gets 30%. This lets you match traffic distribution to your actual server capacity.

How it works

You assign a numeric weight to each origin (e.g., 60, 30, 10). The Worker uses weighted random selection to pick an origin for each request. Over time, the distribution converges to match the weights. The selection is per-request, not a fixed rotation.

Technical details
Overhead
~0ms
Complexity
Low
Failover
No
Sticky
No
Use when
  • Your origins have different capacities (e.g., 8GB vs 2GB RAM)
  • You are doing gradual rollouts (new server gets 10% traffic)
  • You are A/B testing between two backends
  • You have a mix of dedicated and shared hosting
Do not use when
  • All origins are identical (use round robin)
  • You need guaranteed exact percentages (weighted is probabilistic)

IP Hash

Consistent routing without cookies

The visitor's IP address is hashed to determine which origin server they hit. The same IP always maps to the same server, providing consistency without requiring cookies. This works with any HTTP client, including browsers, mobile apps, and API consumers.

How it works

The Worker takes the client's IP address (from CF-Connecting-IP), hashes it, and maps the result to an origin index. The mapping is deterministic — the same IP always gets the same server. If an origin goes down, affected users are redistributed to the next available server.

Technical details
Overhead
~0ms
Complexity
Low
Failover
No
Sticky
Yes (by IP)
Use when
  • You need consistent routing without cookies
  • You are running a CDN with cache warming at origins
  • Your API consumers expect to hit the same backend
  • You cannot use cookies (some API clients strip them)
Do not use when
  • Many users share the same IP (corporate NAT, VPNs)
  • You need even distribution regardless of IP patterns

Failover

Primary-backup with automatic recovery

All traffic goes to your primary origin server. The moment it stops responding (connection failure, 5xx error, or timeout), the Worker automatically routes to the next server in the list. When the primary recovers, traffic shifts back. This gives you disaster recovery with zero manual intervention.

How it works

The Worker tries the first origin. If it fails (5xx status, connection refused, or timeout), it retries the next origin in the list. Health checks run periodically in the background, and the Worker tracks which origins are healthy. Failed origins are marked as unhealthy and skipped for subsequent requests until they recover.

Technical details
Overhead
~2ms (on failover)
Complexity
Medium
Failover
Yes (automatic)
Sticky
No
Use when
  • You have a primary server with a hot standby
  • You need disaster recovery without DNS-level failover
  • You want automatic failback when the primary recovers
  • You have a staging server that should only receive traffic when production is down
Do not use when
  • You want traffic distributed across all origins
  • All origins should actively serve traffic

Geographic Routing

Location-aware traffic distribution

Routes visitors to the origin server closest to their physical location. The Worker uses Cloudflare's edge data (data center colo, country, continent) to make routing decisions. This minimizes latency and helps with data sovereignty requirements like GDPR.

How it works

When a request arrives at a Cloudflare edge, the Worker checks the data center location. It first tries to match by city, then by country, then by continent. If no match is found, it falls back to round-robin across all origins. You configure which origins serve which regions.

Technical details
Overhead
~1ms
Complexity
High
Failover
Yes (fallback)
Sticky
No
Use when
  • You have origins in multiple regions (US, EU, Asia)
  • You need to comply with GDPR or data residency laws
  • You want to minimize latency for global users
  • You serve region-specific content (localized APIs, CDNs)
Do not use when
  • All origins are in the same region
  • You do not care about latency optimization
  • Your application does not have region-specific data

Ready to deploy?

Pick a strategy and deploy your first load balancer in under 90 seconds.