Practice
Solution
Step 1: Identify Kafka's role in decoupling ingestion and delivery
Kafka partitions by conversation ID ensure ordering per conversation and durability via replication.Step 2: Eliminate other options
Redis pub/sub lacks durability and ordering guarantees; relational DBs can't handle 1M writes/sec with locking overhead; in-memory queues lack durability and don't scale across servers.Final Answer:
Option A -> Option AQuick Check:
Kafka with conversation_id partition -> ordering within conversation guaranteed [check]
Solution
Step 1: Trace cache behavior on miss at step 4
On a cache miss, the cache should fetch fresh data from the backend to serve the request.Step 2: Confirm cache updates itself before responding
This ensures subsequent requests hit the cache, reducing latency and load on backend.Final Answer:
Option D -> Option DQuick Check:
Cache miss triggers backend fetch and cache update [check]
Solution
Step 1: Trace Request Handler token check at Step 4
If the token bucket is empty, no tokens are available to allow immediate processing.Step 2: Determine request fate
The request must be rejected or delayed until tokens refill; processing without tokens violates rate limits.Final Answer:
Option C -> Option CQuick Check:
Empty bucket -> reject or delay request [check]
Solution
Step 1: Trace Kafka's role in order processing
Kafka decouples order acceptance from inventory update; if Kafka is down, inventory update messages are lost or not sent.Step 2: Analyze failure impact
API layer (B) uses async calls, so requests don't block. Payment retries (D) are independent. Accepting orders without inventory update (C) causes overselling.Final Answer:
Option D -> Option DQuick Check:
Kafka down -> inventory updates lost -> overselling risk [check]
Solution
Step 1: Identify stateful components under load
API Gateway maintains user session state (e.g., WebSocket connections), which are sticky and stateful, limiting horizontal scaling.Step 2: Compare other components
Relational DB (A) can be sharded; cache (C) TTL floods are mitigated by pre-warming; inventory locking (D) is optimized with partitioning. API Gateway statefulness causes connection limits and bottlenecks first.Final Answer:
Option B -> Option BQuick Check:
API Gateway stateful sessions limit horizontal scaling [check]
