Google Professional Cloud Developer Question 458
Single answerGoogle Cloud PlatformYou are developing a web application hosted on Google Cloud that frequently fetches product catalog data from a Cloud SQL database. To improve performance and reduce database load, you decide to introduce caching. Which approach should you take to implement caching effectively while ensuring data consistency and scalability?
- A
Use Memorystore for Redis to cache the product catalog data and configure a TTL (Time-To-Live) for cache expiration.
- B
Store product catalog data in a local in-memory cache on the application server.
- C
Use a global variable in your application code to cache the product catalog data.
- D
Replicate the product catalog data into a separate Cloud SQL instance for faster access.
Show answer and explanation
Correct answer: A
Explanation
Caching frequently accessed data, like a product catalog, improves performance and reduces load on the database. Memorystore for Redis is a managed and scalable caching solution in Google Cloud that supports features such as TTL for cache expiration and consistency across distributed systems. Local or application-specific caching methods are not suitable for scalable cloud applications, and replicating the database does not address the primary goal of reducing query latency.
- A. Correct.
This is the correct answer. Memorystore for Redis is a managed caching service provided by Google Cloud, designed for low-latency and scalable caching. Configuring TTL ensures that stale data is eventually evicted and replaced with fresh data.
- B. Incorrect.
This is incorrect because local in-memory caching on the application server is not scalable in a distributed environment and could lead to inconsistent cache states across multiple instances.
- C. Incorrect.
This is incorrect because global variables are not designed for caching and do not provide scalability or data consistency in a cloud environment.
- D. Incorrect.
This is incorrect because replicating data to a separate Cloud SQL instance does not solve the problem of high latency or reduce database load significantly. Caching should be used instead for performance optimization.