CS FundamentalsVery hardProduct-company system-design interview

An order service and a payment service each own their database. Placing an order must reserve stock, charge the card and create the order, or undo everything. Which approach fits a microservice architecture?

  1. A. A saga: a sequence of local transactions, each with a compensating action (e.g. refund, release stock) if a later step fails
  2. B. A single ACID transaction spanning both databases through a shared connection
  3. C. Merge the services back into one shared database table
  4. D. Skip consistency because microservices are eventually consistent anyway

Correct answer: A. A saga: a sequence of local transactions, each with a compensating action (e.g. refund, release stock) if a later step fails

Database-per-service rules out cross-service locks. Sagas (choreographed by events or orchestrated) restore consistency through compensation, accepting brief intermediate states.

More Software Engineering, Git and Cloud Basics questions

Exams that ask this topic