Google Professional Cloud Developer Question 465
Select 3Google Cloud PlatformYou are developing a serverless application on Google Cloud that makes HTTP requests to an external API. Occasionally, the API returns 429 status codes due to rate limiting. Which of the following strategies should you implement to handle these errors effectively and ensure successful retries?
- A
Implement exponential backoff with capped retries to reduce the frequency of retry attempts over time.
- B
Immediately retry the request with no delay to ensure faster resolution of temporary issues.
- C
Use a fixed delay between retries to ensure consistent retry intervals.
- D
Log the error details and stop retrying after a predefined number of attempts.
- E
Add jitter to the retry interval to avoid synchronized retries in distributed systems.
Show answer and explanation
Correct answers: A, D, E
Explanation
Handling transient errors such as rate limiting requires a combination of strategies to ensure efficient and reliable retries. Exponential backoff with capped retries reduces retry frequency over time, while adding jitter avoids synchronized retries in distributed systems. Logging errors and limiting retries ensures that retry attempts remain manageable and do not overwhelm the system.
- A. Correct.
Exponential backoff with capped retries is a recommended approach for handling transient errors like rate limiting. It reduces the frequency of retries over time and prevents overwhelming the external API.
- B. Incorrect.
Immediately retrying without delay can worsen the issue, especially during rate limiting, as it increases the load on the external API.
- C. Incorrect.
Using a fixed delay between retries does not adapt to the severity of the issue and can lead to inefficient retries or further rate limiting.
- D. Correct.
Logging error details and stopping retries after a predefined limit ensures that you can avoid infinite retry loops and allows you to analyze the issue later.
- E. Correct.
Adding jitter to retry intervals helps prevent synchronized retries across distributed systems, which can lead to cascading failures.