Google Professional Cloud Developer Question 177
Single answerGoogle Cloud PlatformYou are designing a cloud-based inventory management system using Google Cloud Datastore. The application needs to handle high availability and scale globally, but it also requires that the most recently updated stock counts are immediately visible to all users. Which consistency model should you choose, and why?
- A
Eventual consistency, because it offers higher availability and scalability.
- B
Eventual consistency, because it ensures that updates are immediately visible to all users.
- C
Strong consistency, because it ensures that the most recent data is visible immediately after an update.
- D
Strong consistency, because it sacrifices availability for better cost efficiency.
Show answer and explanation
Correct answer: C
Explanation
The scenario requires that the most recently updated stock counts are immediately visible to all users, which is a characteristic of strong consistency. Eventual consistency, while suitable for applications that prioritize availability and scalability, introduces delays in propagating updates across replicas, making it unsuitable for this use case. Therefore, strong consistency is the correct choice.
- A. Incorrect.
Eventual consistency is designed for high availability and scalability, but it does not guarantee that the most recent updates are visible immediately. This makes it unsuitable for the described requirement.
- B. Incorrect.
Eventual consistency does not ensure updates are immediately visible to all users. There may be a delay before all replicas reflect the latest state.
- C. Correct.
Strong consistency ensures that the most recent data is immediately visible after an update, meeting the requirement for accurate stock counts to be visible to all users.
- D. Incorrect.
Strong consistency does not necessarily sacrifice availability for better cost efficiency. Its primary trade-off is typically reduced availability in distributed systems, not cost.