Every device connected to the Internet is identified by an IP address. However, IP addresses are difficult for humans to remember and may change over time. DNS (Domain Name System) provides a human-readable naming system (domain name) that maps a domain name to its corresponding IP address.
Instead of accessing
https://203.0.113.5
users simply access
https://example.com
The browser first resolves the domain name into an IP address before establishing the network connection.
DNS Resolution
A typical DNS lookup follows the process below.
Browser
|
| Check local DNS cache
v
Operating System
|
| Check OS cache
v
Recursive DNS Resolver
|
| Query Root DNS
v
Root DNS Server
|
| Refer to .com TLD
v
TLD DNS Server
|
| Refer to authoritative DNS
v
Authoritative DNS Server
|
| example.com → 203.0.113.5
v
Browser
Once the IP address is obtained, the browser can establish a TCP (or QUIC) connection to the destination server. Note that a domain name can corresponds to mulitple IPs.
Common DNS Records
| Record | Purpose |
|---|---|
| A | Maps a domain name to an IPv4 address |
| AAAA | Maps a domain name to an IPv6 address |
| CNAME | Creates an alias to another domain |
| MX | Specifies mail servers |
| TXT | Stores arbitrary text (e.g., domain verification, SPF, DKIM) |
A Record
An A record directly maps a domain name to an IPv4 address.
example.com
A Record
example.com ----------------> 203.0.113.10
Example:
example.com A 203.0.113.10
The returned IP address is then used to establish a TCP connection.
Browser
|
| DNS Query (example.com)
v
DNS Server
|
| 203.0.113.10
v
TCP Connection
However, A records require manual updates when the IP address changes.
CNAME Record
A CNAME (Canonical Name) record maps a domain name to another domain name instead of directly mapping to an IP address.
www.example.com
CNAME
www.example.com ------------> example.com
|
v
203.0.113.10
Example:
example.com A 203.0.113.10
www.example.com CNAME example.com
The advantage is that the underlying IP address can change without updating every related domain.
Comparison of A Record and CNAME Record
Modern cloud services, CDNs, and load balancers often provide a hostname instead of a fixed IP address.
myapp.com
CNAME
cloud-load-balancer.example.com
|
v
Managed IP pool
The service provider can change the underlying infrastructure while keeping the domain configuration unchanged.
Common use cases for DNS
- Human-readable domain names
- Decoupling domain names from changing IP addresses
- Routing traffic to different services
- Supporting email and domain verification
Query a DNS Server to Resolve the Domain Name
dig @8.8.8.8 www.bime.ntu.edu.tw
CDN (Content Delivery Network)
DNS determines where a service is located, but it does not improve how quickly content is delivered. A Content Delivery Network (CDN) is a geographically distributed network of servers that caches content closer to end users, reducing latency and improving availability. Note that it is the domain owner decides to use a CDN by configuring DNS to point the domain to the CDN provider (or by delegating DNS authority to the CDN provider).
Instead of every user contacting the origin server directly,
Users
|
v
Origin Server (Taiwan)
users are redirected to a nearby edge location.
Origin Server
(Taiwan)
|
+-----------+-----------+
| | |
v v v
Tokyo Singapore Los Angeles
Edge Edge Edge
The edge server serves cached content whenever possible, reducing both response time and the load on the origin server.
Typical Request Flow
Client
|
v
CDN Edge Server
|
| Cache Hit?
|
+------ Yes -------> Return cached content
|
No
|
v
Origin Server
|
v
Return response
|
v
Store in cache
What Can Be Cached?
Static resources are typically cached. For instance,
- HTML pages
- CSS
- JavaScript
- Images
- Fonts
- Videos
Dynamic requests usually bypass the cache. For instance,
- User login
- Payment processing
- Database queries
- Personalized content
Common use cases
- Reducing latency
- Lowering origin server load
- Improving scalability
- Increasing service availability
- Mitigating DDoS attacks (when integrated with edge platforms)
Comparison between DNS vs CDN
Although DNS and CDN are frequently provided by the same platform (e.g., Cloudflare), they solve different problems.
| DNS | CDN | |
|---|---|---|
| Primary purpose | Resolve domain names | Deliver content efficiently |
| Main function | Domain → IP mapping | Cache and distribute content |
| Happens | Before the connection | After the connection is established |
| Operates on | DNS queries | HTTP/HTTPS traffic |
| Typical output | IP address | Cached or origin response |
Typical Modern Deployment
In modern web applications, DNS and CDN are often deployed together.
Client
|
|
DNS Resolution
|
v
CDN Edge Server
|
+-----------+-----------+
| |
| Cache Hit | Cache Miss
| |
v v
Cached Content Reverse Proxy
|
+--------+--------+
| |
Frontend Backend API
|
|
Database
- DNS translates the domain name into a reachable service address.
- The CDN serves cached content whenever possible.
- Cache misses are forwarded to the origin infrastructure.
- The reverse proxy routes requests to the appropriate backend service.
Cloudflare
Cloudflare is a globally distributed edge network that combines DNS, CDN, and reverse proxy functions.
Instead of pointing a domain directly to the origin server, the domain owner configures DNS to point to Cloudflare. Users then connect to a nearby Cloudflare edge server, which can serve cached content or forward requests to the origin server.
User
|
|
DNS Resolution
|
v
Cloudflare Edge
(CDN + Reverse Proxy)
|
+-----------+-----------+
| |
Cache Hit Cache Miss
| |
v v
Cached Content Origin Server
Cloudflare provides:
- DNS resolution: maps domain names to Cloudflare’s edge network
- CDN caching: serves static content from nearby edge locations
- Reverse proxying: forwards dynamic requests to the origin server
- Security services: TLS termination, DDoS protection, and web application firewall (WAF)
The user only interacts with Cloudflare’s edge servers and does not directly access the origin infrastructure.