Google Professional Cloud Developer Question 179
Single answerGoogle Cloud PlatformYou are developing a distributed application on Google Cloud using Cloud Spanner as the database. The application processes customer orders and updates inventory levels. For inventory updates, it is critical that the most recent data is always read to avoid overselling products. Which consistency model should you choose for reading inventory data?
- A
Strong consistency
- B
Eventual consistency
- C
Transactional consistency
- D
Causal consistency
Show answer and explanation
Correct answer: A
Explanation
Strong consistency is the appropriate choice for applications that require reading the most up-to-date data, such as inventory management in an e-commerce application. This ensures that decisions are always made based on the most accurate and recent state of the database, avoiding issues like overselling products. Eventual consistency, while faster, risks returning stale data, which would not be acceptable in this scenario.
- A. Correct.
Strong consistency ensures that the most recent data is always read, making it suitable for scenarios where data accuracy is critical, such as inventory management.
- B. Incorrect.
Eventual consistency allows for faster reads but does not guarantee the most recent data will be returned, which can lead to overselling in this use case.
- C. Incorrect.
Transactional consistency is not a recognized consistency model in Google Cloud. It may refer to the ACID guarantees of transactions, but it is not the correct term for this scenario.
- D. Incorrect.
Causal consistency ensures that related operations are processed in the correct order, but it does not guarantee the most recent data will be read. This is not suitable for critical real-time data requirements like inventory updates.