Skip to content

docs: cover RateLimitPolicy, ttft_ms, runtime cooldown, on_all_filtered - #281

Merged
moonming merged 2 commits into
mainfrom
docs/update-from-pr-280-278-276
May 15, 2026
Merged

docs: cover RateLimitPolicy, ttft_ms, runtime cooldown, on_all_filtered#281
moonming merged 2 commits into
mainfrom
docs/update-from-pr-280-278-276

Conversation

@moonming

@moonming moonming commented May 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

The customer docs hadn't picked up several feature PRs that landed since the docs rebuild in #249. This PR closes those gaps:

#278 (etcd endpoint derivation on subsequent boot) is a pure internal fix with no operator-visible behavior change, so it's not included here.

Changes

File Change
docs/configuration/rate-limits.md rewrite around three enforced layers; add policy fields, window-mapping table, two example policies, etcd-only provisioning path
docs/configuration/api-keys.md add team_id / owner_id bucket fields; drop stale "ApiKey-only enforcement" framing
docs/configuration/models.md document the cooldown config block (defaults: 30s / 600s cap / [401, 408, 429, 500, 502, 503, 504] triggers / honor Retry-After)
docs/configuration/routing-and-failover.md rewrite filter logic as a 4-step loop; document on_all_filtered (fail vs original_order)
docs/integration/errors-and-retries.md add 503 all_candidates_unavailable row, distinct from provider_unavailable
docs/reference/headers-and-error-codes.md add all_candidates_unavailable to the error-type list and 503 status note
docs/cloud/usage-events-and-billing.md new "Latency Signals On The Usage Event" section covering latency_ms and ttft_ms
docs/operations/metrics-and-logs.md new "Streaming TTFT" subsection
docs/reference/resource-schemas.md add RateLimitPolicy to the resource map and field-shape note
docs/reference/admin-api-reference.md new "Resources Without Admin CRUD" note for RateLimitPolicy
docs/reference/glossary.md add RateLimitPolicy term
docs/overview/core-concepts.md add team_id / owner_id to ApiKey; new "Rate Limit Policy" concept section
docs/overview/feature-matrix.md tighten rate-limit row to mention all three layers

Test plan

  • preview the rendered Docusaurus output and verify the new anchors resolve:
    • models.md#cooldown
    • routing-and-failover.md#all-targets-filtered-policy
    • routing-and-failover.md#runtime-filtering
    • rate-limits.md#rate-limit-policy-entities
    • rate-limits.md#troubleshooting
    • core-concepts.md#rate-limit-policy
    • admin-api-reference.md#runtime-model-status
  • sanity-check that every documented field name, default, and enum value matches the schema in crates/aisix-core/src/models/schema.rs and the structs in crates/aisix-core/src/models/{rate_limit_policy,model,routing}.rs
  • verify the 503 all_candidates_unavailable text matches what crates/aisix-proxy/src/error.rs emits

Summary by CodeRabbit

  • Documentation
    • Expanded rate-limiting docs: multi-layer enforcement across API keys, models, and standalone rate-limit policies, plus policy schema and troubleshooting
    • Added latency signals and a time-to-first-token (TTFT) metric for streaming responses, with guidance on interpretation
    • Clarified routing, failover, cooldown, and runtime filtering behaviors and related error codes
    • Improved API key and model configuration semantics and operator guidance

Review Change Stack

