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?
- A. A saga: a sequence of local transactions, each with a compensating action (e.g. refund, release stock) if a later step fails
- B. A single ACID transaction spanning both databases through a shared connection
- C. Merge the services back into one shared database table
- 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.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- A circuit breaker protecting calls to a slow service has three states. Which sequence is correct?
- A Kubernetes pod takes 60 seconds to warm its cache after start-up. During that time it should get no traffic but must not be restarted…
- A CI workflow uses a build matrix of 3 operating systems x 4 language versions, with 2 specific combinations excluded. How many jobs run…
- Which pairing of security testing approaches is correct?
- A team uses Terraform. Someone changes a security-group rule by hand in the cloud console. What is this called, and what happens at the…
- How many of these are among the four DORA key metrics of software delivery performance: (1) deployment frequency, (2) lead time for…