Specify client retry behavior - Amazon SDK for Ruby
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Specify client retry behavior

By default, the Amazon SDK for Ruby performs up to three retries, with 15 seconds between retries, for a total of up to four attempts. Therefore, an operation could take up to 60 seconds to time out.

The following example creates an Amazon S3 client in the region us-west-2, and specifies to wait five seconds between two retries on every client operation. Therefore, Amazon S3 client operations could take up to 15 seconds to time out.

s3 = Aws::S3::Client.new( region: region, retry_limit: 2, retry_backoff: lambda { |c| sleep(5) } )

This example shows how to change the retry parameters directly within code. However, you can also use environment variables or the shared Amazon config file to set these for your application. For more information on these settings, see Retry behavior in the Amazon SDKs and Tools Reference Guide. Any explicit setting set in the code or on a service client itself takes precedence over those set in environment variables or the shared config file.