← 返回
未分类 中文

Rate Limiting

Deep rate limiting workflow—identifying actors and resources, choosing algorithms, distributed vs local limits, client UX (headers, retries), and abuse detec...
深度限流工作流——识别行为主体与资源、选择算法、分布式与本地限流、客户端体验(头部、重试)以及滥用检测。
codekungfu codekungfu 来源
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 0
Stars
📥 429
下载
💾 0
安装
1
版本
#latest

概述

Rate Limiting (Deep Workflow)

Rate limits balance fairness, availability, and abuse prevention. Design explicitly: who is throttled, what resource is limited, and how clients should back off.

When to Offer This Workflow

Trigger conditions:

  • Protecting public APIs, auth endpoints, or expensive operations
  • Multi-tenant “noisy neighbor” isolation
  • Retry storms after incidents causing cascading 429/502

Initial offer:

Use six stages: (1) threat & fairness model, (2) dimensions & keys, (3) algorithms & config, (4) distributed enforcement, (5) client protocol & UX, (6) observability & tuning). Confirm enforcement layer (API gateway vs app middleware vs edge).


Stage 1: Threat & Fairness Model

Goal: Distinguish legitimate bursts (batch jobs, mobile retries) from abuse; align limits with product tiers and SLAs.

Exit condition: Written policy: free vs paid limits, partner caps, burst allowances.


Stage 2: Dimensions & Keys

Goal: Choose stable limit keys: authenticated user id > API key > IP (with shared-NAT caveats).

Practices

  • Per-tenant and global limits; separate expensive routes (exports, search)

Stage 3: Algorithms & Config

Goal: Token bucket / leaky bucket for smooth bursts; sliding window for strict per-minute caps; consider concurrency limits separately from request rate.


Stage 4: Distributed Enforcement

Goal: Central store (Redis, etc.) with atomic increments; handle multi-region (sticky routing vs shared counters); mind clock skew.


Stage 5: Client Protocol & UX

Goal: Consistent 429 responses with Retry-After; document exponential backoff + jitter; optional X-RateLimit-* headers for transparency.


Stage 6: Observability & Tuning

Goal: Metrics on throttles by route and actor class; alerts on abnormal deny spikes (attack vs misconfigured client).


Final Review Checklist

  • [ ] Policy matches tiers and fairness goals
  • [ ] Limit keys stable and hard to spoof
  • [ ] Algorithm matches burst vs sustained semantics
  • [ ] Distributed correctness considered
  • [ ] Client-facing 429 behavior documented
  • [ ] Metrics and tuning loop defined

Tips for Effective Guidance

  • Coordinate with authentication—anonymous IP limits are coarse.
  • Don’t throttle health checks in ways that break monitors.
  • GraphQL: consider query cost / depth limits, not only HTTP count.
  • WebSockets: separate connection caps from message rate limits.

Handling Deviations

  • Edge/CDN: limits may differ from origin—document both layers.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-31 08:33 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

business-ops

抖音电商

codekungfu
该技能介绍如何通过抖音电商实现变现;当你计划从事或优化抖音电商时调用。
★ 2 📥 1,926
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 73 📥 182,215
dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 680 📥 328,605