Trypema Rate Limiter
Status: in development (pre-release).
The name is inspired by the Koine Greek word "τρυπήματος" (trypematos, "hole/opening") from the phrase "διὰ τρυπήματος ῥαφίδος" ("through the eye of a needle") in the Bible:
- Matthew 19:24
- Mark 10:25
- Luke 18:25
Koine Greek (one common form):
"εὐκοπώτερόν ἐστιν κάμηλον διὰ τρυπήματος ῥαφίδος εἰσελθεῖν ἢ πλούσιον εἰς τὴν βασιλείαν τοῦ θεοῦ"
Word breakdown:
- κάμηλον (kamēlon) — camel
- διὰ (dia) — through
- τρυπήματος (trypēmatos) — hole/opening
- ῥαφίδος (rhaphidos) — of a needle
- εἰσελθεῖν (eiselthein) — to enter
- πλούσιον (plousion) — a rich man
- βασιλείαν τοῦ θεοῦ — kingdom of God
High-performance rate limiting primitives in Rust, designed for concurrency safety, low overhead, and predictable latency.
This repository accompanies a post that demonstrates one possible implementation approach, walking through the core data structures, atomic operations, and key design trade-offs for real-time systems.
Status
localprovider: implemented (seeAbsoluteLocalRateLimiter)- additional providers: planned
Crate layout
src/rate_limiter.rs: top-levelRateLimiterand optionssrc/local/absolute_local_rate_limiter.rs: local implementationsrc/common.rs: shared types (RateLimitDecision, counters, series)
Usage
use ;
let rl = new;
let key = "user:123";
// record work
rl.local.absolute.inc;
// check admission
match rl.local.absolute.is_allowed
Configuration
window_size_seconds: sliding window length for admission decisionsrate_group_size_ms: coalescing interval for increments close in time