Google Professional Cloud Developer Question 175
Single answerGoogle Cloud PlatformYou are designing a cloud-native application on Google Cloud that processes inventory updates from multiple regions. The application must ensure that when a product's stock level is updated, the latest value is always read immediately, regardless of the region where the update occurred. Which consistency model should you choose for your database, and why?
- A
Strong consistency, because it ensures that the most recent write is always visible to all reads.
- B
Eventual consistency, because it provides lower latency and is sufficient for all real-time applications.
- C
Eventual consistency, because it guarantees that updates will eventually propagate to all replicas, making it suitable for stock updates.
- D
Strong consistency, because it minimizes latency by immediately distributing updates across all replicas.
Show answer and explanation
Correct answer: A
Explanation
In this scenario, the application requires that the latest stock level is always read immediately, regardless of the region. This requirement aligns with the strong consistency model, which ensures that all reads reflect the most recent write. Eventual consistency, on the other hand, could result in outdated stock levels being read due to the delay in propagating updates across replicas.
- A. Correct.
Strong consistency ensures that every read reflects the most recent write, which is critical for scenarios like inventory management where the latest stock level must be accurate.
- B. Incorrect.
Eventual consistency may provide lower latency but cannot guarantee that all reads will reflect the latest write immediately. This could lead to inconsistent stock levels being read in different regions.
- C. Incorrect.
While eventual consistency guarantees eventual propagation of updates, it does not meet the requirement to always read the most recent write immediately, which is necessary for the given scenario.
- D. Incorrect.
Strong consistency does not minimize latency. In fact, it may introduce higher latency compared to eventual consistency due to the need to synchronize across replicas before confirming a write.