# uber-go/ratelimit

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/uber-go-ratelimit).**

4,665 stars · 322 forks · Go · mit

## Links

- GitHub: https://github.com/uber-go/ratelimit
- awesome-repositories: https://awesome-repositories.com/repository/uber-go-ratelimit.md

## Description

This is a Go library that implements a leaky-bucket algorithm to control the frequency of operations and requests per second. It serves as a concurrent request throttler that blocks calling threads until request slots become available to maintain a steady execution rate.

The project includes a traffic burst controller that allows the accumulation of unspent request capacity, permitting short-term spikes in volume while maintaining a defined long-term average rate.

The library provides capabilities for operation frequency limiting, request interval enforcement, and application resource protection. It also includes a deterministic time simulator and mock clock utilities to verify timing logic and rate limiting behavior without waiting for real-time intervals.

## Tags

### DevOps & Infrastructure

- [Leaky Bucket Algorithms](https://awesome-repositories.com/f/devops-infrastructure/rate-limiters/rate-limiting-algorithms/leaky-bucket-algorithms.md) — Implements a leaky-bucket algorithm to maintain a steady execution rate for requests.
- [Traffic Burst Management](https://awesome-repositories.com/f/devops-infrastructure/message-queues/queue-based-message-distribution/traffic-burst-management.md) — Allows short-term spikes in request volume while maintaining a defined long-term average rate.
- [Rate Limiting Algorithms](https://awesome-repositories.com/f/devops-infrastructure/rate-limiters/rate-limiting-algorithms.md) — Uses a leaky-bucket algorithm as the steady-state execution controller to maintain consistent operation rates. ([source](https://github.com/uber-go/ratelimit/blob/main/.gitignore))
- [Leaky Bucket Implementations](https://awesome-repositories.com/f/devops-infrastructure/rate-limiters/rate-limiting-algorithms/leaky-bucket-implementations.md) — Provides a Go library implementing the leaky-bucket algorithm to control operation frequency.

### Development Tools & Productivity

- [Frequency Limiters](https://awesome-repositories.com/f/development-tools-productivity/action-execution-frameworks/interactive-action-triggers/frequency-limiters.md) — Blocks the calling thread until a slot becomes available based on a defined operations-per-second limit. ([source](https://github.com/uber-go/ratelimit#readme))

### Software Engineering & Architecture

- [Burst Capacity Accumulators](https://awesome-repositories.com/f/software-engineering-architecture/burst-capacity-accumulators.md) — Implements a burst controller that allows the accumulation of unspent request capacity for short-term traffic spikes.
- [Burst Capacity Management](https://awesome-repositories.com/f/software-engineering-architecture/burst-capacity-management.md) — Enables the accumulation of unspent request slots to permit short bursts of traffic. ([source](https://github.com/uber-go/ratelimit/blob/main/ratelimit.go))
- [Traffic Burst Controllers](https://awesome-repositories.com/f/software-engineering-architecture/traffic-burst-controllers.md) — Provides a mechanism for accumulating unspent request capacity to allow short bursts of traffic.
- [Traffic Flow Control](https://awesome-repositories.com/f/software-engineering-architecture/traffic-flow-control.md) — Regulates the number of requests a service handles per second to prevent system overload.
- [Request Rate Limiting](https://awesome-repositories.com/f/software-engineering-architecture/traffic-management/request-rate-limiting.md) — Blocks subsequent calls until the required time interval for a specified rate has elapsed. ([source](https://github.com/uber-go/ratelimit/blob/main/limiter_atomic.go))
- [Execution Timestamp Tracking](https://awesome-repositories.com/f/software-engineering-architecture/retry-state-tracking/execution-timestamp-tracking.md) — Maintains internal timestamps of the last execution to calculate necessary wait periods.

### Web Development

- [Request Throttlers](https://awesome-repositories.com/f/web-development/frontend-development-tools/state-data-management/component-lifecycle-utilities/component-state-management/request-throttlers.md) — Ships a concurrent request throttler that blocks calling threads until request slots become available.
- [Wait-Based Execution Throttling](https://awesome-repositories.com/f/web-development/randomized-interval-schedulers/wait-based-execution-throttling.md) — Blocks calling threads using sleep intervals to ensure operations do not exceed the defined frequency.

### Operating Systems & Systems Programming

- [Integer Atomic Operations](https://awesome-repositories.com/f/operating-systems-systems-programming/lock-free-atomic-containers/integer-atomic-operations.md) — Uses lock-free atomic integer operations to ensure thread-safe updates to internal state during high concurrency.

### Security & Cryptography

- [Deterministic Testing Clocks](https://awesome-repositories.com/f/security-cryptography/clock-abstracted-time-validation/deterministic-testing-clocks.md) — Provides an interface-based clock to allow deterministic testing by simulating time progression.
- [Denial of Service Prevention](https://awesome-repositories.com/f/security-cryptography/denial-of-service-prevention.md) — Prevents services from being overwhelmed by traffic spikes by limiting incoming request frequency.

### Testing & Quality Assurance

- [Time Simulation Utilities](https://awesome-repositories.com/f/testing-quality-assurance/time-simulation-utilities.md) — Implements a custom clock that simulates the passage of time for deterministic testing of rate limits.

### Part of an Awesome List

- [Rate Limiting](https://awesome-repositories.com/f/awesome-lists/devtools/rate-limiting.md) — High-performance rate limiting implementation for Go applications.
