Bird
0
0

Which approach best balances scalability and correctness?

hard📝 Trade-off Q15 of 15
Microservices - Event-Driven Architecture
You design a microservice that consumes events from a message queue. To ensure idempotency, you decide to store processed event IDs in a database. Which approach best balances scalability and correctness?
AStore event IDs in a centralized database with unique constraints
BStore event IDs in a local in-memory cache only
CIgnore event IDs and rely on message queue retries
DProcess events multiple times and fix duplicates later
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate local cache approach

    Local cache is fast but not shared across instances, causing duplicates in distributed systems.
  2. Step 2: Evaluate centralized DB with unique constraints

    A centralized database with unique event ID constraints ensures correctness and scales with proper design.
  3. Step 3: Evaluate ignoring IDs or fixing later

    Ignoring IDs or fixing duplicates later risks data inconsistency and is not reliable.
  4. Final Answer:

    Store event IDs in a centralized database with unique constraints -> Option A
  5. Quick Check:

    Central DB + unique IDs = scalable correctness [OK]
Quick Trick: Use centralized DB with unique keys for idempotency [OK]
Common Mistakes:
MISTAKES
  • Using only local cache in distributed systems
  • Ignoring event IDs completely
  • Accepting duplicates to fix later

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes