nerdexam
Google

PROFESSIONAL-CLOUD-DEVELOPER · Question #106

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…

The correct answer is A. Write a shutdown script that uses inter-process signals to notify the application process to. Using inter-process signals (such as SIGTERM) to notify the application process to stop is the correct approach for graceful shutdown. When a preemptible VM is preempted, GCP sends a shutdown signal and the instance has approximately 30 seconds to complete cleanup. The shutdown…

Designing and Building Applications

Question

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?

Options

  • AWrite a shutdown script that uses inter-process signals to notify the application process to
  • BWrite a shutdown script that broadcasts a message to all signed-in users that the Compute
  • CWrite a shutdown script that writes a file in a location that is being polled by the application once
  • DWrite a shutdown script that publishes a message to the Pub/Sub topic announcing that a

How the community answered

(26 responses)
  • A
    81% (21)
  • B
    12% (3)
  • C
    4% (1)
  • D
    4% (1)

Explanation

Using inter-process signals (such as SIGTERM) to notify the application process to stop is the correct approach for graceful shutdown. When a preemptible VM is preempted, GCP sends a shutdown signal and the instance has approximately 30 seconds to complete cleanup. The shutdown script should send a signal (SIGTERM) to the running application, which should catch it, finish processing any in-flight Pub/Sub message, acknowledge it, and then exit cleanly to avoid message loss or duplicate processing. Option B (broadcasting to users) is irrelevant and doesn't help the application shut down cleanly. Option C (writing a file polled by the application) introduces unnecessary latency and polling overhead within an already short shutdown window. Option D (publishing to Pub/Sub) is unreliable - the network may not be available during shutdown, and this doesn't directly stop the application process.

Topics

#Graceful Shutdown#Preemptible VMs#Linux Signals#Application Resiliency

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-CLOUD-DEVELOPER Practice