Google Professional Cloud Developer Question 78
Select 3Google Cloud PlatformYou are developing a serverless application on Google Cloud using Cloud Functions. The application processes incoming HTTP requests and interacts with a Cloud Pub/Sub topic for asynchronous processing. During peak traffic, you notice intermittent failures in publishing messages to the Pub/Sub topic due to rate limits. How should you design your Cloud Function to gracefully handle these failures and ensure message delivery?
- A
Implement exponential backoff with retries for failed Pub/Sub publishing attempts.
- B
Log the failed messages to Cloud Logging for future manual processing.
- C
Store failed messages in a Cloud Storage bucket and create a scheduled batch job to reprocess them.
- D
Ignore the error and rely on Pub/Sub's retry mechanism to handle delivery.
- E
Use Cloud Tasks to queue failed messages and retry them independently.
Show answer and explanation
Correct answers: A, C, E
Explanation
Graceful handling of scaling events and transient failures requires implementing robust retry mechanisms and fallback strategies. Exponential backoff prevents overwhelming the system, while storing failed messages in Cloud Storage or using Cloud Tasks provides reliability for message delivery during peak loads. Logging errors alone does not ensure resolution, and ignoring errors can result in data loss.
- A. Correct.
Exponential backoff with retries is a best practice for handling transient errors like rate limits. This approach reduces the load on the system and increases the likelihood of successful retries.
- B. Incorrect.
While logging failed messages to Cloud Logging provides traceability, it does not ensure message delivery. Manual intervention would be required, which is not a scalable solution.
- C. Correct.
Storing failed messages in a Cloud Storage bucket and reprocessing them using a scheduled batch job ensures reliable message delivery and avoids immediate retry overload.
- D. Incorrect.
Ignoring the error and relying on Pub/Sub's retry mechanism is not applicable in this case because the failure occurs during publishing, not on the subscriber side.
- E. Correct.
Cloud Tasks can queue failed messages and retry them independently, isolating retry logic from the main Cloud Function and ensuring reliable processing.