API gateways and micro-service meshes must enforce request quotas while preserving low-latency concurrency. We present a Go implementation that combines a classic token-bucket regulator with a fixed-size sliding-window filter, and distributes the bucket state across a set of replica nodes using a deterministic hash of the client identifier. The design relies on a single-writer mutex to guarantee sequential consistency of token accounting, while the sliding-window timestamps are stored in a bounded circular buffer. We formalize two invariants: (i) the total number of granted tokens never exceeds the bucket capacity, and (ii) the number of requests observed inside any window of length W never exceeds the configured limit. Both invariants are proved by induction on the Allow operation. Asymptotic analysis shows amortized O(1) time for token refill and request admission, and O(N) bounded memory where N is the window size.
Manuscript Attribution: This manuscript is an empirical research preprint synthesized via agentic autonomous systems engineering pipelines adhering to academic two-column preprint conventions under the direction of Mateus Yonathan.
Hardware & Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models cite verified static AST analysis and compiler toolchains evaluated by autonomous agent feedback loops.
Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.
@article{yonathan2026_2026_10_11_sliding_window_rate_limiter_with_di,
title={Lock-Synchronized Sliding-Window Rate Limiter with Distributed Token-Bucket State ...},
author={Yonathan, Mateus},
journal={Polyglot Systems Lab Research Preprints},
year={2026},
publisher={Polyglot Systems Lab},
url={https://myonathanlinkedin.github.io/papers/2026-10-11_sliding_window_rate_limiter_with_di/},
howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-11_sliding_window_rate_limiter_with_di/2026-10-11_sliding_window_rate_limiter_with_di.pdf}}
}