- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有多种方法可以对 DynamoDB 中的扫描操作进行速率限制,例如:https://java.awsblog.com/post/Tx3VAYQIZ3Q0ZVW/Rate-Limited-Scans-in-Amazon-DynamoDB
我想知道是否有一种方法可以在写作时做到这一点。假设我必须更新 Dynamo 中的一个表,其中包含约 200 个条目,并且我想这样做,这样就不会违反我的写入阈值,即每秒 1 个条目。
限速阅读的代码类似于:
do {
// Let the rate limiter wait until our desired throughput "recharges"
rateLimiter.acquire(permitsToConsume);
// Do the scan
ScanRequest scan = new ScanRequest()
.withTableName("ProductCatalog")
.withLimit(100)
.withReturnConsumedCapacity(ReturnConsumedCapacity.TOTAL)
.withExclusiveStartKey(exclusiveStartKey);
ScanResult result = dynamodb.scan(scan);
exclusiveStartKey = result.getLastEvaluatedKey();
// Account for the rest of the throughput we consumed,
// now that we know how much that scan request cost
double consumedCapacity = result.getConsumedCapacity().getCapacityUnits();
permitsToConsume = (int)(consumedCapacity - 1.0);
if(permitsToConsume <= 0) {
permitsToConsume = 1;
}
// Process results here
processYourResults(result);
} while (exclusiveStartKey != null);
请注意,消耗的许可会根据扫描操作使用的容量进行更新。所以我的问题是如何更新它们以进行写入操作?
此外,如果我知道我的写入操作消耗了 1 个容量,那么在循环中将许可更新 1 是否安全? (这是一个假设)
最佳答案
想到的一个简单选择是在所有写入之前使用 SQS,或者在出现第一个阈值错误时立即使用 SQS 作为“溢出缓冲区”。
然后,您将拥有一个连续运行的后台进程,并以低于最大阈值的预定义速度将记录从 SQS 移动到 DynamoDB。当您的写入量出现峰值但又不想为 dynamodb 的 24x7 更高容量付费时,这种设计模式效果特别好,并且具有成本效益。
这样做的好处是客户端提交记录(写入)时,在等待重试发生时不会被阻塞; SQS 可以以几乎任何速度摄取写入,无需额外费用,即您按消息付费,而不是按消息速率付费。
关于java - DynamoDB 中的 RateLimited 写入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33598966/
本文主要研究的是ratelimit-使用guava来做接口限流的相关内容,具体如下。 1、问题描述 某天a君突然发现自己的接口请求量突然涨到之前的10倍,没多久该接口几乎不可使用,并引发
俗话说得好,缓存,限流和降级是系统的三把利剑。刚好项目中每天早上导出数据时因调订单接口频率过高,订单系统担心会对用户侧的使用造成影响,让我们对调用限速一下,所以就正好用上了。 常用的限
我有一个 RabbitMQ 队列,里面装满了数千条消息。我需要我的消费者每秒消费 1 条消息,因此我使用 Polly 实现了 RateLimit 策略。我的配置如下: public static IA
我一直在研究 throttle 系统,并偶然发现了 Guava RateLimiter。据我所知,它处理限制的两种主要方式是对溢出的请求进行排队(.acquire(...) 方法)或丢弃它们(tryA
我对 Resilience4j RateLimiter 有疑问 public static void main(final String[] args) throws InterruptedExcep
我正在尝试使用 RateLimiter以每秒特定限制丢弃数据包。 final RateLimiter rateLimiter = RateLimiter.create(5000.0); // rate
鉴于我正在使用 Guava 速率限制器和预热,我正在尝试找出一种方法来计算在特定时间会发生多少 QPS。我看了评论here ,但我仍然不清楚。希望这里有人可以为我澄清。 我的用例: 我调用了一个具有
我有将调用限制为 100/s 的情况。 我正在考虑使用 Google Guava RateLimiter。我是这样测试的:- int cps = 100; RateLimiter limite
我在 Heroku 上使用 Django-ratelimit 时遇到问题,限制器不起作用。我没有收到任何错误。有什么建议我做错了什么吗? View .py from django.core.cache
本文整理了Java中com.eudemon.ratelimiter.utils.YamlUtils类的一些代码示例,展示了YamlUtils类的具体用法。这些代码示例主要来源于Github/Stack
本文整理了Java中com.eudemon.ratelimiter.env.ZookeeperConfig类的一些代码示例,展示了ZookeeperConfig类的具体用法。这些代码示例主要来源于Gi
假设我有一个 HTTP 客户端来调用具有请求速率限制的服务器,例如1000 个请求/秒。我在 ExecutionContext 中实现了速率限制器像这样: 使用 RateLimiter 创建了一个有界
有多种方法可以对 DynamoDB 中的扫描操作进行速率限制,例如:https://java.awsblog.com/post/Tx3VAYQIZ3Q0ZVW/Rate-Limited-Scans-i
我正在使用http://mailinator.com/在我的所有电子邮件相关测试的自动化脚本中。它对我来说效果很好,但在执行一定量的脚本后,它不起作用,并将用户路由到名为“ratelimit.jsp”
我正在使用一些 HTTP 库将一些数据上传到一些网络服务,并且需要限制每秒上传的数据量。使用的限制器是Guava RateLimiter ,几乎遵循限制某些数据流的第二个示例。对我来说有两个区别:我正
我在我的项目上设置了 django-ratelimit,它似乎工作正常,除了当访问者达到他们的限制时我无法删除丑陋的 403 错误页面。我正在尝试按照他们在文档中所说的那样替换它,内容如下: Ther
我正在尝试限制每秒对方法的调用次数。我尝试使用 Guava RateLimiter 来实现这一点。 RateLimiter rateLimiter = RateLimiter.create(1.0);
本文整理了Java中com.eudemon.ratelimiter.rule.parser.YamlRuleConfigParser类的一些代码示例,展示了YamlRuleConfigParser类的
我想在我的 Flink 工作中限制 Kafka 消费者。 查看 Flink 1.12 的源代码,我发现 FlinkConnectorRateLimiter和 GuavaFlinkConnectorRa
我正在为我的网站使用 Let's Encrypt,我的 cron 作业中出现错误,导致我尝试手动更新时出错( $ sudo letsencrypt renew ): Error: urn:acme:e
我是一名优秀的程序员,十分优秀!