Google Professional Cloud Developer Question 178
Single answerGoogle Cloud PlatformYou are building a global e-commerce application on Google Cloud that uses Cloud Spanner as the database. The application needs to ensure that inventory updates are reflected immediately across all regions to prevent overselling of products. Which consistency model should you choose, and why?
- A
Strong consistency, because it ensures that all reads return the most recent committed data.
- B
Eventual consistency, because it allows higher availability and lower latency across regions.
- C
Eventual consistency, because it guarantees atomicity for updates across multiple regions.
- D
Strong consistency, because it supports eventual convergence of data without sacrificing performance.
Show answer and explanation
Correct answer: A
Explanation
In scenarios where immediate consistency is required, such as inventory management to prevent overselling, strong consistency is the appropriate choice. It ensures that all reads reflect the most recent committed data, which is critical for maintaining accurate and synchronized states across regions. Eventual consistency, while suitable for some use cases, would not meet the application's requirements for immediate consistency.
- A. Correct.
This is correct. Strong consistency ensures that all reads reflect the most recent committed data, which is critical for preventing issues like overselling in an application that requires immediate synchronization across regions.
- B. Incorrect.
This is incorrect. Eventual consistency does not guarantee that all regions see the most recent updates immediately, which could lead to overselling in this scenario.
- C. Incorrect.
This is incorrect. While eventual consistency can provide low-latency reads, it does not guarantee atomic updates or immediate consistency across multiple regions.
- D. Incorrect.
This is incorrect. Strong consistency ensures immediate data consistency but does not prioritize performance over consistency. Eventual consistency is the model that focuses on performance and eventual convergence.