Error Retries and Exponential Backoff in AWS
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的更多相关文章
- 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 ...
- Java Client for Google Cloud Storage
关于Google Cloud Storage Google Cloud Storage有益于大文件的存储与服务(serve).此外,Cloud Storage提供了对访问控制列表(ACLs)的使用,提 ...
- 9.Hive Metastore Administration
前言metastore参数metastore的基本参数metastore的额外参数客户端参数使用zk自动发现mestastore启动hive metastore服务 前言 本节讲metastore相关 ...
- Golang资料集
<Platform-native GUI library for Go> 介绍:跨平台的golang GUI库,支持Windows(xp以上),Unix,Mac OS X(Mac OS X ...
- 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 ...
- 初识云计算 -《AWS云端企业实战圣经》读书笔记
原书中涉及实操的地方,在本文中被省略.一是篇幅太长,放入文中太过累赘,二是原书成书过早,现在 AWS 的界面早已变化很大,不具备参考性. 第一章 谁在使用云计算 1.什么是云计算 云计算(cloud ...
- Delphi I/O error 103 错误
http://stackoverflow.com/questions/634587/delphi-why-do-i-sometimes-get-an-i-o-error-103-with-this-c ...
- AWS MVC 详解
由于新工作是在AWS PaaS平台上进行开发,为不耽误工作,先整理一下AWS MVS的使用规范,快速上手.对AWS PaaS平台的相关介绍留到以后再来补充.本文几乎是对官方学习文档的整理,有遗漏的后补 ...
- Awesome Go
A curated list of awesome Go frameworks, libraries and software. Inspired by awesome-python. Contrib ...
随机推荐
- bzoj 5206
$n$ 点 $m$ 边图的有限制三元环个数 首先将所有左右端点并且属性相同的边的权值相加,合并为一条边 在这只之前得先排序排序之前得先判断是否需要交换左右端点的位置 T_T 然后统计三元环 补充说明按 ...
- TensorFlow(五):手写数字识别加强版
# 该版本的最终识别准确率达到98%以上 import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_d ...
- P1986 元旦晚会——贪心或差分约束系统
P1986 元旦晚会 每个人可能属于不同的声部,每个声部最少要有c[i]个人发声: 求最少需要多少话筒: 首先贪心,将所有声部的区间按照右端点大小排序,如果右端点相同,左端点从小到大排序: 贪心每次选 ...
- 1825:【01NOIP提高组】数的划分
#include<bits/stdc++.h> using namespace std; ],tot; void dfs(int num,int pos) { if(pos==k) ]) ...
- (转)shell调试方法
---恢复内容开始--- 转载:https://www.ibm.com/developerworks/cn/linux/l-cn-shell-debug/ Shell脚本调试技术 曹 羽中2007 年 ...
- vmware如何克隆多个linux系统
安装一次系统相对来说耗时较长,且还要做各种配置,那么克隆就不失为一种好的选择.接下来我把我做系统克隆的步骤写下来,供大家参考: 右键点击已经安装的虚拟机,选择管理-->克隆,接下来弹出一个窗口 ...
- 使用vscode快速建立vue模板
当我们希望每次新建.vue文件后,vscode能够根据配置,自动生成我们想要的内容. 打开vscode编辑器,依次选择“文件 -> 首选项 -> 用户代码片段”,此时,会弹出一个搜索框,我 ...
- Vue路由管理之Vue-router
一.Vue Router介绍 Vue Router 是 Vue.js 官方的路由管理器.它和 Vue.js 的核心深度集成,让构建单页面应用变得易如反掌.包含的功能有: 嵌套的路由/视图表 模块化的. ...
- HttpClient学习(三)—— AsyncHttpClient使用
一.介绍 This class support asynchronous and synchronous HTTP requests. AsyncHttpClient 支持同步.异步Http请求. 二 ...
- Linux系统中rm删除命令
rm命令 1.可以删除一个目录中的一个或多个文件或目录 2.可以将某个目录及其下属的所有文件及其子目录均删除掉 3.对于链接文件,只是删除整个链接文件,而原有文件保持不变 语法 rm (选项)(参数) ...