Eventual Consistency Concept
What does 'eventual consistency' mean in the context of microservices architecture?
- All services will become consistent over time, given no new updates.
- All data must be consistent immediately across all services.
- Consistency only applies to transactional databases.
- Services that are down will lose data.
- All data updates are sent in real time to every service instantly.
Database Per Service Pattern
Which statement best describes the 'Database per Service' design pattern in microservices?
- Each microservice manages its own database to encapsulate data and avoid direct cross-service database access.
- All microservices share a single, central monolithic database.
- Data is directly replicated between all microservices in real time.
- Only read operations are allowed across service databases.
- Microservices can freely join tables from each other's databases.
Challenges with Shared Databases
What is a primary disadvantage of using a shared database across multiple microservices?
- It increases service coupling and complicates data ownership.
- It improves scalability and independence of microservices.
- It enforces strong data consistency at service boundaries.
- It simplifies deployment pipelines and continuous delivery.
- It avoids the need for synchronization mechanisms.
SAGA Pattern Scenario
In a SAGA pattern, how are distributed transactions handled among microservices?
- By using a series of local transactions, each followed by a compensating action if a failure occurs.
- By utilizing a two-phase commit protocol for guaranteed consistency.
- By executing all actions sequentially without compensation steps.
- Through synchronous HTTP calls with global locks.
- By sharing a single monolithic transactional database.
Synchronizing Data Changes
Which technique is commonly used to synchronize data changes between microservices?
- Publishing domain events through a message broker for eventual update propagation.
- Directly updating both databases using cross-service SQL JOINs.
- Allowing services to poll each other's databases for updates.
- Enabling direct remote table access using ORM tools.
- Sharing the same database tables among all services.
Choosing Strong Consistency
When is strong consistency preferred over eventual consistency between microservices?
- When correctness of distributed operations is critical, such as money transfers.
- When minimizing network latency is the only requirement.
- When each service works with completely isolated data.
- When the system does not require ACID guarantees.
- When using NoSQL databases exclusively.
CQRS Pattern Usage
How does the Command Query Responsibility Segregation (CQRS) pattern help in microservice data management?
- It separates read and write models, making it easier to handle data synchronization and scalability.
- It enforces strict data consistency between all services.
- It replaces the need for service-to-service communication.
- It prevents any form of eventual consistency.
- It allows direct table writes from external APIs.
Event Replay for Recovery
Why would a microservice use event replay from a message log when recovering from a crash?
- To rebuild its state to match the most recent changes from other services.
- To synchronize all databases to the primary node.
- To perform a hard reset and ignore all previous transactions.
- To merge all data into a monolithic schema.
- To avoid using any compensating transactions.
Handling Out-of-Order Events
What issue can arise with event-driven data synchronization between microservices, and how is it commonly addressed?
- Events arriving out of order, usually handled with versioning or timestamps.
- Overloading the database, solved by horizontal scaling.
- Duplicate services, fixed by introducing global transactions.
- Loss of schema, addressed by using message brokers only.
- Instant global consistency, managed by removing asynchrony.
Read Models for Data Sharing
How do microservices typically expose data for queries by other services while maintaining database per service?
- By publishing read models or materialized views through APIs or events.
- By allowing direct database connections from all consumers.
- By using shared database tables for all queries.
- By embedding all data in service URLs.
- By using spreadsheets for synchronization.