DNS Proxies CDNs and Safe Address Changes

Scaling DNS and Load Balancing · 40 min

System Design · Module 5 · Lesson 2 of 4 · 40 min

DNS Proxies CDNs and Safe Address Changes

Distinguish naming from request routing, place forward and reverse proxies correctly, and plan a DNS migration with cache overlap.

DNS selects an entry address under caching rules; downstream proxies and application contracts govern what happens to requests.

01 The idea

The problem this lesson solves

A stub resolver requests the service address from a recursive resolver.

Prerequisite: earlier lessons introduce the vocabulary and shared examples used here. Follow the module order.

Recursive resolverA DNS service that resolves names for a client, using caches and further lookups as needed.
Reverse proxyA service fronting origin servers and forwarding requests to them.
CDNA distributed serving layer that can cache eligible content near callers.

02 Worked example

Follow one worked example

DNS Proxies CDNs and Safe Address Changes worked diagram01Client stubAsks resolver02Recursive DNSCache + delegation03Edge / proxyEntry address04OriginEligible forwarded workDNS Proxies CDNs and Safe Address Changes compact diagram01Client stubAsks resolver02Recursive DNSCache + delegation03Edge / proxyEntry address04OriginEligible forwarded work
Client stub: Asks resolver • Recursive DNS: Cache + delegation • Edge / proxy: Entry address • Origin: Eligible forwarded work.

Trace the example in order. Follow the same identities, units and state transitions through the diagram and the events below.

1
Client asksA stub resolver requests the service address from a recursive resolver.
2
Resolver followsIt uses cached answers or follows the relevant delegation chain.
3
Client connectsThe returned entry point may be a reverse proxy or CDN.
4
Origin handles missesThe intermediary forwards only the work its policy requires.

DNS selects an entry address under caching rules; downstream proxies and application contracts govern what happens to requests.

03 The method

Mechanisms decisions and a guided tutorial

Work through the explanation in order, then apply it in the tutorial. Each comparison names a cost as well as a benefit.

Choice or conceptPurposeBoundary or cost
DNSName → recordsCaches and existing connections
Forward proxyActs for clientsClient policy boundary
Reverse proxyFronts serversRouting and upstream contract
CDNServes eligible edge contentCorrect cache key and privacy rules

Separate DNS from per-request routing

A browser's stub resolver usually asks a recursive resolver for an address. On a cache miss, that resolver follows DNS delegations through root, top-level-domain and authoritative servers as needed. DNS answers are cached according to TTL and resolver behavior. DNS can direct users toward a region or entry point; it usually does not choose one app server for every HTTP request. Existing connections also do not migrate merely because a DNS record changes.

Place proxies and caches by responsibility

A forward proxy acts on behalf of clients; a reverse proxy fronts servers. An API gateway can add authentication, quotas and routing policies; a load balancer focuses on traffic distribution, though one product may do both. A CDN serves eligible cached content near users and reduces origin traffic. It must use correct cache keys and privacy policies: caching one user's private response as public content is a correctness and confidentiality failure.

Plan a DNS migration before changing the record

Lower the TTL sufficiently ahead of the change for previously cached long-lived answers to expire. Bring the new target up, verify it, change the record, and keep the old target serving during the overlap. Monitor both destinations. A low TTL reduces some caching delay; it does not flush all caches, terminate existing connections or make a failed new origin healthy.

Follow the naming chain

A client usually asks its configured recursive resolver. On a cache miss, the resolver follows delegation through the relevant root, top-level-domain and authoritative servers. Some answers are referrals rather than final host addresses. The client does not need to perform every step for every request because several layers cache results.

TTL is a lifetime for a cached DNS answer under the relevant resolver behavior. It is not an instruction that moves an already-open HTTP connection. A client can keep using an established connection even after a record changes; application and transport lifetimes matter during a migration.

Place each intermediary by whose request it handles

A corporate browsing proxy acts for clients and is a forward proxy. An ingress proxy represents the origin service and is a reverse proxy. An API gateway may add authentication, quotas and request policies. A CDN can answer eligible cache hits without contacting the origin.

One product can perform several roles, but the responsibilities remain useful. A CDN cache key and privacy policy must separate representations correctly. A personalized response cannot be made public merely because static images benefit from public caching. Cache eligibility is part of the resource contract.

Migrate with an overlap period

If the current TTL is twenty-four hours, lowering it to five minutes does not rewrite old cached answers immediately. Lower it ahead of the address change and allow the older lifetime to pass under the standard caching model. Bring the new service up, verify it, change the record and continue serving the old target during the overlap.

Monitor both addresses and client errors. Avoid a claim of one universal cutoff: resolvers, clients and existing connections can behave differently. A low TTL increases lookup activity and can reduce some propagation delay, but it cannot make an unhealthy origin usable.

Guided tutorial

1. Observe DNS

