How to implement distributed rate limiter?

前端 未结 3 1521
星月不相逢
星月不相逢 2020-12-29 07:52

Let\'s say, I have P processes running some business logic on N physical machines. These processes call some web service S, say. I want to ensure that not more than X calls

3条回答
  •  孤城傲影
    2020-12-29 08:56

    Bucket4j is java implementation of "token-bucket" rate limiting algorithm. It works both locally and distributed(on top of JCache). For distributed use case you are free to choose any JCache implementation like Hazelcast or Apache Ignite. See this example of using Bucket4j in cluster.

提交回复
热议问题