Two-Phase Commit (2PC) Limitations
What is a primary limitation of using the Two-Phase Commit (2PC) protocol for transactions across microservices?
- It guarantees eventual consistency in all scenarios.
- It introduces tight coupling between services, hindering independent deployments.
- It eliminates the need for compensating transactions.
- It supports asynchronous communication seamlessly.
- It offers built-in scalability and performance optimization.
Eventual Consistency and Data Loss
In a microservices architecture relying on eventual consistency, what is a potential risk that developers must carefully mitigate?
- Data is always consistent across all services.
- Complete data loss is impossible with event sourcing.
- Temporary inconsistencies may occur, requiring strategies to handle them.
- Transactions are always ACID compliant.
- Services can only be updated via direct database modifications.
Saga Pattern - Definition
Which of the following best describes the Saga pattern for managing transactions across microservices?
- A centralized transaction manager coordinating all service operations.
- A sequence of local transactions, each updating a single service, with compensating transactions to undo previous operations if needed.
- A distributed cache that guarantees data consistency.
- A message queue used to ensure transactional message delivery.
- A read-only replica of a database optimized for reporting.
Choreography vs. Orchestration - Sagas
When implementing Sagas, what is the key difference between choreography and orchestration?
- Choreography requires a central coordinator, while orchestration relies on individual services communicating directly.
- Orchestration relies on asynchronous message queues, while choreography uses synchronous API calls.
- Choreography defines the workflow in a central orchestrator, while orchestration relies on each service knowing when to act based on events.
- Orchestration defines the workflow in a central orchestrator, while choreography relies on each service knowing when to act based on events.
- Both are the same thing, just named differently.
Compensation Transactions
What is the purpose of a compensation transaction in a Saga pattern?
- To permanently delete data from all services.
- To reverse the effects of a previously completed local transaction in case of failure.
- To apply updates to multiple services simultaneously.
- To guarantee ACID properties across all services involved in the Saga.
- To improve the read performance of the system.
Outbox Pattern
What problem does the Outbox Pattern solve in the context of microservices data consistency?
- Ensuring data is written to multiple databases simultaneously.
- Guaranteeing that events are reliably published after a database transaction commits.
- Preventing unauthorized access to sensitive data.
- Optimizing the read performance of a database.
- Simplifying the deployment process of microservices.
Idempotency Key Importance
Why is idempotency important when designing compensating transactions or event handlers in microservices?
- To ensure that transactions always succeed.
- To prevent a single operation from being executed multiple times, leading to unintended side effects.
- To reduce the amount of data transferred between services.
- To improve the performance of database queries.
- To simplify the monitoring of microservices.
BASE vs. ACID
Which set of properties does the acronym BASE represent, in contrast to ACID, in the context of distributed systems and microservices?
- Basic Availability, Soft state, Eventual consistency
- Begin, Abort, Soft, End
- Basic, Application, Service, Endpoint
- Bottom, Architecture, Scale, Efficiency
- Binary, Asynchronous, Simple, Extensible
Handling Conflicts in Eventual Consistency
What strategies can be employed to handle conflicting updates in a microservices system using eventual consistency?
- Rollback all transactions to a previous state.
- Last-write-wins, optimistic locking, or conflict resolution algorithms.
- Prevent updates from occurring concurrently.
- Force all services to use the same database.
- Disable eventual consistency and use ACID transactions everywhere.
Distributed Lock Implementations
Which technology is commonly used to implement distributed locks for coordinating access to shared resources across microservices?
- Local JVM locks
- Redis, ZooKeeper, or etcd
- Operating System file locks
- Web browser cookies
- Compile time code analysis