Getting Started

Introduction

Start with the provider and strategy that match your workload, then scale without changing your mental model.

Trypema is a sliding-window rate limiting library for Rust with three providers and two strategies:

ProviderBest forMain trade-off
Localsingle-process services, jobs, CLIsstate is not shared
Redisshared limits across many instancesevery check performs Redis I/O
Hybridvery high-throughput distributed APIsdecisions can lag behind Redis by sync_interval_ms
StrategyBest forBehavior
Absolutehard admission controlallow or reject
Suppressedgraceful degradationprobabilistic shedding near or above the limit

What Trypema is good at

  • Starting local and staying on one API as your deployment grows.
  • Using fractional rates such as 0.5 or 5.5 requests per second.
  • Running best-effort distributed limiting with Redis 7.2+.
  • Choosing between strict rejection and smoother traffic shedding.

What to keep in mind

  • Local state is process-local.
  • Redis and hybrid are best-effort distributed limiters, not strictly linearizable admission control.
  • redis-tokio and redis-smol are mutually exclusive.

The name

Trypema comes from the Koine Greek word "τρυπήματος" (trypematos), "hole" or "opening," from the biblical phrase "through the eye of a needle." The image fits the library well: a rate limiter is a narrow gate that controls what passes through.

  1. Installation
  2. Quickstart (Local)
  3. Quickstart (Redis) or Quickstart (Hybrid)
  4. Decisions and Providers