A user in Singapore does not care about your architecture diagram. They care that the page loads in under a second and the checkout does not stall. If your origin sits in a single region, physics sets a floor under that experience: a round trip across the Pacific takes time no application tuning can remove. Edge architecture moves work closer to the user, so the slow path is taken as rarely as possible.
The common mistake is treating a content delivery network as the whole strategy. A CDN caches static assets well, but it does not fix slow APIs, uncacheable personalised pages, or a single-region database every request must reach. Real latency design covers the full path: DNS, TLS termination, caching, origin shielding, API acceleration, and regional failure. Getting one layer right while ignoring the others leaves the user-visible number almost unchanged.
This guide walks through that full path, from measuring latency properly to designing regional failover that actually works. It assumes a typical web application with static assets, public pages, authenticated APIs, and a primary database.
#Quick Answer: How Do You Design for Global Latency?
Put static assets and cacheable public content on a CDN with long, versioned cache lifetimes, terminate TLS and serve cached responses at the edge, and keep dynamic requests on the shortest possible path to an origin that can answer them. For APIs, that means edge routing to the nearest healthy region, connection reuse, and caching only what is safe to cache. For failover, run at least two regions in an active-passive or active-active pattern with health-checked DNS or anycast routing, and replicate the data your failover actually needs — a second region with no usable data is not a failover plan. Measure latency by percentile and by geography, not by global average, because averages hide exactly the users you are trying to help.
#Measure Before You Build
Latency work without measurement is guesswork, and the wrong metric leads to the wrong fix. Global average latency is almost useless: it blends a fast local majority with a slow distant minority and reports a number nobody experiences. Measure the 50th, 90th, and 99th percentiles separately for each major geography, and split by request type — static assets, HTML, API calls, and the slowest user journey, such as checkout or search. A CDN may cut static asset time dramatically while API time stays flat, and only the split view reveals that.
Real user monitoring tells you what users experience, including DNS, TLS, and last-mile conditions synthetic probes never see. Synthetic monitoring from multiple regions tells you whether a regression is regional or global. Use both. During an investigation you need the waterfall: time to first byte, DNS time, TLS time, and download time, per resource. High time to first byte on dynamic pages points at the origin or database; high download time on assets points at cache hit ratio or compression.
Set targets per geography, not one global target. A 200 millisecond API target may be realistic in the origin region and impossible from the far side of the world without a regional deployment. Let the gap decide where to invest: edge caching is cheap and high-leverage for static content, while regional origins are justified only when dynamic latency for a large user population is the binding constraint.
Cache Hit Ratio Is the Number That Matters
For a CDN, cache hit ratio — the share of requests served from the edge without contacting the origin — is the single most informative metric. A low hit ratio means the CDN is mostly a proxy, adding a hop without removing the origin round trip. Common causes are cache keys that include unnecessary variation, such as query strings that do not change the response, cookies that bust the cache for every user, and short time-to-live values set defensively because nobody is sure what is safe to cache.
Fix the cache key first. Strip marketing query parameters, normalise what remains, and decide explicitly which headers and cookies participate in the key. Then fix lifetimes: version static assets by filename or hash so they can be cached for a year, because a new deploy produces new filenames rather than invalidating old ones. For public HTML that changes occasionally, a short time-to-live combined with stale-while-revalidate lets the edge serve a slightly stale page instantly while refreshing in the background. For personalised content, do not cache the full page; cache the shared fragments and assemble the personalised shell at the edge or the origin, using edge-side includes or a lightweight composition layer where the platform supports it.
#Design the Edge Layer Properly
The edge is more than a cache. Modern edge platforms run compute at points of presence, terminate TLS close to the user, and enforce security policy before traffic reaches the origin. Each capability helps latency in a different way, and each has limits worth respecting.
TLS termination at the edge removes a round trip for the handshake, and TLS 1.3 with session resumption lowers the cost further. HTTP/2 and HTTP/3 multiplexing reduce the penalty of many small assets, and HTTP/3 over QUIC helps most on lossy mobile networks, where TCP head-of-line blocking hurts. Brotli typically beats gzip for text assets, and images should be served in modern formats at responsive sizes rather than one large original resized by CSS.
Edge compute is tempting and easy to overuse. It is excellent for routing, header normalisation, authentication checks, and assembling cached fragments. It is a poor place for heavy business logic or anything stateful, because edge runtimes have CPU and memory limits and distributed edge code is harder to debug. Edge code should be stateless, fast, and fall back cleanly: if it fails, the request should still reach the origin and succeed, perhaps slower.
Origin shielding is the layer teams skip and later regret. Without it, a cache miss storm — after a deploy, a purge, or a traffic spike — hits the origin from every point of presence at once. A shield layer collapses those misses into a single origin request per object per region, which protects the origin during exactly the events when it is most vulnerable. Configure shielding in the region closest to the origin, and make sure purge behaviour is understood: a full purge after every deploy defeats the cache, while versioned assets and targeted purges preserve it.
Dynamic Content and APIs Need a Different Playbook
APIs cannot be cached like images, but they can still be accelerated. Keep connections warm between edge and origin, and use route-based origin selection so a request from Europe goes to the European origin when one exists. For read-heavy APIs with slowly changing data — catalogues, pricing lists, public indexes — cache at the edge with short lifetimes and explicit invalidation on write. For personalised or transactional calls, do not cache; shrink the payload and push aggregation to the server so the client makes one call instead of five.
#Regional Failover That Actually Works
Failover design starts with an honest answer to one question: what does the second region need in order to serve traffic correctly? If the answer is a full copy of the database, failover means replication, conflict handling, and a tested promotion procedure. If the answer is a read-only copy plus a queue for writes, failover means degraded mode, not full service, and the product team must agree to that degradation in advance. If the answer is nothing, because the workload is stateless and data lives elsewhere, failover is comparatively easy — which is why stateless services should stay stateless.
DNS-based failover is the most common approach and the most misunderstood. DNS records have time-to-live values, resolvers cache beyond them, and clients cache beyond resolvers, so failover is never instant. A 60-second TTL does not guarantee 60-second failover. Health checks must be real: a check that returns success when the load balancer is up but the application is returning errors is worse than no check, because it keeps traffic pointed at a broken region. Anycast routing, where the same IP is announced from multiple regions and the network routes to the nearest healthy one, fails over faster and avoids DNS caching problems, but it requires provider support and careful handling of stateful connections, which may reset when routing changes.
Active-active designs, where both regions serve traffic continuously, prove failover every day because both paths are always exercised. They are harder to build: data must be replicated or partitioned, and conflicts must be resolved. Active-passive designs are simpler but carry a specific risk — the passive region is untested until the day it matters, and configuration drift between regions is almost guaranteed unless deploys and infrastructure changes are applied to both identically. Whichever pattern you choose, test failover on a schedule, in production, during business hours, with a rollback plan. A failover that has never been tested is a hypothesis, not a capability.
Data replication choices drive the rest. Synchronous replication gives strong consistency but adds latency to every write and risks availability if the replica region becomes unreachable. Asynchronous replication keeps writes fast but allows a lag window in which failover loses recent writes. Most global applications accept asynchronous replication with a defined recovery point objective, and design for it with idempotent writes and clear behaviour if a recent write is missing after failover.
#Cost, Complexity, and When Not to Add a Region
Every region adds cost beyond the instance bill: replication traffic, cross-region data transfer, duplicated monitoring, and the operational burden of keeping two environments identical. A second region that serves a small fraction of users may cost more in complexity than it saves in latency. Before adding one, check whether the cheaper levers are exhausted: cache hit ratio, payload size, connection reuse, origin location relative to the majority of users, and database query performance. A slow query in the origin region is slow in every region, and replicating a slow system globally just distributes the slowness.
Edge caching plus a single well-placed origin is genuinely the right answer when users cluster in one or two geographies. Global architecture is not a virtue in itself; it is a trade for specific latency and availability goals. Add regions only where measurement justifies them, and add them completely: monitoring, alerting, runbooks, deploy pipelines, and failover tests, not just compute.
#Frequently Asked Questions
Does a CDN help dynamic, personalised content?
A CDN helps most with static and shared content, but it still helps dynamic traffic through TLS termination near the user, connection reuse to the origin, and routing to the nearest healthy origin. Personalised pages should not be fully cached, but shared fragments, API responses with short lifetimes, and static assets on the same page all benefit. Measure the split between static and dynamic time before assuming the CDN is or is not working.
How fast is DNS failover in practice?
Slower than the TTL suggests. Resolvers and clients cache records, and some ignore short TTLs, so failover can take several minutes even with a 60-second TTL. Anycast routing typically fails over faster because it does not depend on DNS caching. For critical paths, combine health-checked DNS with anycast where the provider supports it, and design clients to retry against an alternate endpoint rather than depending solely on DNS.
Should I use active-active or active-passive regions?
Active-active proves both paths continuously but requires replicated or partitioned data and conflict handling. Active-passive is simpler, but the passive region drifts unless changes are applied identically, and it stays untested until failover day. Choose active-active when uptime justifies the data complexity; choose active-passive when the workload tolerates a defined degraded period and the team commits to regular failover tests.
What cache lifetime should I use for public pages?
Version static assets for a year, since new filenames replace old ones. For public HTML that changes occasionally, use a short lifetime, such as a few minutes, combined with stale-while-revalidate so the edge serves instantly while refreshing in the background. Purge explicitly on publish for pages that must be current immediately. The right lifetime is the longest one the content owner can tolerate being stale, not the shortest one that feels safe.
Is HTTP/3 worth enabling?
Usually yes, particularly for mobile users on lossy networks, where QUIC avoids TCP head-of-line blocking and improves connection setup. The gain is modest on fast, reliable networks and larger where packet loss is common. Enable it at the edge, measure by geography and device type, and keep HTTP/2 as a fallback. It is a low-risk change compared with adding a region, so it belongs early in a latency programme, not late.
#Sources and Further Reading
- Cloudflare Documentation, "How CDN Caching Works" and "Origin Shield" — https://developers.cloudflare.com/cache/
- Amazon CloudFront Developer Guide, "How CloudFront Delivers Content" — https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/
- Fastly Documentation, "Shielding" and "Edge Compute" — https://docs.fastly.com/
- "Designing Data-Intensive Applications" by Martin Kleppmann (O'Reilly) — replication, consistency, and partitioning trade-offs
- "Web Performance in Action" by Jeremy Wagner (Manning) — caching, compression, and delivery optimisation
- Google Web Fundamentals, "Optimizing Content Efficiency" — https://web.dev/learn/performance/