Google Cloud Professional Cloud Architect — Question 248
You have a Compute Engine managed instance group that adds and removes Compute Engine instances from the group in response to the load on your application. The instances have a shutdown script that removes REDIS database entries associated with the instance. You see that many database entries have not been removed, and you suspect that the shutdown script is the problem. You need to ensure that the commands in the shutdown script are run reliably every time an instance is shut down. You create a Cloud Function to remove the database entries. What should you do next?
Answer options
- A. Modify the shutdown script to wait for 30 seconds before triggering the Cloud Function.
- B. Do not use the Cloud Function. Modify the shutdown script to restart if it has not completed in 30 seconds.
- C. Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging.
- D. Modify the shutdown script to wait for 30 seconds and then publish a message to a Pub/Sub queue.
Correct answer: C
Explanation
The correct answer is C because setting up a Cloud Monitoring sink allows the Cloud Function to be triggered reliably based on the instance removal log, ensuring the database entries are removed after the instance is shut down. Options A and D introduce a delay or send a message without guaranteeing execution, while option B does not utilize the Cloud Function at all, making it less effective for reliable execution.