Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 1.42 KB

File metadata and controls

53 lines (37 loc) · 1.42 KB

Rate Limiting Design

Overview

Credence Backend enforces per-tier rate limits using a token-bucket algorithm. Each API key is assigned a tier, and each tier has its own bucket size, refill rate, and burst allowance.

Tier model

Tier Bucket size Refill rate Burst allowance Reset window
<<<TIER_1>>> <<>> <<>> <<>> <<>>
<<<TIER_2>>> <<>> <<>> <<>> <<>>
<<<TIER_3>>> <<>> <<>> <<>> <<>>

Example

curl -i http://localhost:3000/api/<<<REAL_ENDPOINT>>> \
  -H "Authorization: Bearer <<<TOKEN>>>"

Response headers on a request under the limit: Response when the bucket is exhausted (HTTP 429):

{
  "error": "<<<REAL_ERROR_MESSAGE_FROM_MIDDLEWARE>>>"
}

Configuration

Rate limiting is controlled by the following environment variables (see .env.example):

Variable Default Description
<<<VAR_NAME>>> <<>> <<>>

Related docs

Rate Limiting

#rate-limiting

API requests are limited per-tier using a token-bucket algorithm. See docs/RATE_LIMITING_DESIGN.md for tier sizes, burst allowance, and reset windows.