Practice
Solution
Step 1: Identify prefix lookup requirements
Prefix queries require fast, low-latency lookups optimized for string prefixes, which relational DB LIKE queries are inefficient at scale.Step 2: Evaluate component suitability
A distributed in-memory Trie cache supports efficient prefix matching and can be sharded by prefix hash for scalability, unlike message queues or full-text search without caching.Final Answer:
Option A -> Option AQuick Check:
Distributed Trie cache -> efficient prefix lookups at scale [check]
Solution
Step 1: Understand traffic variability
Clients open varying numbers of connections, so servers can become unevenly loaded if requests are assigned blindly.Step 2: Evaluate load balancing algorithms
Round Robin ignores current load, IP Hash pins clients to servers (may cause imbalance), Weighted Round Robin uses static weights ignoring dynamic load. Least Connections dynamically balances based on active connections.Final Answer:
Option D -> Option DQuick Check:
Least Connections adapts to real-time load, balancing uneven client connections [check]
Solution
Step 1: Identify the need for decoupling high write throughput from delivery
Relational DB with synchronous writes (A relational database with synchronous writes and triggers for fan-out) blocks on writes and triggers, unsuitable for 1M writes/sec. REST API synchronous calls (A REST API that synchronously calls each subscriber endpoint) block sender and don't scale to millions of subscribers. Redis (An in-memory cache like Redis without persistence) lacks durability and persistence, risking data loss.Step 2: Recognize Kafka's partitioned topics enable high throughput and fan-out
Kafka partitions allow parallel writes and ordered delivery per partition, decoupling producers and consumers efficiently.Final Answer:
Option D -> Option DQuick Check:
Kafka partitions -> high throughput + durable fan-out [check]
Solution
Step 1: Analyze component scalability
Search clusters (A) scale horizontally with sharding; Kafka (C) can increase partitions; user DB (D) can be sharded or use multi-master.Step 2: Stateful feed generation bottleneck
Feed generation maintains per-user session caches and WebSocket connections, which are stateful and tied to specific servers, limiting horizontal scaling and causing early failure.Final Answer:
Option C -> Option CQuick Check:
Stateful feed caches block horizontal scaling, causing first failure [check]
Solution
Step 1: Identify stateful components in REST API architecture
API Gateway maintaining in-memory sessions is stateful and tied to client connections.Step 2: Understand scaling impact of statefulness
Stateful session storage prevents easy horizontal scaling; new servers can't share session state, causing bottlenecks.Step 3: Compare with other components
Load balancers handle stateless TCP connections; databases and caches can be sharded or scaled differently.Final Answer:
Option C -> Option CQuick Check:
Stateful API Gateway sessions block horizontal scaling first [check]
