Error Retries and Exponential Backoff in AWS

https://docs.aws.amazon.com/general/latest/gr/api-retries.html

Numerous components on a network, such as DNS servers, switches, load balancers, and others can generate errors anywhere in the life of a given request. The usual technique for dealing with these error responses in a networked environment is to implement retries in the client application. This technique increases the reliability of the application and reduces operational costs for the developer.

Each AWS SDK implements automatic retry logic. The AWS SDK for Java automatically retries requests, and you can configure the retry settings using the ClientConfiguration class. For example, you might want to turn off the retry logic for a web page that makes a request with minimal latency and no retries. Use theClientConfiguration class and provide a maxErrorRetry value of 0 to turn off the retries.

If you're not using an AWS SDK, you should retry original requests that receive server (5xx) or throttling errors. However, client errors (4xx) indicate that you need to revise the request to correct the problem before trying again.

In addition to simple retries, each AWS SDK implements exponential backoff algorithm for better flow control. The idea behind exponential backoff is to use progressively longer waits between retries for consecutive error responses. You should implement a maximum delay interval, as well as a maximum number of retries. The maximum delay interval and maximum number of retries are not necessarily fixed values, and should be set based on the operation being performed, as well as other local factors, such as network latency.

Most exponential backoff algorithms use jitter (randomized delay) to prevent successive collisions. Because you aren't trying to avoid such collisions in these cases, you don't need to use this random number. However, if you use concurrent clients, jitter can help your requests succeed faster. For more information, see the blog post for Exponential Backoff and Jitter.

The following pseudo code shows one way to poll for a status using an incremental delay.

Do some asynchronous operation.

retries = 

DO
wait for (^retries * ) milliseconds status = Get the result of the asynchronous operation. IF status = SUCCESS
retry = false
ELSE IF status = NOT_READY
retry = true
ELSE IF status = THROTTLED
retry = true
ELSE
Some other error occurred, so stop calling the API.
retry = false
END IF retries = retries + WHILE (retry AND (retries < MAX_RETRIES))

The following code demonstrates how to implement this incremental delay in Java.

 public enum Results {
SUCCESS,
NOT_READY,
THROTTLED,
SERVER_ERROR
} /*
* Performs an asynchronous operation, then polls for the result of the
* operation using an incremental delay.
*/
public static void doOperationAndWaitForResult() { try {
// Do some asynchronous operation.
long token = asyncOperation(); int retries = ;
boolean retry = false; do {
long waitTime = Math.min(getWaitTimeExp(retries), MAX_WAIT_INTERVAL); System.out.print(waitTime + "\n"); // Wait for the result.
Thread.sleep(waitTime); // Get the result of the asynchronous operation.
Results result = getAsyncOperationResult(token); if (Results.SUCCESS == result) {
retry = false;
} else if (Results.NOT_READY == result) {
retry = true;
} else if (Results.THROTTLED == result) {
retry = true;
} else if (Results.SERVER_ERROR == result) {
retry = true;
}
else {
// Some other error occurred, so stop calling the API.
retry = false;
} } while (retry && (retries++ < MAX_RETRIES));
} catch (Exception ex) {
}
} /*
* Returns the next wait interval, in milliseconds, using an exponential
* backoff algorithm.
*/
public static long getWaitTimeExp(int retryCount) { long waitTime = ((long) Math.pow(, retryCount) * 100L); return waitTime;
}

