Skip to main content

API Rate Limiting

SDD Classification: L3-Technical Authority: Engineering Team Review Cycle: Quarterly
This document describes the rate limiting implementation in Materi’s API Service, including algorithms, configuration, and client-side handling.

Rate Limiting Overview


Rate Limit Tiers

By Authentication Method

By Endpoint Category


Sliding Window Algorithm

Implementation

Token Bucket Alternative

For burst-tolerant endpoints:

Endpoint Configuration

Route-Level Limits


Response Headers

Standard Headers

Every response includes rate limit information:

Rate Exceeded Response


Middleware Implementation

Rate Limit Middleware


Distributed Rate Limiting

Multi-Instance Coordination

Key Distribution

Rate limit keys are distributed across Redis cluster using consistent hashing:

Quota Management

AI Request Quotas


Client-Side Handling

Retry Strategy

Best Practices

  1. Cache responses - Reduce unnecessary API calls
  2. Implement exponential backoff - Don’t hammer the API
  3. Monitor headers - Track remaining quota proactively
  4. Batch requests - Combine multiple operations when possible
  5. Use webhooks - Prefer push over polling where available

Monitoring and Alerts

Prometheus Metrics

Alert Thresholds



Document Status: Complete Version: 2.0