
Explanation:
The correct approach is to use inter-process signals (Option A) because preemptible VMs provide a 30-second window before shutdown. A shutdown script can send a signal (e.g., SIGTERM) to the application process, which can then handle it by disconnecting from the database gracefully. Options B and C are unsuitable as they involve user notifications or polling intervals longer than the shutdown window. Option D is unreliable because the application may not process the Pub/Sub message before termination. Signal handling (A) ensures immediate and direct notification to the application.
Ultimate access to all questions.
No comments yet.
You are developing an application that subscribes to a single Pub/Sub topic and inserts corresponding rows into a database. The application runs on Linux using preemptible VMs to minimize costs. How should you design a shutdown script to ensure a graceful shutdown?
A
Write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database.
B
Write a shutdown script that broadcasts a message to all signed-in users that the Compute Engine instance is going down and instructs them to save current work and sign out.
C
Write a shutdown script that writes a file in a location that is being polled by the application once every five minutes. After the file is read, the application disconnects from the database.
D
Write a shutdown script that publishes a message to the Pub/Sub topic announcing that a shutdown is in progress. After the application reads the message, it disconnects from the database.