Run dig example.com A and identify the answer TTL without assuming a fixed address.

2. Classify proxies

Draw one forward proxy and one reverse proxy with their clients and servers.

3. Write cache eligibility

Choose public image and private profile responses and state different policies.

4. Plan the change

Write preparation, address cutover, overlap, monitoring and rollback steps.

dig example.com A
curl -I https://example.com
# Migration: lower TTL ahead of cutover → verify new target
# → change answer → overlap old/new serving → observe → retire old

04 Cheat sheet

Review the decisions

Use this table to explain the mechanism and its limit without memorizing a product name.

Choice or conceptRememberCheck
DNSName → recordsCaches and existing connections
Forward proxyActs for clientsClient policy boundary
Reverse proxyFronts serversRouting and upstream contract
CDNServes eligible edge contentCorrect cache key and privacy rules
Recursive resolverA DNS service that resolves names for a client, using caches and further lookups as needed.
Reverse proxyA service fronting origin servers and forwarding requests to them.
CDNA distributed serving layer that can cache eligible content near callers.

05 Where & why

Check the primary references

Use official references for protocol and implementation details. The questions here are teaching prompts.

Primary reference
NGINX HTTP load balancing

Read NGINX HTTP load balancing

Primary reference
DNS concepts

Read DNS concepts

Primary reference
Google SRE cascading failures

Read Google SRE cascading failures

State the implementation version and the workload assumptions when defending your own design.

06 Interview questions

Explain the reasoning out loud

Answer before opening the explanation. The questions progress from vocabulary to decisions and failure behavior.

What does Recursive resolver mean?
A DNS service that resolves names for a client, using caches and further lookups as needed.
What does Reverse proxy mean?
A service fronting origin servers and forwarding requests to them.
What does CDN mean?
A distributed serving layer that can cache eligible content near callers.
Does a five-minute TTL flush an older cached answer?
No. A resolver holding the old answer may retain it for the older remaining lifetime. Plan the TTL reduction ahead of the cutover.
Does a DNS change close existing connections?
No. Established connections have their own lifetime and may continue using the prior address.
How is a CDN miss served?
The edge follows its configured upstream policy to fetch or revalidate content, then may store the eligible result. The origin still needs a capacity and failure plan.
Why distinguish forward from reverse proxy?
It identifies whose behalf the intermediary acts on and where policy is applied. The same forwarding technology can serve different roles.
Can a CDN safely cache every successful API response?
No. Eligibility, privacy, authorization scope and cache-key inputs must be defined. A successful response can still be private.

07 Practice problems

Practice a new case

Solve the new cases before revealing hints. Complete worked solutions follow the set.

Name the proxy

Easy
Classify a corporate browsing proxy and an ingress proxy in front of an API.
Follow-up
The proxy's position alone is less useful than whose behalf it acts on.
Show the hint
Ask whether it represents clients or servers.

Name a record

Easy
State which problem a DNS address answer solves and which HTTP permission problem it does not solve.
Follow-up
State the assumption or edge case that makes the answer correct.
Show the hint
Location and authorization are separate.

DNS overlap

Medium
Plan a migration from a record with a 24-hour TTL to a new origin using a later five-minute TTL.
Follow-up
Caches holding the old TTL do not immediately learn the new one.
Show the hint
Lower the TTL before changing the address.

Private cache

Medium
Explain the risk of caching /profile using only its URL as a public CDN key.
Follow-up
State the assumption or edge case that makes the answer correct.
Show the hint
Different users can receive different bodies for the same path.

Connection overlap

Medium
Why keep an old origin serving after its DNS answer changes?
Follow-up
State the assumption or edge case that makes the answer correct.
Show the hint
Clients may retain answers or open connections.

Migration review

Hard
Plan a hostname cutover when old clients can keep long-lived streams.
Follow-up
State the assumption or edge case that makes the answer correct.
Show the hint
DNS TTL does not move streams.

Worked solutions

1. Name the proxy

The corporate browsing proxy is a forward proxy for clients. The ingress proxy is a reverse proxy for the API servers.

2. Name a record

It helps locate an entry address for a hostname. It does not decide whether the caller may read a private resource.

3. DNS overlap

Lower TTL at least an old-TTL interval ahead under the standard caching model, verify the new origin, change the address, and keep the old origin serving through the overlap. Account for connection lifetimes and monitor stragglers rather than claiming an exact universal cutoff.

4. Private cache

One user’s private representation may be served to another. Define private/no-store behavior or a correct authorized cache design instead of a global URL-only entry.

5. Connection overlap

Some callers can still reach the old address. An overlap period and monitoring prevent avoidable failures while their routing state changes.

6. Migration review

Verify the new target, prepare TTL changes, overlap serving, and define stream draining/reconnect behavior. Monitor both endpoints and retain a rollback plan until the intended client population has migrated.