Bird
Raised Fist0

How DNS Works - Resolution Chain from Browser to IP Address

HLDmediumInterview freq: common
Choose your preparation mode4 modes available
🎯
How DNS Works - Resolution Chain from Browser to IP Address
45 min · senior
senior

You are designing the DNS resolution process for a startup with 50 million daily active users (DAU). The system must resolve domain names to IP addresses efficiently and securely, supporting encrypted DNS queries to protect user privacy. The resolution chain should maintain a P99 latency under 200ms globally. The system must handle high query volumes and support offline fallback mechanisms for intermittent connectivity.

  • Support DNS-over-HTTPS (DoH) or DNS-over-TLS (DoT) for encrypted queries
  • P99 resolution latency must be under 200ms globally
  • System must handle at least 10 million DNS queries per second
  • Offline fallback caching on client devices to reduce network dependency
  • Global distribution with regional authoritative DNS servers for low latency
  • Cache consistency and TTL adherence to avoid stale IP addresses
📋
Guided Steps
1/5
Step 1
Choosing the DNS Query Transport Protocol
Which protocol should the client use to send DNS queries to ensure privacy and security?
💡 Hint
Consider protocols that encrypt DNS queries to prevent eavesdropping and tampering.
Use DNS-over-HTTPS (DoH) with HTTP/2 or HTTP/3 transport to encrypt DNS queries and leverage existing web infrastructure.
Mid-level: Names DoH or DoT as encrypted DNS protocols. Senior: Explains why DoH over HTTP/2 or HTTP/3 is preferred for browser integration and firewall traversal, and why plain UDP DNS is insecure.
⚠️Common Wrong Answer
Using traditional UDP DNS queries - exposes queries to MITM attacks and cannot guarantee privacy, failing security constraints.
Step 2
Designing the DNS Resolver Architecture
How should the DNS resolver infrastructure be architected to handle 10M QPS with P99 < 200ms globally?
💡 Hint
Think about global distribution, caching layers, and authoritative server placement.
Deploy globally distributed recursive resolvers using Anycast IPs combined with edge caching via Redis clusters to reduce latency and load on authoritative servers.
Mid-level: Mentions caching and global distribution. Senior: Details Anycast for geo-routing, Redis TTL-based caching for fast lookups, and fallback to authoritative servers with load balancing.
⚠️Common Wrong Answer
Centralized resolver cluster - creates latency hotspots and single points of failure, breaking P99 latency and scalability.
Step 3
Implementing Client-Side Caching and Offline Fallback
How should the client handle DNS caching and offline scenarios to reduce network dependency and improve latency?
💡 Hint
Consider TTL adherence and cache invalidation strategies on the client side.
Use a local DNS cache with TTL enforcement and stale-while-revalidate strategy, combined with persistent storage (IndexedDB or localStorage) for offline fallback.
Mid-level: Describes basic caching with TTL. Senior: Explains stale-while-revalidate to serve stale entries during network issues and persistent storage for offline resolution.
⚠️Common Wrong Answer
No client caching or ignoring TTL - leads to excessive queries, increased latency, and stale IP usage.
Step 4
Handling Cache Consistency and TTL Expiry
How does the system ensure cache consistency and timely TTL expiry across distributed caches and clients?
💡 Hint
Think about TTL propagation, cache invalidation, and authoritative server TTL enforcement.
Enforce TTL strictly at all caching layers (client, recursive resolver, edge caches) and use authoritative DNS servers with accurate TTL values; implement negative caching for NXDOMAIN responses using RFC 2308.
Mid-level: Mentions TTL usage. Senior: Explains negative caching, TTL enforcement at each layer, and consequences of TTL misconfiguration causing stale or incorrect resolutions.
⚠️Common Wrong Answer
Ignoring negative caching or inconsistent TTL enforcement - causes stale data, cache poisoning risks, and resolution errors.
Step 5
Designing APIs for DNS Resolution and Cache Management
What are the core API endpoints the client should expose for DNS resolution, cache refresh, and error reporting?
💡 Hint
Consider endpoints for query submission, cache invalidation, and failure feedback.
Expose three endpoints: (1) /dns-query for DoH DNS queries, (2) /cache-refresh to force TTL-based cache invalidation, (3) /resolution-report to send failure or latency metrics for monitoring.
Mid-level: Names DNS query endpoint. Senior: Details cache management and telemetry endpoints to improve reliability and observability.
⚠️Common Wrong Answer
Only a DNS query endpoint without cache or error reporting - limits client control and observability, impacting reliability.
🔌
API Design Challenge
Sketch 3 core API endpoints that a browser or client uses to perform DNS resolution securely and efficiently.
  • How does the client send a DNS query over HTTPS or TLS?
  • How does the client refresh or invalidate cached DNS entries?
  • How does the client acknowledge or report resolution failures?
