If distributed transactions are not feasible, which pattern helps maintain consistency across services?

Prepare for the FAST Enterprises IC Interview. Enhance your skills with flashcards and multiple-choice questions. Each question provides hints and detailed explanations. Excel in your interview!

Multiple Choice

If distributed transactions are not feasible, which pattern helps maintain consistency across services?

Explanation:
When distributed transactions aren’t feasible, coordinating updates across services becomes challenging. Global locking across services or forcing immediate strong consistency with synchronous commits would require distributed ACID-style coordination, which severely hurts scalability and availability in a microservices setup. Ignoring cross-service consistency would leave the system in a brittle, inconsistent state whenever a partial failure occurs. The pattern that fits this situation is eventual consistency with conflict resolution and sagas. In a saga, each service performs its local transaction and records the outcome, while a central orchestrator or a set of coordinated events handles the next steps. If something later fails, compensating actions are triggered to undo or offset earlier steps, guiding the system toward a consistent state over time. This approach lets services evolve independently, keeps latency reasonable, and provides a resilient way to recover from partial failures. For example, in an order process, one service might reserve inventory while another processes payment. If the payment fails after inventory is reserved, a saga would trigger a compensating action to release the inventory. Over time, all parts of the system converge to a consistent outcome without locking resources across services.

When distributed transactions aren’t feasible, coordinating updates across services becomes challenging. Global locking across services or forcing immediate strong consistency with synchronous commits would require distributed ACID-style coordination, which severely hurts scalability and availability in a microservices setup. Ignoring cross-service consistency would leave the system in a brittle, inconsistent state whenever a partial failure occurs.

The pattern that fits this situation is eventual consistency with conflict resolution and sagas. In a saga, each service performs its local transaction and records the outcome, while a central orchestrator or a set of coordinated events handles the next steps. If something later fails, compensating actions are triggered to undo or offset earlier steps, guiding the system toward a consistent state over time. This approach lets services evolve independently, keeps latency reasonable, and provides a resilient way to recover from partial failures.

For example, in an order process, one service might reserve inventory while another processes payment. If the payment fails after inventory is reserved, a saga would trigger a compensating action to release the inventory. Over time, all parts of the system converge to a consistent outcome without locking resources across services.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy