Practice
1. A browser needs to resolve a domain name to an IP address but wants to avoid repeated queries to external servers for the same domain within a short time. Which component in the DNS resolution chain primarily handles this optimization?
easy
Solution
Step 1: Identify the role of the local DNS resolver
The local DNS resolver (stub resolver) on the user's machine caches recent DNS lookups to avoid repeated network queries for the same domain within a short time.Step 2: Eliminate other options
Authoritative DNS servers provide domain data but do not cache queries for clients. Root servers do not cache all mappings globally and are rarely queried directly. Recursive DNS servers do cache results to improve performance, so The recursive DNS server, which never caches results and always queries authoritative servers is incorrect.Final Answer:
Option B -> Option BQuick Check:
Local resolver caches to reduce network calls [check]
Hint: Local resolver caches recent lookups to reduce queries [check]
Common Mistakes:
2. For delivering videos globally with low latency, should the system use a centralized origin server with global CDN caching, or a peer-to-peer (P2P) delivery network? Assume millions of users worldwide and variable network conditions.
medium
Solution
Step 1: Evaluate delivery approaches for global scale and latency
P2P (A) alone is unreliable due to variable user upload bandwidth and NAT traversal issues. Multiple regional origins without CDN (D) add complexity and don't scale well globally. P2P with CDN fallback (C) adds complexity and inconsistent performance.Step 2: Recognize CDN benefits
A centralized origin with global CDN (B) provides consistent availability, low latency via edge caching, and simplifies management, making it the best fit for millions of users worldwide.Final Answer:
Option A -> Option AQuick Check:
Global CDN ensures consistent low-latency delivery [check]
Hint: Global CDN with origin beats P2P for consistent delivery [check]
Common Mistakes:
3. Without the graph database's relationship index, what exactly breaks during a shortest path query between two nodes?
medium
Solution
Step 1: Role of relationship index
The index enables efficient lookup of edges; without it, traversal cannot proceed correctly.Step 2: Behavior without index
Queries relying on the index return empty results silently because no edges are found, not errors or scans.Final Answer:
Option A -> Option AQuick Check:
Missing index causes silent empty results, not crashes or scans [check]
Hint: Missing index -> silent empty results, no errors or scans [check]
Common Mistakes:
4. For a mobile chat app requiring exactly-once message delivery with minimal latency, which architecture is best suited?
medium
Solution
Step 1: Evaluate Kafka transactions for mobile clients
Kafka's transactional exactly-once requires stable connections and complex coordination, unsuitable for mobile clients with intermittent connectivity.Step 2: Assess idempotent consumers with client deduplication
Idempotent consumers combined with client-side deduplication handle retries and duplicates gracefully, fitting mobile constraints and ensuring exactly-once delivery.Final Answer:
Option D -> Option DQuick Check:
Idempotency + client deduplication -> practical exactly-once for mobile [check]
Hint: Mobile needs idempotency + deduplication, not Kafka transactions [OK]
Common Mistakes:
5. You must implement a distributed lock for a system with high contention and strict latency requirements. Which approach is best and why?
medium
Solution
Step 1: Evaluate Redis SETNX under high contention
Redis SETNX with TTL (A) is fast but can cause split-brain and stale locks under network partitions, violating correctness.Step 2: Consider consensus-based lock service
Consensus-based services like etcd (B) provide strong consistency and fault tolerance, ensuring correctness even if latency is higher.Step 3: Assess database row locks and local locks
Database locks (C) have high latency and risk deadlocks; local locks (D) do not coordinate across nodes, failing correctness.Final Answer:
Option B -> Option BQuick Check:
Consensus ensures correctness under contention despite latency [check]
Hint: Consensus beats speed for correctness under contention [check]
Common Mistakes:
