Limitly is a Spring Boot starter that provides annotation-driven rate limiting using Redis and Lua scripts for atomic operations, supporting token bucket and sliding window algorithms.

Stars

7

7-day growth

No data

Forks

0

Open issues

0

License

No data

Last updated

2026-07-29

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It offers zero-config, annotation-based rate limiting with automatic observability via Micrometer, flexible key resolution (user, IP, SpEL), and resilient fallback modes, all built for production-grade distributed systems.

Who it is for

  • Spring Boot developers
  • Microservices architects
  • Backend engineers implementing rate limiting
  • DevOps/SREs seeking rate limit observability

Use cases

  • Protect REST API endpoints from abuse or overuse
  • Rate-limit authentication attempts per user or IP
  • Control access to critical/costly endpoints with fail-closed mode
  • Implement per-user or per-route rate limits with different algorithms

Strengths

  • Annotation-based usage simplifies integration
  • Atomic Lua scripts eliminate race conditions under high concurrency
  • Supports both token bucket (memory-efficient) and sliding window log (precise) algorithms
  • Built-in Micrometer metrics and RFC-compliant rate limit headers

Considerations

  • Requires a running Redis instance (external dependency)
  • Sliding window log algorithm consumes memory proportional to request volume per window
  • Currently at version 0.1.0-SNAPSHOT, indicating early development stage

README quick start

Limitly — Redis-Backed Rate Limiter Spring Boot Starter

Limitly is a production-grade, zero-config, annotation-based rate limiting library built for Spring Boot applications powered by Redis. Built with Java 21, Spring Boot 3, and Lua Scripting to ensure race-condition-free, atomic operations across distributed pod replicas.


⚡ Features

  • Annotation-based DX: Drop @RateLimit on any @RestController endpoint.
  • Atomic Redis Execution: Zero race conditions under high concurrent traffic using Redis Lua scripts (EVALSHA/EVAL).
  • Dual Algorithms Supported:
    • Token Bucket: Smoothed traffic flow, configurable refill rates, low Redis memory footprint.
    • Sliding Window Log: Exact request-count precision using Redis Sorted Sets (ZSET).
  • Flexible Key Resolution:
    • USER: Resolves user Principal or X-User-ID header.
    • IP: Resolves real client IP (aware of X-Forwarded-For proxy headers).
    • SPEL: Dynamic SpEL expression support (e.g. #request.remoteAddr, #user.id).
  • Resilient Fallback Modes:
    • FAIL_OPEN: (Default) Allows request traffic through when Redis is unreachable.
    • FAIL_CLOSED: Throttles requests securely during Redis outages.
  • Production Observability: Built-in Micrometer metrics (ratelimiter.requests.allowed, ratelimiter.requests.denied, ratelimiter.redis.latency, ratelimiter.redis.failures) ready for Prometheus and Grafana dashboards.
  • RFC-compliant HTTP Headers: Automatically appends X-RateLimit-Limit, X-RateLimit-Remaining, and Retry-After HTTP headers on throttled 429 responses.

🏗️ High-Level Architecture

┌───────────────────────────────────────────────────────────┐
│                     Client Request                        │
└────────────────────────┬──────────────────────────────────┘
                         ▼
              ┌─────────────────────┐
              │ RateLimitInterceptor│  (HandlerInterceptor)
              └──────────┬──────────┘
                         │ resolves key via KeyResolver
                         ▼
              ┌─────────────────────┐
              │  RateLimiterService │
              └──────────┬──────────┘
                         │ executes Lua script atomically

Description

Production-grade Redis-backed rate limiter Spring Boot starter. Features atomic Lua execution, Token Bucket & Sliding Window algorithms, SpEL resolution, and Micrometer metrics.

Related repositories

Similar projects matched by category, topics, and programming language.

Krishnagangwal
Featured
Krishnagangwal GitHub avatar

CS-Fundamentals

A curated collection of Computer Science fundamentals (PDFs, notes, cheatsheets, interview question banks) for placement preparation, covering seven core subjects plus general resources.

Data & DatabasesDatabases & Storage
2,326
robbin
robbin GitHub avatar

wechat-exporter

A Claude Code/Codex skill to export all WeChat chat records from macOS desktop client into plain-text SQLite databases.

AI & Machine LearningMCP & Tool Protocols
176
talivia-group
Featured
talivia-group GitHub avatar

talivia

Talivia is an open-source, self-hosted analytics platform that combines web analytics, session replay, and customer revenue tracking from multiple payment providers.

Web DevelopmentData & Databases
484