Google Cloud Professional Cloud Developer — Question 80

You are designing an application that will subscribe to and receive messages from a single Pub/Sub topic and insert corresponding rows into a database. Your application runs on Linux and leverages preemptible virtual machines to reduce costs. You need to create a shutdown script that will initiate a graceful shutdown.
What should you do?

Answer options

Correct answer: A

Explanation

The correct answer is A because using inter-process signals allows the application to receive a direct notification to gracefully disconnect from the database, ensuring that any ongoing transactions are completed. Option B is not effective for application processes and only informs users. Option C introduces unnecessary polling and delays, making the shutdown less efficient. Option D, while it communicates shutdown, relies on the application to read the message, which may not ensure prompt disconnection.