Google Professional Cloud Developer Question 38
Select 2Google Cloud PlatformYou are developing an e-commerce application hosted on Google Cloud and notice high latency when retrieving product details from your Cloud SQL database. To address this issue, you decide to implement a caching solution. Which of the following approaches would effectively reduce latency while ensuring cache invalidation when product details are updated?
- A
Use Cloud Memorystore to cache product details and implement a cache invalidation mechanism triggered by database update events.
- B
Implement a global in-memory cache within your application hosted on Compute Engine instances to store product details.
- C
Use Cloud CDN to cache product details stored in Cloud SQL.
- D
Use Cloud Spanner’s built-in caching for product details to avoid using an external cache.
- E
Cache product details in Cloud Storage and update the cached file whenever the database is updated.
Show answer and explanation
Correct answers: A, E
Explanation
To reduce database query latency, using a caching solution such as Cloud Memorystore or caching files in Cloud Storage can be effective. Both options allow data to be retrieved quickly while maintaining consistency when updates occur by invalidating or updating the cache. Other options, such as in-memory caches on Compute Engine instances or using services not designed for this purpose (e.g., Cloud CDN or Cloud Spanner), are less optimal or unfeasible for this scenario.
- A. Correct.
This is a correct option. Cloud Memorystore is a managed Redis or Memcached service that provides low-latency caching. By implementing a cache invalidation mechanism triggered by database updates, you can ensure the cache remains consistent with the database.
- B. Incorrect.
This option is not ideal as using an in-memory cache on individual Compute Engine instances can lead to data inconsistency and is not scalable. It is better to use a managed and centralized caching solution.
- C. Incorrect.
Cloud CDN is designed to cache static content served by HTTP(S) load balancers. It is not suitable for caching product details stored in a database.
- D. Incorrect.
Cloud Spanner does not have built-in caching mechanisms for application-level data like product details. You would still need an external caching solution for this use case.
- E. Correct.
This is a correct option. Storing product details in Cloud Storage as cached files and updating them upon database changes is a valid approach. This ensures that the cache remains consistent and provides low-latency access to product details.