본문으로 건너뛰기
cccskills
무료GitHub에 공개

api-rate-limiting-throttling-expert

Token bucket, sliding window, and Redis-based rate limiting for API protection. Activate on: rate limiting, throttling, token bucket, sliding window, API abuse, DDoS protection, quota management. NOT for: API gateway setup (use api-gateway-reverse-proxy-expert), caching (use cache-strategy-invalidation-expert).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구Redis
설치 방법 보기

포함된 파일(1)

  • SKILL.md5.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

API Rate Limiting & Throttling Expert

Implement fair, efficient rate limiting using token bucket, sliding window, and fixed window algorithms with Redis-backed distributed counters.

Activation Triggers

Activate on: "rate limiting", "throttling", "token bucket", "sliding window", "API abuse", "DDoS protection", "quota management", "429 Too Many Requests", "request limits"

NOT for: API gateway configuration → api-gateway-reverse-proxy-expert | Caching strategies → cache-strategy-invalidation-expert | WAF/firewall rules → relevant security skill

Quick Start

  1. Define limits — requests/minute per API key, IP, or user tier
  2. Choose algorithm — sliding window log (precise), token bucket (bursty), fixed window (simple)
  3. Use Redis — atomic operations with MULTI/EXEC or Lua scripts for distributed rate limiting
  4. Return proper headers — X-RateLimit-Limit, X-RateLimit-Remaining, Retry-After
  5. Differentiate tiers — free/pro/enterprise get different limits

Core Capabilities

DomainTechnologies
AlgorithmsToken bucket, sliding window log, sliding window counter, fixed window
StorageRedis 7.4+, Valkey, DragonflyDB, in-memory (single node)
Librariesrate-limiter-flexible, @upstash/ratelimit, express-rate-limit
Gateway PluginsKong rate-limiting, Nginx limit_req, Traefik ratelimit
StandardsRFC 6585 (429), RateLimit headers (draft-ietf-httpapi-ratelimit)

Architecture Patterns

Sliding Window Counter (Redis Lua)

-- Redis Lua script: sliding window rate limiter
-- KEYS[1] = rate limit key
-- ARGV[1] = window size (seconds)
-- ARGV[2] = max requests
-- ARGV[3] = current timestamp

local key = KEYS[1]
local window = tonumber(ARGV[1])
local limit = tonumber(ARGV[2])
local now = tonumber(ARGV[3])

-- Remove expired entries
redis.call('ZREMRANGEBYSCORE', key, 0, now - window)

-- Count current window
local count = redis.call('ZCARD', key)

if count < limit then
  redis.call('ZADD', key, now, now .. '-' .. math.random(1000000))
  redis.call('EXPIRE', key, window)
  return {1, limit - count - 1}  -- allowed, remaining
else
  return {0, 0}  -- denied, 0 remaining
end

Multi-Tier Rate Limiting

Request → IP Rate Limit (100/min)
              │ pass
              ↓
         Auth Check → API Key Rate Limit (tier-based)
              │           Free:  60/min
              │           Pro:   600/min
              │           Enterprise: 6000/min
              ↓ pass
         Endpoint Rate Limit (per-route)
              │   POST /upload: 10/min
              │   GET /search:  120/min
              ↓ pass
         Process Request

Response Headers (IETF Draft Standard)

// Middleware: attach rate limit headers
function rateLimitHeaders(limit: number, remaining: number, resetAt: number) {
  return {
    'RateLimit-Limit': limit.toString(),
    'RateLimit-Remaining': Math.max(0, remaining).toString(),
    'RateLimit-Reset': Math.ceil((resetAt - Date.now()) / 1000).toString(),
  };
}

// On 429 response:
res.status(429).set({
  ...rateLimitHeaders(limit, 0, resetAt),
  'Retry-After': Math.ceil((resetAt - Date.now()) / 1000).toString(),
}).json({ error: 'Too Many Requests', retryAfter: resetAt });

Anti-Patterns

  1. In-memory counters in distributed systems — rate limits must be shared across instances; use Redis or equivalent
  2. Missing Retry-After header — 429 responses without Retry-After force clients to guess, leading to thundering herd
  3. IP-only rate limiting — IP limits miss authenticated abuse and punish shared IPs (NAT, VPN); combine with API key limits
  4. Hard cutoff without burst — token bucket allows small bursts while maintaining average rate; pure fixed window is too rigid
  5. No rate limit on internal APIs — a misbehaving internal service can cascade-fail your database; always limit

Quality Checklist

  • Rate limits use distributed storage (Redis/Valkey), not in-memory
  • RateLimit-Limit, RateLimit-Remaining, RateLimit-Reset headers on every response
  • Retry-After header on 429 responses
  • Different limits per authentication tier (free/pro/enterprise)
  • Per-endpoint limits for expensive operations (uploads, search)
  • Lua script or atomic pipeline for counter increment (no race conditions)
  • Rate limit keys include both identity (API key) and scope (endpoint)
  • Monitoring dashboard shows rate limit hits, denials, and top consumers
  • Graceful degradation: queue or slow down rather than hard-reject where possible

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Expert in 2000s-era music visualization (Milkdrop, AVS, Geiss) and modern WebGL implementations. Specializes in Butterchurn integration, Web Audio API AnalyserNode FFT data, GLSL shaders for audio-reactive visuals, and psychedelic generative art. Activate on "Milkdrop", "music visualization", "WebGL visualizer", "Butterchurn", "audio reactive", "FFT visualization", "spectrum analyzer". NOT for simple bar charts/waveforms (use basic canvas), video editing, or non-audio visuals.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

Expert legal research agent for finding and scraping expungement data state by state. Knows authoritative sources, URL patterns, Firecrawl configuration, and 2026 legal landscape.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

Expert in 3D computer vision labeling tools, workflows, and AI-assisted annotation for LiDAR, point clouds, and sensor fusion. Covers SAM4D/Point-SAM, human-in-the-loop architectures, and vertical-specific training strategies. Activate on '3D labeling', 'point cloud annotation', 'LiDAR labeling', 'SAM 3D', 'SAM4D', 'sensor fusion annotation', '3D bounding box', 'semantic segmentation point cloud'. NOT for 2D image labeling (use clip-aware-embeddings), general ML training (use ml-engineer), video annotation without 3D (use computer-vision-pipeline), or VLM prompt engineering (use prompt-engineer).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

Apply crisis decision-making research to agent routing, uncertainty triage, and coordination failure analysis in time-pressured systems. Use when diagnosing handoff failures, analytical paralysis, or expert judgment under incomplete information. NOT for routine coding, simple CRUD design, or static single-agent tasks with complete information.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

Use for insight, reframing, contradiction, impasse, and anomaly-driven problem solving when execution effort no longer helps. NOT for routine optimization, error correction, or well-specified tasks with known solution paths.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

Apply cognitive task analysis to expert work that depends on perceptual cues, branching judgment, and recurring monitoring loops. Use when decomposing expert capability into agent structure, simulation design, or validation interviews. NOT for ordinary step-by-step SOP capture or simple pipelines with no tacit cue layer.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

curiositech/port-daddy32026년 10월 19일 업데이트

curiositech의 스킬 모두 보기

이 스킬의 문제 신고