java中的速率控制 [英] rate control in java

查看:92
本文介绍了java中的速率控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个好的解决方案或可能的 API 来解决以下问题:

I am looking for a good solution or probably an API to solve the following problem:

  • 我的应用程序循环执行一项任务,例如发送电子邮件等.我需要将消息的平均速率限制为例如每秒 100 条消息或每分钟 1000 条消息...

不,我正在寻找可以完成此任务的算法或 API.

No I am looking for an algorithm or an API which does exactly this task.

推荐答案

令牌桶算法是非常容易实现和使用但非常强大.您可以在运行时控制吞吐量并将一些请求排队以处理窥视.

Token bucket algorithm is very easy to implement and use yet very powerful. You can control the throughput at runtime and queue some requests to handle peeks.

这篇关于java中的速率控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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