Error Retries and Exponential Backoff in AWS的更多相关文章

  1. Exponential Backoff

    f^x(f^y+f-m)+f-n =f^(x+y)+f^(f-m)+(f-n) <?php $exponent=0; w(80,3); function w($input,$base){ glo ...

  2. Java Client for Google Cloud Storage

    关于Google Cloud Storage Google Cloud Storage有益于大文件的存储与服务(serve).此外,Cloud Storage提供了对访问控制列表(ACLs)的使用,提 ...

  3. 9.Hive Metastore Administration

    前言metastore参数metastore的基本参数metastore的额外参数客户端参数使用zk自动发现mestastore启动hive metastore服务 前言 本节讲metastore相关 ...

  4. Golang资料集

    <Platform-native GUI library for Go> 介绍:跨平台的golang GUI库,支持Windows(xp以上),Unix,Mac OS X(Mac OS X ...

  5. s3cmd在配置后使用时提示ERROR: S3 error: 403 (InvalidAccessKeyId): The AWS Access Key Id you provided does not exist in our records.

    自己新建的ceph环境,下载了s3cmd来做客户端,使用了s3cmd --configure配置后,在使用s3cmd ls可以查看到所有的bucket,但s3cmd ls s3://xxx 具体buc ...

  6. 初识云计算 -《AWS云端企业实战圣经》读书笔记

    原书中涉及实操的地方,在本文中被省略.一是篇幅太长,放入文中太过累赘,二是原书成书过早,现在 AWS 的界面早已变化很大,不具备参考性. 第一章 谁在使用云计算 1.什么是云计算 云计算(cloud ...

  7. Delphi I/O error 103 错误

    http://stackoverflow.com/questions/634587/delphi-why-do-i-sometimes-get-an-i-o-error-103-with-this-c ...

  8. AWS MVC 详解

    由于新工作是在AWS PaaS平台上进行开发,为不耽误工作,先整理一下AWS MVS的使用规范,快速上手.对AWS PaaS平台的相关介绍留到以后再来补充.本文几乎是对官方学习文档的整理,有遗漏的后补 ...

  9. Awesome Go

    A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...

随机推荐

  1. LibreOJ #6. Guess Number

    二次联通门 : LibreOJ #6. Guess Number /* LibreOJ #6. Guess Number 交互题初体验 用了二分判定 感觉不错 */ #include "in ...

  2. 解决vue多个路由共用一个页面的问题

    在日常的vue开发中我们可能会遇见多个路由需要共用一个页面的需求,特别是当路由是通过动态添加的,不同的路由展示的东西只是数据不同其他没有变化.例如: ? 1 2 3 4 5 6 7 8 9 10 11 ...

  3. 查看linux系统版本相关信息

    1.查看内核版本:cat /proc/version A机器 root@debian:~# cat /proc/version Linux version -- (ty@debian) ( (Debi ...

  4. Asis_2016_b00ks wp

    目录 程序基本信息 程序漏洞 利用思路 exp脚本 参考 程序基本信息 程序漏洞 有一个读入函数,程序的所有输入都靠它读取,这个程序有个很明显的off_by_one漏洞,在输入时多输入一个0字符. 利 ...

  5. IDEA使用(03)_git撤回(已经commit未push的)操作

    1.问题来源 日常工作中会遇到 commit 到本地仓库的代码,因为一些原因,需要撤销后再提交到本地,或者需要整合多次 commit,然后 push 到远程仓库. 2.IDEA解决方案 I.在idea ...

  6. EINVRES Request to https://bower.herokuapp.com/packages/ failed with 502

    Bower install fails with 502 - Bad Gateway when downloading bower packages. For example bower instal ...

  7. MySQL格式化时间date_format

    select date_format(deal_date, '%Y年%m月%d日 %H时%i分%s秒'), date_format(deal_date, '%Y-%m-%d %H:%i:%s') fr ...

  8. MeasureSpec常用方法

    package com.loaderman.customviewdemo; import android.content.Context; import android.util.AttributeS ...

  9. 002-创建型-03-单例模式(Singleton)【7种】、spring单例及原理

    一.概述 保证一个类仅有一个实例,并提供一个全局访问点 私有构造器.线程安全.延迟加载.序列化和反序列化安全.反射攻击 1.1.适用场景 1.在多个线程之间,比如servlet环境,共享同一个资源或者 ...

  10. 123457123456---熊猫宝贝连数字游戏(儿童连数字)--com.threeObj03.shuziLink

    熊猫宝贝连数字游戏(儿童连数字)--com.threeObj03.shuziLink