The open-source rate limiting library that protects your APIs without slowing you down. One annotation. Sub-millisecond overhead. Works with Spring Boot and Quarkus.
Designed with production patterns in mind. Clean architecture. Extensible by design.
Sub-millisecond decisions won't slow your hot paths. O(1) algorithms, lock-free data structures, and zero allocations in the critical path.
Add @RateLimit and you're done. No XML configs, no boilerplate, no ceremony. Works instantly with Spring Boot and Quarkus.
Redis backend with atomic Lua scripts ensures consistent limits across your entire cluster. No double-counting, no race conditions.
Redis down? Circuit breakers kick in. Tiered L1/L2 storage keeps your app running. Designed for the chaos of production.
SpEL injection attacks? Blocked. Key enumeration? Prevented. PII in logs? Masked. We sweat the security details so you don't have to.
Prometheus metrics out of the box. Know exactly who's hitting limits, what's being blocked, and when to adjust your quotas.
Modular by design. Small JARs. No bloat. Mix and match for your stack.
| Module | What It Does | Size |
|---|---|---|
| rl-core | The engine: algorithms, resilience, security. Zero dependencies. | ~10.8K LOC |
| rl-spi-redis | Distributed storage. Atomic Lua scripts. Cluster-ready. | ~770 LOC |
| rl-spi-caffeine | In-memory storage. Blazing fast. Great for single-instance. | ~800 LOC |
| rl-adapter-spring | Drop-in for Spring Boot. Auto-config. AOP magic included. | ~2.7K LOC |
| rl-adapter-quarkus | Native Quarkus support. CDI interceptors. GraalVM ready. | ~800 LOC |
Add the dependency. Add the annotation. Your API is protected.
<dependency>
<groupId>com.lycosoft</groupId>
<artifactId>rl-adapter-spring</artifactId>
<version>0.1.0-beta.1</version>
</dependency>
@RestController
public class OrderController {
// Allow 100 requests per 60 seconds
@RateLimit(requests = 100, window = 60)
@GetMapping("/orders")
public List<Order> getOrders() {
return orderService.findAll();
}
}
<dependency>
<groupId>com.lycosoft</groupId>
<artifactId>rl-adapter-quarkus</artifactId>
<version>0.1.0-beta.1</version>
</dependency>
@Path("/orders")
public class OrderResource {
// Allow 100 requests per 60 seconds
@RateLimit(requests = 100, window = 60)
@GET
public List<Order> getOrders() {
return orderService.findAll();
}
}
Powerful enough for complex scenarios. Simple enough to understand.
Use SpEL expressions to rate limit per authenticated user.
@RateLimit(
key = "#user.id",
requests = 100,
window = 60
)
@PostMapping("/api/orders")
public Order createOrder(
@AuthenticationPrincipal User user,
@RequestBody OrderRequest request
) {
return orderService.create(request);
}
Combine tenant + user for SaaS-style fair usage limits.
@RateLimit(
key = "#tenant.id + ':' + #user.id",
requests = 50,
window = 60
)
public void tenantAction() { ... }
Stack multiple limits: prevent sudden spikes AND enforce long-term quotas.
@RateLimits({
@RateLimit(name = "burst", requests = 10, window = 1), // 10 req/sec max
@RateLimit(name = "hourly", requests = 1000, window = 3600) // 1000 req/hour quota
})
@GetMapping("/api/resource")
public Resource getResource() {
return resourceService.fetch();
}
Works out of the box. Fine-tune when you need to.
ratelimit:
enabled: true
storage: redis # or: caffeine
spel:
compiler-mode: IMMEDIATE
cache-size: 1000
Prometheus-ready. Alert on abuse before it becomes a problem.
# Who's getting blocked?
rate(ratelimit_denied_total[5m])
# How much traffic is allowed?
sum(rate(ratelimit_allowed_total[5m]))
Everything you need to implement rate limiting in your application.
Complete reference for all features, algorithms, and YAML configuration options.
Read GuideAnnotation-driven rate limiting with auto-configuration for Spring Boot applications.
Read GuideCDI interceptors with reactive support and native compilation compatibility.
Read GuideUse the core library directly in any Java application without frameworks.
Read GuideJoin developers who ship faster without worrying about abuse.