Bird
0
0

You design a microservice system where orders are created and inventory is updated asynchronously. How do you ensure inventory is never oversold despite eventual consistency?

hard📝 Trade-off Q8 of 15
Microservices - Event-Driven Architecture
You design a microservice system where orders are created and inventory is updated asynchronously. How do you ensure inventory is never oversold despite eventual consistency?
AAllow orders without checking inventory and fix later
BUse distributed locks to reserve inventory before order creation
CUpdate inventory synchronously in the order service
DIgnore inventory updates to speed up processing
Step-by-Step Solution
Solution:
  1. Step 1: Identify the risk of overselling

    Asynchronous updates can cause race conditions leading to overselling inventory.
  2. Step 2: Apply a solution to prevent overselling

    Distributed locks can reserve inventory before order creation, preventing conflicts.
  3. Final Answer:

    Use distributed locks to reserve inventory before order creation -> Option B
  4. Quick Check:

    Distributed locks prevent overselling in async systems [OK]
Quick Trick: Reserve inventory with locks before async order creation [OK]
Common Mistakes:
MISTAKES
  • Ignoring inventory checks
  • Relying on synchronous updates only
  • Allowing overselling to fix later

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes