Practice
Solution
Step 1: Identify the need for durability and ordering
Relational DB synchronous writes (Use a relational database with immediate synchronous writes for each vote) cause high latency and don't scale to 1M writes/sec. Redis without persistence (Use an in-memory cache like Redis without persistence to handle votes) risks data loss on failure. Batch processing (Use a batch processing system that aggregates votes every hour) introduces unacceptable latency.Step 2: Recognize Kafka's role
Kafka provides durable, ordered, high-throughput buffering of vote events, decoupling ingestion from processing.Final Answer:
Option D -> Option DQuick Check:
Kafka buffers high-write streams with durability and ordering [check]
Solution
Step 1: Identify the latency cause
High latency is due to repeated database reads causing load spikes, which read replicas help but still hit the database.Step 2: Recognize caching benefits
An in-memory cache like Redis serves repeated reads from memory, drastically reducing latency and database load.Final Answer:
Option A -> Option AQuick Check:
Cache serves repeated reads faster than replicas [check]
Solution
Step 1: Understand DLQ role in failure isolation
Without DLQ, failed messages remain in the main queue causing retries that block subsequent messages.Step 2: Evaluate failure outcomes
Silent drops (A) lose data; automatic routing (C) requires DLQ logic; synchronous fallback (D) is not automatic.Final Answer:
Option A -> Option AQuick Check:
No DLQ -> retries block main queue causing backpressure [check]
Solution
Step 1: Evaluate synchronous repository calls
Use a synchronous call to the code repository for every request to get the latest code causes high latency due to network and disk IO, violating 100ms budget.Step 2: Compare batch offline indexing
Use a batch offline indexing updated once a day and serve completions from cached embeddings sacrifices freshness, unsuitable for frequently changing codebases.Step 3: Assess purely generative model
Use a purely generative model without retrieval to avoid retrieval latency lacks grounding in latest code, reducing accuracy.Step 4: Identify hybrid RAG architecture
Use a hybrid RAG architecture with pre-indexed code embeddings updated periodically and a fast vector search balances freshness (periodic updates) and latency (fast vector search), meeting constraints.Final Answer:
Option D -> Option DQuick Check:
Hybrid RAG balances freshness and latency [check]
Solution
Step 1: Role of metadata service
Metadata tracks access patterns to trigger tier migration safely without data loss.Step 2: Consequence of missing metadata
Without metadata, migration workers may archive data prematurely without validation, causing permanent data loss.Final Answer:
Option D -> Option DQuick Check:
Missing metadata -> unsafe archiving -> data loss [check]
