重复限制的DynamoDB请求 [英] Repeating Throttled DynamoDB Requests

查看:184
本文介绍了重复限制的DynamoDB请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用适用于PHP的AWS开发工具包与DynamoDB进行编程交互。

I am using the AWS SDK for PHP to interact programmatically with DynamoDB.

我想检测到对DynamoDB的请求是否已被限制,因此可以将另一个请求

I would like to detect if a request to DynamoDB has been throttled so another request can be made after a short delay.

现在,我正在假设未满足节流请求的情况下进行操作。 Amazon FAQs 建议在节流时返回400错误。

Right now, I am operating under the assumption that throttled requests are not fulfilled. Amazon FAQs suggest that a 400 error is returned when throttling occurs.

所以我目前的逻辑看起来像这样:

So I currently have logic that looks something like this:

for( $i=0; $i<10; $i++ ) {

    $response = $dynamodb->get_item($get_item_args);

    if( $response->isOK() ) {

        break;

    } elseif( $i < 9 ) {

        sleep(1);
    }
}

我想这可行,但这是一个愚蠢。特别是,它将重复所有失败的请求,而不仅仅是受限制的请求。如果存在无法解决的错误,我真的不想重复该请求。

I suppose this works, but it is a bit dumb. In particular, it will repeat all failed requests, not just throttled requests. If there is a non-resolvable error, I really don't want to repeat the request.

为了使这个过程更智能,我想查看一个经过限制的响应用于唯一标识符(即特定的错误消息)。但是对于我一生来说,我无法捕获(或在互联网上的任何地方)受限制的示例。

To make this smarter, I'd like to look inside a throttled response for a unique identifier (i.e. a specific error message). But for the life of me, I can't capture (or find anywhere on the internet) a sample throttled response.

补偿风险的最佳方法是什么节流和最大程度地满足请求的可能性?

What is the best way to compensate for the risk of throttling and maximize the likelihood of a fulfilled request?

推荐答案

事实证明,AWS开发工具包将自动重试受限制的请求,直到成功为止。因此,不需要上面的工作(因为我正在使用适用于PHP的AWS开发工具包)。

It turns out, the AWS SDKs will automatically retry throttled requests until success. So my efforts above are unneeded (since I am using the AWS SDK for PHP).

Amazon DynamoDB处理错误文档页面针对ProvisionedThroughputExceededException错误指出了以下内容:

The Handling Errors in Amazon DynamoDB documentation page says the following for the ProvisionedThroughputExceededException error:


用于Amazon DynamoDB的AWS开发工具包会自动重试
收到此异常的请求。因此,您的请求最终将是成功的,
,除非请求太大或重试队列太大而无法完成

The AWS SDKs for Amazon DynamoDB automatically retry requests that receive this exception. So, your request is eventually successful, unless the request is too large or your retry queue is too large to finish.

这篇关于重复限制的DynamoDB请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