Skip to content
/ smoother Public

A Go traffic smoothing library that maintains target RPS through intelligent request delays instead of rejections. Supports local and Redis-based implementations with circuit breaker capabilities

License

Notifications You must be signed in to change notification settings

n-r-w/smoother

Repository files navigation

Smoother

Smoother is a Go package that provides traffic smoothing capabilities by introducing controlled delays to maintain a target request rate. Unlike traditional rate limiters that reject excess requests, Smoother keeps all requests active while ensuring a consistent throughput through intelligent request spacing.

Go Reference CI Status

Features

  • 🎯 Maintains target RPS through controlled delays rather than request rejection
  • ⏱️ Dynamically adjusts wait times to smooth traffic spikes
  • 🔄 Keeps all requests active and processing
  • 🌊 Smooths out traffic spikes while ensuring all requests complete
  • 📡 Supports both local and distributed (Redis-based) implementations
  • 🛠️ Pluggable interface for custom implementations
  • 🔌 Thread-safe operation
  • 🚦 Throttler package for back pressure pattern

Key Benefits

  • No dropped connections or rejected requests
  • Consistent, predictable throughput
  • Better resource utilization through traffic smoothing
  • Ideal for scenarios where request completion is more important than immediate error response
  • Suitable for both single-instance and distributed systems

Special features of the implementation Primary + fallback + circuit breaker

In the FallbackTryer, requests are sent concurrently to both the primary and fallback. When in the closed state, it chooses the primary if it succeeds, and falls back if it fails. Consequently, both implementations handle traffic simultaneously. Traffic is only removed from the primary when the circuit breaker opens

Installation

go get github.com/n-r-w/smoother

Rate Limiter backends

Usage

See the example for usage examples.

Throttler package

The throttler package provides a simple implementation of the back pressure pattern.

About

A Go traffic smoothing library that maintains target RPS through intelligent request delays instead of rejections. Supports local and Redis-based implementations with circuit breaker capabilities

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages