API retry logic in Amazon Web Services

穿精又带淫゛_ 提交于 2019-12-04 02:09:59

The same documentation page says:

The AWS SDK for Java automatically retries requests, and you can configure the retry settings using the ClientConfiguration class.

You should check the official documentation for ClientConfiguration, it has plenty of methods to tune its behaviour regarding retry logic. Here are the most important:

  • withMaxErrorRetry Sets the maximum number of retry attempts for failed retryable requests (ex: 5xx error responses from services)
  • withRequestTimeout Sets the amount of time to wait (in milliseconds) for the request to complete before giving up and timing out [...]
  • withThrottledRetries Retry throttling is a feature which intelligently throttles retry attempts when a large percentage of requests are failing and retries are unsuccessful [...]
  • withRetryPolicy This is the most interesting, it allows you to choose RetryPolicy and change:
    • BackoffStrategy The hook for providing custom back-off strategy to control the sleep time between retries
    • RetryCondition The hook for providing custom condition on whether a failed request should be retried
    • maxErrorRetry
    • honorMaxErrorRetryInClientConfig (whether to respect the configuration setting mentioned above)

Also note that if you haven't noticed the automatic retry mechanism, it could be due to the client-side errors. These settings are only for retrying requests in case of server (5xx) or throttling errors:

client errors (4xx) indicate that you need to revise the request to correct the problem before trying again

If you claim that it were "service side" fails, you should provide some code to reproduce the situation and analyze what is actually happening.


Now about defaults:

What is the default mechanism for Java SDK, if i don't specify any retry config?

You can lookup the default values of the ClientConfiguration constant fields. But note, that it may differ depending on the service you use (in particular DynamoDB is a special case). Check also PredefinedClientConfigurations and PredefinedRetryPolicies classes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!