📊
Scoring Rubric
▼ Show
Must Have - 60%
  • Use of DNS-over-HTTPS or DNS-over-TLS for encrypted queries
  • Global distribution of recursive resolvers with Anycast IPs
  • Client-side caching with TTL enforcement and offline fallback
  • Strict TTL and negative caching enforcement across caches
Good to Have - 30%
  • Edge caching layer with Redis clusters for high throughput
  • API endpoints for cache refresh and resolution failure reporting
  • Use of stale-while-revalidate strategy on client cache
Bonus - 10%
  • Detailed explanation of failure modes like cache poisoning or stale data
  • Telemetry integration for DNS resolution monitoring
Using plain UDP DNS queries - exposes queries to man-in-the-middle attacks and privacy leaks, compromising user security
Centralized resolver architecture - causes latency spikes and single points of failure, breaking scalability and availability
Ignoring TTL or negative caching - leads to stale or incorrect DNS responses, increasing risk of cache poisoning and resolution errors
No client-side caching or offline fallback - increases latency and network dependency, degrading user experience during outages
Omitting cache invalidation APIs - reduces client control and observability, impacting system reliability and troubleshooting
✅
Model Answer
▼ Reveal

The DNS resolution chain uses DNS-over-HTTPS for encrypted queries, globally distributed recursive resolvers fronted by Anycast IPs, and Redis-based edge caching to achieve P99 latency under 200ms at 10M QPS. Clients implement TTL-enforced caching with stale-while-revalidate and offline fallback using persistent storage to maintain resolution during network outages.

  • Use DNS-over-HTTPS (DoH) over HTTP/2 or HTTP/3 to encrypt DNS queries and enable firewall traversal
  • Deploy recursive resolvers globally with Anycast IPs for geo-routing and low latency
  • Implement edge caching with Redis clusters using TTL-based eviction to reduce load on authoritative servers
  • Enforce strict TTL adherence and negative caching at all caching layers to prevent stale or poisoned responses
  • Use client-side caching with TTL enforcement and stale-while-revalidate strategy combined with persistent storage for offline fallback
  • Expose APIs for DNS queries (/dns-query), cache refresh (/cache-refresh), and resolution failure reporting (/resolution-report) to improve observability and reliability
  • DNS-over-HTTPS (DoH) using HTTP/2 or HTTP/3 for encrypted, firewall-friendly DNS queries
  • Globally distributed recursive resolvers fronted by Anycast IPs for geo-routing and low latency
  • Edge caching layer implemented with Redis clusters using TTL-based eviction to reduce authoritative load
  • Authoritative DNS servers deployed regionally with accurate TTL and negative caching per RFC 2308
  • Client-side DNS cache with TTL enforcement and stale-while-revalidate strategy using persistent storage (IndexedDB)
  • API endpoints: /dns-query (DoH), /cache-refresh (cache invalidation), /resolution-report (failure telemetry)
  • Strict TTL adherence and negative caching to prevent stale or poisoned DNS responses
  • Offline fallback on client using persistent cache to maintain resolution during network outages

Practice

(1/5)
1. In a time-series ingestion pipeline, at step 4 the Aggregation Worker reads raw event batches from Kafka and writes summarized metrics to the time-series database. What happens if the Aggregation Worker crashes after reading but before writing?
easy
A. The raw events remain in Kafka and will be reprocessed after worker restart
B. The Aggregation Worker automatically retries writing without re-reading events
C. The summarized metrics are partially written causing data corruption in the database
D. The raw events are lost because Kafka deletes them immediately after consumption

