<< All versions
Skill v1.0.1
Automated scan100/100j4flmao/agent-skills/rate-limiting
+2 new
──Details
PublishedAugust 29, 2026 at 09:07 AM
Content Hashsha256:e86d9156e88e5e10...
Git SHAefded0a5aa11
Bump Typepatch
──Files
Files (1 file, 1.5 KB)
SKILL.md1.5 KBactive
SKILL.md · 60 lines · 1.5 KB
version: "1.0.1" name: Rate Limiting description: Implementation of Token Bucket and Leaky Bucket algorithms for load balancing.
Rate Limiting
Algorithms
1. Token Bucket
Tokens are added to a bucket at a fixed rate. Each request consumes a token. If the bucket is empty, the request is dropped.
2. Leaky Bucket
Requests are added to a queue (bucket). The queue is processed at a fixed rate. If the queue is full, new requests are dropped.
Redis Lua Script (Token Bucket)
lua
-- KEYS[1]: rate limit key-- ARGV[1]: capacity (max tokens)-- ARGV[2]: rate (tokens per second)-- ARGV[3]: current timestamplocal key = KEYS[1]local capacity = tonumber(ARGV[1])local rate = tonumber(ARGV[2])local now = tonumber(ARGV[3])local info = redis.call("HMGET", key, "tokens", "last_update")local tokens = tonumber(info[1])local last_update = tonumber(info[2])if tokens == nil thentokens = capacitylast_update = nowelselocal delta = math.max(0, now - last_update)tokens = math.min(capacity, tokens + delta * rate)endif tokens >= 1 thentokens = tokens - 1redis.call("HMSET", key, "tokens", tokens, "last_update", now)redis.call("EXPIRE", key, math.ceil(capacity / rate))return 1 -- Allowedelsereturn 0 -- Rate Limitedend
Architecture
mermaid
%%{init: {"theme": "default", "flowchart": {"useMaxWidth": false}}}%%flowchart TDA[Client Request] --> B{Rate Limiter}B -- Allowed --> C[API Gateway]C --> D[Backend Service]B -- Denied --> E[429 Too Many Requests]