Worker Placement, Smart Placement, Region Hints and Limits
How Cloudflare places Workers and Pages Functions near users or back-end infrastructure, with Smart Placement, Placement Hints, limits, and verification.
This page summarises Cloudflare documentation on placement: where Workers and Pages Functions run relative to the end user and to your databases, APIs, and other back-end services. By default they run in the data center closest to where the request was received; Smart Placement and Placement Hints can move execution closer to slow or distant infrastructure when that reduces total latency.
Default placement: why run the Worker near the user or the database?
Section titled “Default placement: why run the Worker near the user or the database?”Workers and Pages Functions normally execute in the data center nearest the incoming request. That is a good default when most work happens at the edge and back-end calls are rare or fast.
When a Worker makes repeated round trips to databases or APIs, running only near the user can add tens of milliseconds per hop. Cloudflare’s placement options trade user proximity against back-end proximity so overall request time can improve—especially for chatty workloads.
By default, Workers and Pages Functions run in a data center closest to where the request was received. If your Worker makes requests to back-end infrastructure such as databases or APIs, it may be more performant to run that Worker closer to your back-end than the end user.
— Cloudflare, Placement
Static assets are a separate path: they are always served from the location nearest the user unless your architecture deliberately routes all traffic through a placed Function (see below).
Smart Placement: automatic location for multiple or unknown back ends
Section titled “Smart Placement: automatic location for multiple or unknown back ends”Smart Placement lets Cloudflare analyze traffic and move a Worker or Pages Function to a more optimal location—for example nearer a database—instead of always using the default “closest to the user” site.
Smart Placement is a unique Cloudflare feature that can make decisions to move your Worker to run in a more optimal location (such as closer to a database). Instead of always running in the default location (the one closest to where the request is received), Smart Placement uses certain “heuristics” (rules and thresholds) to decide if a different location might be faster or more efficient.
— Cloudflare, Smart Placement is smarter about running Workers and Pages Functions in the best locations
When should you enable Smart Placement instead of a region hint?
Section titled “When should you enable Smart Placement instead of a region hint?”Use Smart Placement when you connect to multiple back-end services, do not know exact infrastructure locations, or your services are distributed or replicated. Cloudflare places the Worker closest to the upstream that drives the most request time, based on measured request duration in locations where the Worker has already run.
| Option | Best for | Wrangler setting |
|---|---|---|
| Smart | Multiple back ends or unknown locations | mode = "smart" |
| Region | Single service in a known AWS, GCP, or Azure region | region |
| Host / hostname | Single service outside major clouds (probe-based) | host or hostname |
Smart Placement automatically analyzes your Worker’s traffic patterns and places it in an optimal location. Use Smart Placement when: Your Worker connects to multiple back-end services; You do not know the exact location of your infrastructure; Your back-end services are distributed or replicated.
— Cloudflare, Placement
Smart Placement only considers Cloudflare locations that have already seen traffic for that Worker; it cannot place into a colo that never receives requests. After you enable it, analysis may take up to 15 minutes, and the dashboard flow for Pages suggests sending roughly 20–30 requests before effects appear (Pages Smart Placement).
D1 no longer gets special co-location: Smart Placement applies the same logic whether or not a Worker uses D1 bindings (Workers platform changelog). Workers with Smart Placement enabled also support Gradual Deployments (same changelog, 2024-06-03 entry).
Placement Hints: placement.region, host, and hostname
Section titled “Placement Hints: placement.region, host, and hostname”Placement Hints are explicit Wrangler settings when you know where a single primary database, VM, API, or cluster lives and want the Worker in the Cloudflare colo with lowest latency to that target—not inside the cloud region itself.
Placement Hints let you explicitly specify where your Worker runs. Use Placement Hints when: You know the exact location of your back-end infrastructure; Your Worker connects to a single database, API, or service; Your infrastructure is single-homed (not replicated or anycasted).
— Cloudflare, Placement
Workers still run on Cloudflare’s network; a hint picks the data center with the lowest latency to a given cloud region or probed endpoint. At very high volume (hundreds of thousands of RPS or more), instances may spread for load balancing (New Placement Hints for Workers).
How do you set placement.region for AWS, GCP, or Azure?
Section titled “How do you set placement.region for AWS, GCP, or Azure?”Set placement.region to a provider:region value in wrangler.json or wrangler.toml:
{ "placement": { "region": "aws:us-east-1" }}Supported formats include aws:us-east-1, gcp:us-east4, and azure:eastus (Placement, New Placement Hints). Cloudflare maps the region to the best colo and can adjust for network changes without you listing failover regions.
When should you use placement.host or placement.hostname?
Section titled “When should you use placement.host or placement.hostname?”If infrastructure is not in AWS, GCP, or Azure, expose an endpoint for probes:
placement.host— layer 4 (TCP CONNECT), e.g.my_database_host.com:5432placement.hostname— layer 7 (HTTP HEAD), e.g.my_api_server.com
Only one placement mode applies at a time: mode, region, host, and hostname are mutually exclusive in the same placement block (Placement).
Enable placement in Wrangler or the dashboard
Section titled “Enable placement in Wrangler or the dashboard”Smart Placement is available on all Workers plans. Add configuration or use the dashboard under Workers & Pages → your Worker → Settings → General → Placement → Smart (Placement).
For Pages Functions, enable Smart under Settings → Runtime (Pages Smart Placement); project-level enablement is also noted in the Pages platform changelog.
Wrangler example for Smart Placement:
[placement]mode = "smart"Smart Placement requires consistent traffic from multiple locations so the system can compare candidates (Placement).
Pages Functions, static assets, and run_worker_first
Section titled “Pages Functions, static assets, and run_worker_first”Pages Smart Placement applies to Functions and middleware; static files are still intended to be served closest to users—but there are important exceptions.
Smart Placement applies to Pages Functions and middleware. Normally, assets are always served globally and closest to your users.
— Cloudflare, Smart Placement (Pages)
If middleware runs on every request with Smart Placement enabled, assets may be served from near your back end, increasing latency. If you use env.ASSETS.fetch, assets are served from the same location as the Function, which may be the back-end-optimal colo, not the user (Pages Smart Placement).
For Workers with static assets, Smart Placement only applies when a main Worker is defined (Static assets binding):
run_worker_first |
Behavior |
|---|---|
true |
Every request hits the Smart-Placed Worker first; asset requests may be slower—use for auth, back-end integration, or asset mutation |
false or unset |
Assets stay near the user; Worker logic runs in the efficient placement target |
To mix fast static delivery with a placed API Worker, Cloudflare suggests splitting into multiple Workers linked with service bindings (Static assets binding, Service bindings).
Limits: fetch handlers, RPC, cache, and API status
Section titled “Limits: fetch handlers, RPC, cache, and API status”Placement (Smart Placement and Placement Hints) shares the same runtime limits:
Placement only affects the execution of fetch event handlers. It does not affect RPC methods or named entrypoints. Workers without a fetch event handler are ignored by placement.
— Cloudflare, Placement
Workers Cache is independent of where the Worker runs: tiered cache still serves from near the user on hits, and Smart Placement is considered only when both cache tiers miss (Smart placement and the cache). On a full miss, the request may touch the eyeball colo, an upper-tier cache colo, and the placement target—those three locations are chosen separately today.
What do Workers API placement states mean?
Section titled “What do Workers API placement states mean?”Query status via the Workers API:
| Status | Meaning |
|---|---|
| (not present) | Not analyzed yet; default location |
SUCCESS |
Analyzed; Smart Placement will optimize |
INSUFFICIENT_INVOCATIONS |
Not enough multi-location traffic |
UNSUPPORTED_APPLICATION |
Placement made the Worker slower; reverted (rare) |
Example request:
curl -X GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/workers/services/$WORKER_NAME" \ -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ -H "Content-Type: application/json" | jq .Request duration analytics measure impact at the colo nearest the user; about 1% of requests skip Smart Placement routing as a baseline (Placement).
Verify placement with cf-placement and metrics
Section titled “Verify placement with cf-placement and metrics”When placement is enabled, Cloudflare adds a cf-placement response header: a type plus airport code (e.g. remote-LHR for Smart-routed execution near London, local-EWR for default local execution near Newark) (Placement).
Use Functions Metrics on Pages and Worker request duration analytics after enabling Smart Placement (Pages Smart Placement, Placement).
Common mistakes
Section titled “Common mistakes”- Enabling Smart Placement on a Worker with no
fetchhandler—placement is ignored. - Expecting RPC or named entrypoints to relocate—they do not.
- Using host/hostname hints against anycast or multi-region replicas—probes target single-homed endpoints only.
- Running global middleware on Pages with Smart Placement and being surprised by asset latency.
- Confusing placement with cache location—a cache hit never runs the Worker, so Smart Placement is not involved (Workers Cache).
How to check this on your site
Section titled “How to check this on your site”- Confirm Wrangler or dashboard settings match your goal:
mode = "smart"for unknown or multiple back ends, or an explicitregion/host/hostnamehint from Placement or New Placement Hints. - Deploy, send sustained traffic from more than one geographic path (Workers need multi-location invocations; Pages Functions benefit from an initial batch of requests per Pages Smart Placement).
- Inspect responses for the
cf-placementheader and interpretremote-vslocal-values (Placement). - Check placement state and request-duration analytics via the Workers API and dashboard metrics (Placement).
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact wording you are asking about, and we will correct or clarify it.