Solution

  1. Step 1: Understand Kafka's offset commit behavior

    Kafka retains messages until consumers commit offsets. If the worker crashes before committing, messages remain available for reprocessing.
  2. Step 2: Analyze crash timing

    Since the worker crashed before writing summaries and committing offsets, raw events remain in Kafka and will be reprocessed after restart.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    Kafka retains uncommitted messages for reprocessing [check]
Hint: Kafka commits offsets after processing to avoid data loss [check]
Common Mistakes:
2. For a social network with users having highly variable follower counts (from tens to millions), which fan-out architecture best balances write latency and read latency?
medium
A. Pure pull fan-out: followers fetch posts on demand from a global store
B. Pure push fan-out: push every post to all followers' feeds synchronously
C. Hybrid fan-out: push to high-follower-count users' feeds, pull for low-follower-count users
D. Push fan-out only for active users, pull for inactive users

Solution

  1. Step 1: Analyze pure push fan-out (A)

    Push to all followers synchronously causes huge write amplification for celebrities, increasing write latency and storage.
  2. Step 2: Analyze pure pull fan-out (C)

    Pull reduces write cost but increases read latency and complexity for users with many followers.
  3. Step 3: Evaluate hybrid fan-out (B)

    Hybrid pushes to users with many followers (to reduce read latency) and pulls for users with few followers (to reduce write amplification), balancing both latencies.
  4. Step 4: Evaluate push only for active users (D)

    Activity-based push doesn't address follower count skew effectively.
  5. Final Answer:

    Option C -> Option C
  6. Quick Check:

    Hybrid fan-out balances write and read latency by follower count [check]
Hint: Hybrid fan-out balances write/read latency by follower count [check]
Common Mistakes:
3. Without explicitly stating your assumptions during a design interview, what failure mode is most likely to occur in your explanation?
medium
A. The interviewer assumes your design is perfect and asks no questions
B. Your design appears inconsistent or incomplete, causing confusion and follow-up questions
C. Your design is accepted without challenge, even if it has flaws
D. The interviewer provides the solution for you to avoid confusion

Solution

  1. Step 1: Understand the role of stating assumptions

    Explicit assumptions clarify scope and constraints, preventing misunderstandings.
  2. Step 2: Trace failure when assumptions are omitted

    Without assumptions, interviewers may accept incomplete designs without challenge, missing flaws.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Omitting assumptions leads to unchallenged flawed designs [check]
Hint: State assumptions to avoid unchallenged flawed designs [check]
Common Mistakes:
4. If the Key Management Service (KMS) becomes unavailable, what exactly breaks in the system's encryption-at-rest workflow?
medium
A. New encryption keys cannot be generated, but existing data remains accessible and decryptable
B. Data encryption stops, causing all writes to fail immediately
C. Decryption of existing data fails, causing read operations to block or error out
D. The system falls back to unencrypted storage, risking data exposure

Solution

  1. Step 1: Understand KMS role in key lifecycle

    KMS generates and manages encryption keys; if unavailable, new keys can't be created but existing keys cached locally allow decryption.
  2. Step 2: Eliminate incorrect failure modes

    Encryption doesn't stop immediately; decryption continues with cached keys; system does not fallback to unencrypted storage automatically.
  3. Final Answer:

    Option A -> Option A
  4. Quick Check:

    KMS outage blocks new key generation, existing keys still usable [check]
Hint: KMS down -> no new keys, existing keys still decrypt [check]
Common Mistakes:
5. At 10x scale, which component is most likely to fail first in a system targeting 99.999% availability, and why?
hard
A. The database because it cannot handle 10x write throughput without sharding
B. The load balancer because it cannot maintain 10x concurrent TCP connections
C. The message queue because it runs out of disk space under 10x message volume
D. The chat servers because WebSocket connections are stateful and can't be resharded easily

Solution

  1. Step 1: Identify stateful bottlenecks at scale

    Chat servers maintain stateful WebSocket connections bound to server memory, limiting horizontal scaling.
  2. Step 2: Compare other components' scalability

    Databases can shard; load balancers can be scaled horizontally; queues can be partitioned and scaled with disk expansion.
  3. Final Answer:

    Option D -> Option D
  4. Quick Check:

    Stateful WebSocket servers -> resharding hard -> first bottleneck at 10x scale [check]
Hint: Stateful WebSocket servers -> resharding hard -> first bottleneck [check]
Common Mistakes:
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard