rate-limiting

Implement atomic rate limiting with Redis-based counters and Lua scripts.

9|3|Updated Jun 13, 2026
One-click install
npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill rate-limiting-sir-chawakorn
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rate-limiting
Source: https://github.com/Sir-chawakorn/sanook-cli/tree/main/skills/rate-limiting
Command: npx skills add https://github.com/Sir-chawakorn/sanook-cli --skill rate-limiting-sir-chawakorn

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill addresses the challenge of protecting backend services from abuse, scraping, and accidental overload by implementing precise, atomic request throttling.

Core Features & Use Cases

  • Algorithm Flexibility: Supports token-bucket, sliding-window, and fixed-window strategies to match specific traffic patterns.
  • Atomic Operations: Uses Lua scripting to ensure race-free counter updates in distributed Redis environments.
  • Use Case: Implement per-user API quotas to prevent a single client from exhausting system resources or to enforce tiered service plans.

Quick Start

Use the rate-limiting skill to configure a token bucket limiter for the user API endpoint with a capacity of 100 requests and a refill rate of 10 requests per second.

Frequently Asked Questions about rate-limiting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce rate limiting in a distributed backend environment?

Distributed rate limiting requires atomic operations to track quotas accurately across multiple instances. This skill uses Redis-based counters with Lua script execution to prevent race conditions and ensure consistent request throttling across all service nodes.

What is the best way to prevent API traffic bursts from exhausting system resources?

API traffic bursts are controlled by implementing rate limiting strategies like token-bucket, sliding-window, or fixed-window algorithms. These mechanisms enforce per-user quotas, preventing individual clients from scraping or overloading backend services.

How does atomic throttling prevent race conditions in Redis?

Atomic throttling prevents race conditions by executing Lua scripts directly within Redis. This ensures counter updates are processed as single, uninterrupted operations, maintaining accurate quota enforcement even under high concurrency.

Do I need Redis to implement consistent rate limiting across multiple instances?

Redis is required for distributed environments because it provides a centralized data store for atomic counter updates. This ensures that rate limiting quotas are consistently enforced across all service instances without local state conflicts.

When should I choose a token bucket algorithm over a fixed window for API rate limiting?

Token bucket is ideal when you need to allow short traffic bursts while maintaining an average rate, as it refills continuously. Fixed window is simpler but can cause edge-case spikes at window boundaries, making token bucket better for flexible API quotas.

Why does my API rate limiter allow more requests than the configured quota?

Rate limiters exceed configured quotas when counter updates suffer race conditions in concurrent environments. Using atomic Lua script execution in Redis ensures updates are isolated and sequential, keeping request tracking accurate.