Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
davidcastagnetoa avatar

Redis Rate Limiter

  • 5 installs
  • 1 repo stars
  • Updated March 10, 2026
  • davidcastagnetoa/skills

Implement a sliding-window rate limiter in Redis using sorted sets to cap verification attempts per IP, device, and document number.

About

Builds a Redis sorted-set sliding-window rate limiter keyed by IP, device, or document to block brute-force attempts. A developer uses it when enforcing app-level attempt limits beyond gateway IP throttling.

  • Sorted-set sliding window (ZADD/ZREMRANGEBYSCORE/ZCARD) with per-key expiry
  • Standard X-RateLimit-* and Retry-After headers; Lua scripts for atomicity

Redis Rate Limiter by the numbers

  • 5 all-time installs (skills.sh)
  • Ranked #1,725 of 2,203 Security skills by installs in the Skillselion catalog
  • Data as of Jul 8, 2026 (Skillselion catalog sync)
npx skills add https://github.com/davidcastagnetoa/skills --skill redis_rate_limiter

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs5
repo stars1
Last updatedMarch 10, 2026
Repositorydavidcastagnetoa/skills

What it does

Implement a sliding-window rate limiter in Redis using sorted sets to cap verification attempts per IP, device, and document number.

Files

SKILL.mdMarkdownGitHub ↗

redis_rate_limiter

Implementa rate limiting con algoritmo de ventana deslizante (sliding window) en Redis para limitar el número de intentos de verificación por IP, dispositivo y número de documento.

When to use

Aplicar en el api_gateway_agent y antifraud_agent como primera línea de defensa contra ataques de fuerza bruta.

Instructions

1. Instalar: pip install redis. 2. Algoritmo sliding window con sorted sets de Redis:

  • Key: ratelimit:{type}:{identifier} (ej. ratelimit:ip:192.168.1.1).
  • Añadir timestamp actual: ZADD key {now_ms} {now_ms}.
  • Eliminar entradas fuera de la ventana: ZREMRANGEBYSCORE key 0 {now_ms - window_ms}.
  • Contar: count = ZCARD key.
  • Si count > limit: rechazar. Si no: proceder.
  • Expirar key: EXPIRE key {window_seconds}.

3. Límites configurables: IP: 10 intentos/hora; device_id: 5 intentos/día; doc_number: 3 intentos/hora. 4. Devolver headers estándar: X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After.

Notes

  • Para alto rendimiento usar scripts Lua en Redis para atomicidad sin round-trips.
  • Redis Sentinel garantiza que el rate limiter no sea SPOF.

Related skills

Securityappsec

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.