Practice
Solution
Step 1: Identify failover requirements
Zero downtime and immediate failover require both sites to be active and data synchronized synchronously to avoid data loss.Step 2: Evaluate options
Active-Active with synchronous replication ensures both data centers serve traffic simultaneously and failover is automatic without data loss.Final Answer:
Option A -> Option AQuick Check:
Active-Active with sync replication -> zero downtime and instant failover [check]
Solution
Step 1: Identify decoupling need
Immediate consistency via relational DB (A relational database with strong ACID transactions for immediate consistency) blocks on writes, causing latency spikes. In-memory cache (An in-memory cache with TTL eviction to buffer incoming orders) lacks durability and ordering guarantees. API gateway throttling (A REST API gateway that throttles requests to downstream services) limits throughput but doesn't decouple processing.Step 2: Durable queue with partitioning
A distributed message queue (A distributed message queue with partitioning and durable storage) buffers spikes, partitions workload, and guarantees durability, enabling asynchronous downstream processing.Final Answer:
Option C -> Option CQuick Check:
Distributed queue partitions spikes, ensures durability, decouples processing [check]
Solution
Step 1: Understand Kafka's role in event streaming
Kafka streams photo upload events to downstream processors like metadata extraction and feed generation.Step 2: Trace failure impact
If Kafka is down, photo uploads still succeed because upload service writes to storage directly. Feed generation depends on Kafka events for stories update; without Kafka, stories updates stop, but feed generation for photos continues from DB. Metadata extraction is delayed but not necessarily indefinite. Notifications are handled separately.Final Answer:
Option B -> Option BQuick Check:
Kafka outage stops stories update but feed photo generation continues [check]
Solution
Step 1: Analyze consistency and throughput needs
Strong write consistency with high read throughput favors CQRS separating write/read models.Step 2: Evaluate options
Use asynchronous replication with eventual consistency on read replicas sacrifices strong consistency; Use synchronous replication with read replicas and route reads only to replicas after commit synchronous replication slows writes; Use a single primary database with aggressive caching on the client side risks stale cache and write bottleneck.Final Answer:
Option A -> Option AQuick Check:
CQRS separates concerns, enabling strong writes and scalable reads [check]
Solution
Step 1: Identify scaling bottlenecks
Blue-Green requires two full environments; load balancer scales horizontally; feature flags scale independently.Step 2: Analyze deployment pipeline
Build servers face 10x concurrent builds, causing queueing and delays, blocking releases.Step 3: Compare other components
Load balancer and feature flags can be sharded; doubling environment cost is expensive but not a failure.Final Answer:
Option A -> Option AQuick Check:
Build servers bottleneck at 10x concurrent builds, delaying deployments [check]