…own / on_all_filtered (#268)

Bring customer docs back in line with main after the post-#249 feature PRs:

- rate-limits.md: rewrite around the three enforced layers (ApiKey
  inline, Model inline, RateLimitPolicy entities). Add scope/window
  reference, window-mapping table, two example policies, and the
  etcd-only provisioning path.
- api-keys.md: add team_id / owner_id as bucket identifiers and drop
  the stale "ApiKey-only enforcement" framing.
- models.md: document the cooldown config block (default_seconds,
  max_seconds, honor_retry_after, trigger_statuses,
  trigger_on_timeout, trigger_on_transport) alongside
  background_model_check, and surface the runtime-status linkage.
- routing-and-failover.md: rewrite the runtime-filter description as a
  4-step loop and document on_all_filtered (fail vs original_order).
- errors-and-retries.md / headers-and-error-codes.md: add the
  503 all_candidates_unavailable error, distinct from
  provider_unavailable.
- usage-events-and-billing.md / metrics-and-logs.md: document the new
  ttft_ms field and the streaming-only contract.
- resource-schemas.md / glossary.md / core-concepts.md / feature-matrix.md /
  admin-api-reference.md: add RateLimitPolicy to the resource maps,
  glossary, core concepts, feature matrix, and call out that it has no
  admin CRUD route today.
Copilot AI review requested due to automatic review settings May 15, 2026 02:26
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Free

Run ID: f654441b-c76e-4f56-b1cc-a1c0fc48a8ed

📥 Commits

Reviewing files that changed from the base of the PR and between b93cebb and 28a2dae.

📒 Files selected for processing (4)
  • docs/cloud/usage-events-and-billing.md
  • docs/configuration/models.md
  • docs/configuration/rate-limits.md
  • docs/configuration/routing-and-failover.md
✅ Files skipped from review due to trivial changes (4)
  • docs/cloud/usage-events-and-billing.md
  • docs/configuration/routing-and-failover.md
  • docs/configuration/models.md
  • docs/configuration/rate-limits.md

📝 Walkthrough

Walkthrough

Documentation-only updates: introduce RateLimitPolicy as an etcd-stored rate-limit resource; clarify three-layer AND-combined rate-limit enforcement (ApiKey, Model, RateLimitPolicy); expand model cooldown/probe semantics and runtime routing/filter behavior; add latency signals latency_ms and streaming ttft_ms; add all_candidates_unavailable error type and routing on_all_filtered behavior.

Changes

Rate limiting, routing, model behavior, and observability

Layer / File(s) Summary
Multi-layer rate-limit overview and operator guidance
docs/configuration/rate-limits.md, docs/overview/core-concepts.md, docs/overview/feature-matrix.md
Defines three AND-combined enforcement layers: ApiKey.rate_limit, Model.rate_limit, and scope-matched RateLimitPolicy rows; expands explanation of how inline fields map to rpm/tpm/rpd/tpd/concurrency and updates operator/troubleshooting guidance.
ApiKey semantics and matching fields
docs/configuration/api-keys.md
Adds team_id and owner_id to ApiKey fields, clarifies four control layers (identity key_hash, authorization allowed_models, inline policy rate_limit, bucket identity team_id/owner_id), and documents how RateLimitPolicy rows match via team_id/owner_id.
RateLimitPolicy resource: schema, provisioning, and examples
docs/reference/resource-schemas.md, docs/reference/glossary.md, docs/reference/admin-api-reference.md
Introduces RateLimitPolicy as an etcd-backed dynamic resource with required fields (name, scope, scope_ref, window), constraint that at least one of max_requests/max_tokens is set, validation/load behavior, examples, and note that admin CRUD is not exposed (direct etcd under rate_limit_policies/<id>).
Runtime routing/filtering and all-candidates-unavailable behavior
docs/configuration/routing-and-failover.md, docs/integration/errors-and-retries.md, docs/reference/headers-and-error-codes.md
Replaces runtime filtering description with ordered dispatch by target state (healthycooldownunhealthy); adds routing.on_all_filtered options (fail default returns 503 all_candidates_unavailable with Retry-After: 30, or original_order to ignore runtime state). Adds all_candidates_unavailable proxy error type and distinguishes it from provider_unavailable.
Direct-model probes, cooldown, and routing interaction
docs/configuration/models.md
Adds cooldown to direct-model fields and expands background_model_check/probe semantics: ignore_statuses, stale_after_seconds, minimum intervals/timeouts/tokens, unhealthy-state transitions/resets, cooldown trigger conditions (statuses/timeouts), defaults, and how routing filters exclude unhealthy before cooldown candidates.
Latency observability: latency_ms and streaming ttft_ms
docs/cloud/usage-events-and-billing.md, docs/operations/metrics-and-logs.md
Documents two emitted usage/metric fields: latency_ms (total elapsed request time on all request paths) and ttft_ms (streaming time-to-first-token measured at first upstream chunk with generated content). Notes that ttft_ms is omitted on non-streaming, cache-hit, and error paths and guidance for interpreting warm-up vs streaming latency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization has reached its limit of developer seats under the Pro Plan. For new users, CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please add seats to your subscription by visiting https://app.coderabbit.ai/login.If you believe this is a mistake and have available seats, please assign one to the pull request author through the subscription management page using the link above.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

- rate-limits.md: out-of-enum windows are rejected at etcd load by the
  JSON Schema, not coerced into an unrestricted policy
- models.md: clarify that effective cooldown defaults come from
  accessor fallbacks, not from schema-level field defaults (every
  field is null until set)
- routing-and-failover.md: detangle the cooldown-fallback step — drop
  the tautological "non-unhealthy cooldown target" phrasing and
  describe the actual condition (any cooldown candidate exists, then
  dispatch to all non-unhealthy targets)
- usage-events-and-billing.md: ttft_ms is set on the first chunk
  carrying generated output, which includes tool-call deltas, not
  just text content
@moonming
moonming merged commit f1ff3c1 into main May 15, 2026
6 checks passed
@moonming
moonming deleted the docs/update-from-pr-280-278-276 branch May 15, 2026 02:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants