本文へ移動
cccskills
無料GitHub で公開

rate-limiting

Rate limiting and throttling for Educabot APIs (Go/TS): token bucket, sliding window, Redis, per-user/IP/endpoint, 429 headers, protecting logins/expensive APIs.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcaneスター 3(GitHub 3 + cccskills 0)
連携ツールRedis

実行スコア 未検証

インストール方法を見る

含まれるファイル(1)

  • SKILL.md3.9 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

rate-limiting — API Rate Limiting

Authoritative backend-side rate limiting with Redis for coordination across pods.

When to use / NOT use

UseDo NOT use
Login/signup/forgot-password (bruteforce)As the only security mechanism (combine with auth, WAF)
Public APIs (scraping, abuse)Internal service-to-service endpoints (circuit breakers)
Expensive endpoints (LLM, reports, exports)Limiting legitimate usage (that is pricing/plans)

Defense in Depth

CDN/WAF (Cloudflare) → API Gateway/Ingress (crude per-IP) → App middleware (per-user, per-endpoint)

Algorithms

AlgorithmWhen
Sliding Window CounterDefault — balances precision/cost
Token BucketAPIs where bursts are useful
Fixed WindowSimple daily/monthly quotas
Leaky BucketShapeable rate (uploads)

Dimensions

KeyWhen
ip:<ip>Unauthenticated
user:<userId>Default authenticated
endpoint:<route>:<userId>A specific expensive endpoint
action:<name>:<id>Login, forgot-password
tenant:<orgId>Multi-tenant

Combine: action:login:ip:<ip> + action:login:email:<email>

Educabot Config

EndpointLimitWindowKey
POST /auth/login515minip + email
POST /auth/signup31hip
POST /auth/forgot-password31hemail
General authenticated API10001minuser
General anonymous API601minip
Exports/reports101huser
LLM/AI endpoints301minuser + tenant

Implementation

  • Sliding window counter with an atomic Lua script in Redis (INCR + EXPIRE)
  • Middleware: key function → CheckRate → set headers → 429 if exceeded
  • Fail-open by default (Redis dies → allow). Fail-closed for auth/payment
  • Go: go-redis + embedded Lua script. TS: rate-limiter-flexible

Response Headers (RFC 9331)

X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 847
X-RateLimit-Reset: <unix timestamp>
Retry-After: 30           ← only on 429

429 body: application/problem+json with type, title, status, detail, retryAfter

Rate Limit per Plan (SaaS)

Config per plan (free/pro/enterprise) → look up the user's plan → use the matching limiter

Correct IP

  • Fastify: trustProxy: true. Gin: SetTrustedProxies([]string{"10.0.0.0/8"})
  • Do not trust X-Forwarded-For without a trusted proxy — trivial spoofing

Client: Handling 429

  • Exponential backoff with jitter, always (without jitter → synchronized clients amplify the load)
  • Read the Retry-After header

Anti-patterns

  • Client-only rate limit, in-memory on multi-pod, a single limit with no user dimension
  • Not rate-limiting signup/forgot-password, 429 without Retry-After
  • Retrying without jitter, a limit too loose or too tight without data
  • Fail-closed everywhere (Redis hiccup → total outage)

Observability

  • Metrics: rate_limit_requests_total{endpoint,decision}, redis_errors_total
  • Dashboard: % of 429 per endpoint, top limited users/IPs, Redis latency
  • Alerts: 429 spike on non-auth, login bruteforce from the same IP, Redis errors >1%

Checklist

  • Login/signup/forgot rate limited by email + IP
  • Sliding window counter in Redis (atomic Lua)
  • X-RateLimit-* headers + Retry-After on 429
  • Fail-open by default, fail-closed for auth/payment
  • Trusted proxy configured correctly
  • Metrics + dashboard
  • Rate limit per plan if SaaS
  • Tests: blocks after N requests, 429 with correct headers

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

コメント

ログインなしで書き込めます。使ってみた感想、質問、動かなかった環境などを気軽にどうぞ。

まだコメントはありません。最初のコメントを書いてみませんか。

送信するとすぐに公開されます。メールアドレスや電話番号などの個人情報は書かないでください。URL は 2 つまでです。

0 / 1000 文字

このフォームは reCAPTCHA で保護されており、Google のプライバシーポリシーと利用規約が適用されます。

同じリポジトリのスキル

Plan, design, and implement A/B tests and experiments with statistical rigor. Covers hypothesis frameworks, sample sizing, metrics, and result analysis.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

Web/mobile accessibility decision guide: WCAG 2.2 AA, ARIA, keyboard nav, focus management, contrast, testing. Use for: a11y, accessibility, wcag, aria, screen reader, keyboard, contrast.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

Generate, iterate, and scale ad creative for paid advertising across Google, Meta, LinkedIn, and X. Covers platform specs, creative frameworks, and quality validation.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

Interactive music for games: vertical layering, horizontal re-sequencing, stingers, transition rules with sync points, and mapping gameplay states to music. Use for: adaptive music, dynamic music system, musical transitions, combat music.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

Design multi-agent systems, create agent architectures, define communication patterns, and build autonomous agent workflows with structured evaluation frameworks.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

Inter-agent communication protocol for C-suite agent teams. Defines invocation syntax, loop prevention, isolation rules, response formats, and quality loops.

日本語の概要は準備中です。原文の説明を表示しています。

SebastianLuser/claude-code-arcane32026年10月29日 更新

SebastianLuser のスキルをすべて見る

このスキルの問題を報告する