https://github.com/mokies/ratelimitj
A Java library for Rate-Limiting, providing extensible storage and application framework adaptors.
https://github.com/mokies/ratelimitj
dropwizard java rate-limits redis sliding-windows
Last synced: about 1 month ago
JSON representation
A Java library for Rate-Limiting, providing extensible storage and application framework adaptors.
- Host: GitHub
- URL: https://github.com/mokies/ratelimitj
- Owner: mokies
- License: apache-2.0
- Created: 2016-06-12T03:27:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-05-15T08:19:49.000Z (over 2 years ago)
- Last Synced: 2024-11-15T02:55:26.601Z (about 1 year ago)
- Topics: dropwizard, java, rate-limits, redis, sliding-windows
- Language: Java
- Homepage:
- Size: 1.11 MB
- Stars: 482
- Watchers: 24
- Forks: 93
- Open Issues: 21
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-java - RateLimitJ
README
#### This project is no longer supported, please consider using [Bucket4j](https://github.com/bucket4j/bucket4j) instead

RateLimitJ
============
[](https://travis-ci.com/mokies/ratelimitj)
[](https://codecov.io/github/mokies/ratelimitj?branch=master)
[](https://maven-badges.herokuapp.com/maven-central/es.moki.ratelimitj/ratelimitj-core/)
[](https://github.com/mokies/ratelimitj/blob/master/LICENSE)
A Java library for rate limiting, assembled using extensible storage and application framework adaptors. The library's interfaces support thread-safe sync, async, and reactive usage patterns.
#### Modules
RateLimitJ provides the following stable plugable modules:
* [Redis sliding window rate limiter](ratelimitj-redis)
* [In-memory sliding window rate limiter](ratelimitj-inmemory)
* [Dropwizard integration](ratelimitj-dropwizard)
#### Features
* Uses an efficient approximated sliding window algorithm for rate limiting
* Multiple limit rules per instance
Binaries/Download
----------------
Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [Maven Central](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22es.moki.ratelimitj%22).
Example for Maven:
```xml
es.moki.ratelimitj
ratelimitj-redis
${ratelimitj-redis.version}
```
#### Prerequisite
* RateLimitJ requires Java 8
#### Roadmap
| Feature | Status |
| ------------- |-------------|
| Redis sliding window rate limiter | production |
| Dropwizard integration - Bundle | production |
| In-memory sliding window rate limiter | stable |
| In-memory concurrent rate limiter | beta |
| Rate limiting toggles (dark launch) for framework integration | beta |
| Hazelcast sliding window rate limiter | beta/dev |
| Redis concurrent rate limiter | dev/active |
| Enhanced metrics logging | back log |
| Whitelisting & blacklisting of keys | back log |
| Rate limit HTTP header responses | back log |
| Async in-memory rate limit buffer/cache (inspired by Google's SRE book) | back log |
| Spring integration | back log |
Building
-----------
RateLimitJ is built with Gradle and requires docker to spin up Redis for the Redis module.
To build:
```
$ git clone https://github.com/mokies/ratelimitj.git
$ cd ratelimij/
$ ./gradlew
```
#### Credits
This library was inspired by the following articles on sliding window rate limiting with Redis:
* [Introduction to Rate Limiting with Redis Part 1](http://www.dr-josiah.com/2014/11/introduction-to-rate-limiting-with.html)
* [Introduction to Rate Limiting with Redis Part 2](http://www.dr-josiah.com/2014/11/introduction-to-rate-limiting-with_26.html)
#### Background Reading
* [Stripe Blog - Scaling your API with rate limiters](https://stripe.com/blog/rate-limiters)
* [An alternative approach to rate limiting](https://medium.com/figma-design/an-alternative-approach-to-rate-limiting-f8a06cf7c94c)
#### Authors
* [Craig Baker](https://github.com/mokies)