Chapter 04 · Cloudflare Deploy
Subchapter 4.197
references/smart-placement/README.mdMarkdown5 KBView on GitHub
Automatic workload placement optimization to minimize latency by running Workers closer to backend infrastructure rather than end users.
Smart Placement automatically analyzes Worker request duration across Cloudflare’s global network and intelligently routes requests to optimal data center locations. Instead of defaulting to the location closest to the end user, Smart Placement can forward requests to locations closer to backend infrastructure when this reduces overall request duration.
Enable Smart Placement when:
fetch handler (not RPC methods)Do NOT enable for:
fetch handlers are affected)run_worker_first = true (degrades asset serving)Does your Worker have a fetch handler?
├─ No → Smart Placement won't work (skip)
└─ Yes
│
Does it make multiple backend calls (DB/API)?
├─ No → Don't enable (won't help)
└─ Yes
│
Is backend geographically concentrated?
├─ No (globally distributed) → Probably won't help
└─ Yes or uncertain
│
Does it serve static assets with run_worker_first=true?
├─ Yes → Don't enable (will hurt performance)
└─ No → Enable Smart Placement
│
After 15min, check placement_status
├─ SUCCESS → Monitor metrics
├─ INSUFFICIENT_INVOCATIONS → Need more traffic
└─ UNSUPPORTED_APPLICATION → Disable (hurting performance)Recommended: Split full-stack applications into separate Workers:
User → Frontend Worker (at edge, close to user)
↓ Service Binding
Backend Worker (Smart Placement enabled, close to DB/API)
↓
Database/Backend ServiceThis maintains fast, reactive frontends while optimizing backend latency.
// wrangler.jsonc
{
"placement": {
"mode": "smart" // or "off" to explicitly disable
}
}Deploy and wait 15 minutes for analysis. Check status via API or dashboard metrics.
To disable: Set "mode": "off" or remove placement field entirely (both equivalent).
type PlacementStatus =
| undefined // Not yet analyzed
| 'SUCCESS' // Successfully optimized
| 'INSUFFICIENT_INVOCATIONS' // Not enough traffic
| 'UNSUPPORTED_APPLICATION'; // Made Worker slower (reverted)# Deploy with Smart Placement
wrangler deploy
# Check placement status
curl -H "Authorization: Bearer $TOKEN" \
https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/services/$WORKER_NAME \
| jq .result.placement_status
# Monitor
wrangler tail your-worker-name --header cf-placementFirst time? Start here:
Quick lookup: