- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
鉴于我正在使用 Guava 速率限制器和预热,我正在尝试找出一种方法来计算在特定时间会发生多少 QPS。我看了评论here ,但我仍然不清楚。希望这里有人可以为我澄清。
我的用例:
我调用了一个具有 50 TPS 限制的外部服务。需要注意的是,我们调用它们的前 500 次必须远低于 50 TPS,之后我们可以恢复 50TPS。 (如果有比使用速率限制器更好的解决方案,我很想听听!)
伪代码:
RateLimiter rateLimiter = RateLimiter.create(50.0, 10, minutes);
for (String customerId : customerList) {
rateLimiter.acquire();
// call external service
}
假设我们仅使用一个线程执行此操作。有没有办法计算给定时间的 TPS(QPS)? 3分钟后? 5分钟后?等等
最佳答案
具有 warmupPeriod
的 RateLimiter
的冷(最小)速率是稳定(最大)速率的 1/3(这源自 coldFactor
硬编码为 RateLimiter.java:147-184 中的 3.0
)。在饱和需求(即不间断的许可证请求)下,速率将以恒定速率增加,直到达到稳定(最大)速率。
因为这是 linear equation我们可以将其写成 y = m * x + b
的形式,其中
y
(又名 y(x)
)或 qps(t)
)是给定饱和周期(例如3分钟内),m
是从冷(最小)速率到稳定(最大)速率的变化率,x
(或t
)是饱和需求下耗时,b
是我们的冷(最小)速率(稳定(最大)速率的 1/3)。总而言之,我们有 qps(t) = (stableRate - ColdRate)/WarmupPeriod * saturatedPeriod + ColdRate
,其中 coldRate = stableRate/3
。
因此,对于您的示例,我们可以在 3 分钟内获得预期的 QPS:
qps(3) = (50.0 - 50.0/3.0) / 10.0 * 3.0 + 50.0/3.0 ~= 26.6666
这是 Java 中的实现:
/**
* Calculates the expected QPS given a stableRate, a warmupPeriod, and a saturatedPeriod.
* <p>
* Both specified periods must use the same time unit.
*
* @param stableRate how many permits become available per second once stable
* @param warmupPeriod the duration of the period where the {@code RateLimiter} ramps up
* its rate, before reaching its stable (maximum) rate
* @param saturatedPeriod the duration of the period for which the {@code RateLimiter} has
* been under saturated demand starting from a cold state
* @return The expected QPS assuming saturated demand starting from a cold state
*/
public static double qps(double stableRate, double warmupPeriod, double saturatedPeriod) {
if (saturatedPeriod >= warmupPeriod) {
return stableRate;
}
double coldRate = stableRate / 3.0;
return (stableRate - coldRate) * saturatedPeriod / warmupPeriod + coldRate;
}
请注意,在实践中使用单个线程,您将无法满足 RateLimiter
的需求,因此您的实际 QPS 将略低于预期,并且很少(如果有的话)实际达到稳定(最大)速率。但是,使用多个线程将允许您始终有待处理的许可请求并满足需求。
关于java - Guava RateLimiter 预热说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35298991/
阅读文档时:https://learn.microsoft.com/en-us/azure/app-service/deploy-staging-slots#swap-operation-steps
我正在使用 Leiningen 在 Clojure 中创建一个项目。我必须对这个项目进行基准测试。我开始明白我必须预热我的 JVM。我已经进行了提前编译,这是否意味着我不必预热我的 JVM? 我知道调
我们有一个 Kubernetes 服务,其 pod 需要一些时间来预热第一个请求。基本上,第一个传入请求将从 Redis 读取一些缓存值,这些请求可能需要更长的时间来处理。当这些新创建的 pod 准备
我正在尝试消除(或至少最小化)我的 .NET 应用程序的启动/预热时间。尽管这是一个普遍关注的问题,但我不太确定如何做到这一点。 关于 .NET 应用程序启动缓慢的问题有很多。这些很容易通过池回收、工
如何预热 Maven 测试的依赖缓存?例如。 mvn test -DskipTests 下载一些依赖项,但不是全部,例如一些 maven surefire 插件依赖项只能通过 mvn test 下载。
如果我正在设计排序算法测试,我可以这样做以避免 JVM 预热吗?谢谢! double count = 0; double start, end; for(int r = 0; r < warmup;
我想要一个 java 应用程序,它运行 Scalabench 的不同基准测试.我想确保 JVM 在开始测量基准运行时长之前已预热。我应该如何从我的 Java 应用运行这些基准测试? 我想到的第一件事是
除了使用以下命令外,还有其他方法可以预热 PIOPS EBS 卷吗? sudo dd if=/dev/xvdf of=/dev/null bs=1M 随着 EBS vol 的大小增加,上述命令似乎需要
此消息来源说初始化: https://support.microsoft.com/en-us/help/2843964/application-initialization-module-fails-
我们已经使用 IIS 7.5 的应用程序初始化模块已经有一段时间了,它总是工作得很好。 但是,我们刚刚开始实现 SSL,它似乎与热身产生了冲突。我已经做了很多研究,但到目前为止还没有解决方案。 基本上
我试图使用IIS 7.5应用程序初始化扩展为我的Web应用程序配置预热过程。我正在采用这种方法来最大程度地减少由应用程序池回收引起的速度下降,这是一个问题。 我想要的是在不重新映射其他任何请求的情况下
我有一个托管在 IIS 上的 .net core (3.1) Web 应用程序。我无法弄清楚如何在第一个请求之前运行一段代码。我已完成以下操作: 设置应用池的“启动模式”=“AlwaysRunning
我有一个托管在 IIS 上的 .net core (3.1) Web 应用程序。我无法弄清楚如何在第一个请求之前运行一段代码。我已完成以下操作: 设置应用池的“启动模式”=“AlwaysRunning
我是一名优秀的程序员,十分优秀!