Google Professional Cloud Architect

Google Professional Cloud Architect

Get started today

Ultimate access to all questions.


You have a Compute Engine managed instance group that dynamically scales by adding and removing Compute Engine instances based on the load on your application. Each instance in this group runs a shutdown script intended to clean up by removing REDIS database entries associated with that instance when it is terminated. However, you've noticed that many of these database entries remain uncleared, suggesting that the shutdown script isn't reliably executing. To address this, you decide to use a Cloud Function to handle the removal of the database entries. What should you do next to ensure that the database clean-up is performed reliably every time an instance is shut down?




Explanation:

The correct answer is C: Set up a Cloud Monitoring sink that triggers the Cloud Function after an instance removal log message arrives in Cloud Logging. This method ensures that the Cloud Function is triggered reliably when an instance is shut down. Relying on the shutdown script alone is not recommended because shutdown scripts are executed on a best-effort basis in Compute Engine, which cannot guarantee that they will complete. By setting up a Cloud Monitoring sink to trigger the Cloud Function upon the instance removal log message, you eliminate the dependency on the successful execution of the shutdown script, ensuring that your database clean-up tasks are performed consistently.