- Implemented on top of ideas of well known algorithm, which are by de-facto standard for rate limiting in the IT industry.
- Effective lock-free implementation, Bucket4j is good scalable for multi-threading case.
- Absolutely non-compromise precision, Bucket4j does not operate with floats or doubles, all calculation are performed in the integer arithmetic, this feature protects end users from calculation errors involved by rounding.
- Ability to switch from one JVM to cluster in two lines of code. Using Bucket4j you are able to limiting something in the cluster of JVMs.
Since release 1.2 the
Bucket4j
supports any GRID solution which compatible with JCache API (JSR 107) specification. Just use your favorite grid including Hazelcast, Ignite, Coherence, Infinispan or any other. - Ability to specify multiple bandwidths per bucket. For example you can limit 1000 events per hours but not often then 100 events per minute.
- Both synchronous and asynchronous API.
- Pluggable listener API that allows to implement monitoring and logging.
- Ability to use bucket as as scheduler, see examples.
As mentioned above in addition to local in-memory buckets, the Bucket4j supports clustered usage scenario on top of following back-ends:
Back-end | Documentation page | Async supported |
---|---|---|
JCache API (JSR 107) |
bucket4j-jcache | No |
Hazelcast |
bucket4j-hazelcast | Yes |
Apache Ignite |
bucket4j-ignite | Yes |
Inifinispan |
bucket4j-infinspan | Yes |
Oracle Coherence |
bucket4j-coherence | Yes |
- Token bucket wikipedia - wikipedia page describes the token-bucket algorithm in classical form.
- Non-formal overview of token-bucket algorithm - the brief overview of token-bucket algorithm.
- Basic-usage - examples of basic usage.
- Advanced-usage - examples of advanced usage.
- Asynchronous-usage - examples of asynchronous usage.
- Listening of bucket events - examples of monitoring.
- Common production checklist - Mandatory points that need to be understood before using the Bucket4j in production, independently of local or clustered usage scenarios.
- JCache production checklist - Mandatory points that need to be understood before using the Bucket4j over JCache cluster.
- marcosbarbero/spring-cloud-zuul-ratelimit
- MarcGiffing/Spring Boot Starter for Bucket4j . Demos of usage (incluing Zuul and Hazelcast) can be found there bucket4j-spring-boot-starter-examples.
- JHipster/JHipster API Gateway
- Zivver/Dropwizard Ratelimit
- Rate limiting Spring MVC endpoints with bucket4j
- Abdennebi/spring-boot-bucket4j-hazelcast-demo
- ProgrammerSought Bucket4j - preliminary understanding
The Bucket4j is distributed through both JCenter and Maven Central, use any of them:
<dependency>
<groupId>com.github.vladimir-bukhtoyarov</groupId>
<artifactId>bucket4j-core</artifactId>
<version>4.5.0</version>
</dependency>
git clone https://github.com/vladimir-bukhtoyarov/bucket4j.git
cd bucket4j
mvn clean install
Copyright 2015-2019 Vladimir Bukhtoyarov Licensed under the Apache Software License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0.
Feel free to ask in:
- Gitter chat https://gitter.im/vladimir-bukhtoyarov/bucket4j
- Github issue tracker https://github.com/vladimir-bukhtoyarov/bucket4j/issues/new
If any information in the question should not be made publicly available, then try to contact with author via:
- Twitter private message https://twitter.com/monitoring_king
- Linkedin private message https://www.linkedin.com/in/vladimir-bukhtoyarov-a2385224