Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Professional Cloud Developer All Questions

View all questions & answers for the Professional Cloud Developer exam

Exam Professional Cloud Developer topic 1 question 89 discussion

Actual exam question from Google's Professional Cloud Developer
Question #: 89
Topic #: 1
[All Professional Cloud Developer Questions]

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?

  • 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.
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
GCPCloudArchitectUser
Highly Voted 2 years, 9 months ago
Selected Answer: A
IMO it should be A
upvoted 7 times
...
JonathanSJ
Highly Voted 2 years, 11 months ago
I vote A
upvoted 5 times
...
thewalker
Most Recent 4 months, 1 week ago
Selected Answer: A
The best answer is A. Write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database. Here's why: Inter-process Signals: Signals are a standard mechanism in Unix-like systems for communicating between processes. They are a reliable and efficient way to notify the application process that a shutdown is imminent. Graceful Shutdown: Using signals allows the application to gracefully disconnect from the database, ensuring data integrity and preventing potential data loss. The application can handle the signal, perform necessary cleanup tasks, and then exit gracefully.
upvoted 2 times
thewalker
4 months, 1 week ago
Let's analyze why the other options are less suitable: B. Broadcast message to users: This approach is not a reliable way to initiate a graceful shutdown. It relies on user interaction and might not be effective if users are not actively using the application. C. Write a file for polling: This approach is less efficient and introduces a delay. The application needs to poll the file every five minutes, which can introduce latency and might not be timely enough for a graceful shutdown. D. Publish a message to the Pub/Sub topic: This approach is not ideal because it introduces additional complexity and relies on the application's ability to process messages from the same topic it's subscribing to. It also might not be a reliable way to ensure a timely shutdown.
upvoted 2 times
...
...
santoshchauhan
8 months, 3 weeks ago
Selected Answer: A
A. Write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database. In the scenario of using preemptible virtual machines for running an application that interacts with a database, a graceful shutdown is essential to ensure data consistency and prevent potential issues like incomplete transactions. A shutdown script utilizing inter-process signals is an efficient and direct way to manage this process.
upvoted 1 times
...
wanrltw
1 year ago
Selected Answer: A
I vote A: - https://cloud.google.com/compute/docs/instances/preemptible#preemption - https://cloud.google.com/compute/docs/shutdownscript Option D is not good as we only have a SINGLE pub/sub topic that is also receiving other messages. I wouldn't rely on the new (shutdown) message to come through and be read by the app timely to disconnect from the db.
upvoted 1 times
...
braska
1 year ago
Selected Answer: D
Option D is a suitable approach for initiating a graceful shutdown in a scenario where the application needs to receive a notification to disconnect from the database before the virtual machine is preempted. Here's how the process works:
upvoted 1 times
braska
1 year ago
Shutdown Script: Write a shutdown script that is executed when the instance is being preempted. Publish a Message to Pub/Sub: In the shutdown script, publish a message to the Pub/Sub topic, indicating that a shutdown is in progress. This message serves as a notification to the application. Application Subscription: The application subscribes to the Pub/Sub topic and continuously listens for incoming messages
upvoted 1 times
...
braska
1 year ago
Graceful Shutdown: When the application receives the shutdown message from Pub/Sub, it initiates a graceful shutdown, including disconnecting from the database.
upvoted 1 times
...
Aeglas
1 year ago
You have only one topic, so if there are multiple messages in the queue before the one announcing the disconnect, then a lot of time can pass before the retrival of the message
upvoted 1 times
...
...
__rajan__
1 year, 2 months ago
Selected Answer: A
I will go with A
upvoted 1 times
...
maxdanny
1 year, 3 months ago
Selected Answer: A
https://cloud.google.com/compute/docs/instances/preemptible#preemption
upvoted 1 times
...
omermahgoub
1 year, 10 months ago
It's A To handle the preemption notice and initiate a graceful shutdown, you should write a shutdown script that uses inter-process signals to notify the application process to disconnect from the database. The application can then initiate a graceful shutdown by completing any in-progress tasks and disconnecting from the database, ensuring that data is not lost or corrupted during the shutdown process. This is the most reliable method for initiating a graceful shutdown in response to a preemption notice, as it allows the application to respond directly to the signal and initiate the shutdown process.
upvoted 2 times
omermahgoub
1 year, 10 months ago
Option B, broadcasting a message to signed-in users and instructing them to save current work and sign out, is not relevant to the shutdown process of the application. Option C, writing a file in a location that is being polled by the application, is not a reliable method for initiating a graceful shutdown because the application may not read the file in a timely manner. Option D, publishing a message to the Pub/Sub topic announcing that a shutdown is in progress, is not a reliable method for initiating a graceful shutdown because the application may not read the message in a timely manner.
upvoted 1 times
...
...
tomato123
2 years, 3 months ago
Selected Answer: A
A is correct
upvoted 2 times
...
GossipDolphin
2 years, 4 months ago
it's A Compute Engine sends a preemption notice to the instance in the form of an ACPI G2 Soft Off signal. You can use a shutdown script to handle the preemption notice and complete cleanup actions before the instance stops. https://cloud.google.com/compute/docs/instances/preemptible#preemption
upvoted 1 times
...
szl0144
2 years, 6 months ago
A seems correct, guys
upvoted 2 times
...
dishum
2 years, 8 months ago
Looks like D
upvoted 2 times
...
p4
2 years, 10 months ago
C does not make sense, because you don't know when pub sub message will be consumed (there might other events be in the queue before), so I'll go with option A
upvoted 1 times
...
ParagSanyashiv
2 years, 10 months ago
According to me , it should be D
upvoted 2 times
ParagSanyashiv
2 years, 10 months ago
Because for preemptible instances the script should run within 30 seconds of the instance being shutdown or restarted, in this case a pub sub trigger would be faster to perform.
upvoted 2 times
...
morenocasado
2 years, 7 months ago
The issue with option D is that we have a SINGLE PubSub topic that is used to send the rows to be inserted; sending a completely different message seems wrong.
upvoted 2 times
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...