Google Cloud Professional Cloud Architect — Question 72
You are deploying a PHP App Engine Standard service with Cloud SQL as the backend. You want to minimize the number of queries to the database.
What should you do?
Answer options
- A. Set the memcache service level to dedicated. Create a key from the hash of the query, and return database values from memcache before issuing a query to Cloud SQL.
- B. Set the memcache service level to dedicated. Create a cron task that runs every minute to populate the cache with keys containing query results.
- C. Set the memcache service level to shared. Create a cron task that runs every minute to save all expected queries to a key called ג€cached_queriesג€.
- D. Set the memcache service level to shared. Create a key called ג€cached_queriesג€, and return database values from the key before using a query to Cloud SQL.
Correct answer: A
Explanation
Option A is correct because using a dedicated memcache service and hashing the query allows for efficient retrieval of cached results, minimizing database queries. The other options either do not effectively reduce database queries or use shared memcache, which can lead to contention and less efficient caching.