Skip to content

Installation & Requirements

distlimit is an ultra-high performance, distributed, pluggable rate-limiting library for Go.


Before installing distlimit, ensure your development environment satisfies the following minimum system requirements:

Requirement Supported Versions Notes
Go Runtime 1.20 or higher Tested up to Go 1.26+. Utilizes modern Go standard library features (context, atomic.Pointer, net/netip).
Redis Server (Optional) v6.0 or higher Required only if using Redis or Hybrid storage drivers. Supports Standalone, Sentinel, and Cluster modes.
Operating System Linux, macOS, Windows Cross-platform compatible with zero OS-specific CGO dependencies (CGO_ENABLED=0).

Install distlimit in your Go project using standard go get:

Terminal window
go get github.com/balramadan/distlimit

This installs the core library along with built-in storage drivers (memory, redis, hybrid) and standard algorithms.


distlimit is architected with a strict Zero-Dependency Core Policy.

The core rate-limiting engine relies solely on Go’s standard library. External third-party dependencies are isolated inside specific sub-packages:

1. Distributed Redis Driver (driver/redis)

Section titled “1. Distributed Redis Driver (driver/redis)”

Requires go-redis/v9:

Terminal window
go get github.com/redis/go-redis/v9

2. Telemetry & Observability Exporters (metrics/...)

Section titled “2. Telemetry & Observability Exporters (metrics/...)”
  • Prometheus Observer: go get github.com/prometheus/client_golang
  • OpenTelemetry Observer: go get go.opentelemetry.io/otel

3. Web Framework Middleware Adapters (middleware/...)

Section titled “3. Web Framework Middleware Adapters (middleware/...)”
  • Fiber v3: github.com/balramadan/distlimit/middleware/fiber
  • Gin: github.com/balramadan/distlimit/middleware/gin
  • Echo v4 / v5: github.com/balramadan/distlimit/middleware/echo
  • Standard net/http / Chi: github.com/balramadan/distlimit/middleware/nethttp
  • gRPC: github.com/balramadan/distlimit/middleware/grpc

Verify that distlimit is correctly imported and compiled in your project by creating a minimal test file main.go:

package main
import (
"fmt"
"time"
"github.com/balramadan/distlimit"
"github.com/balramadan/distlimit/driver/memory"
)
func main() {
memDriver := memory.New(5 * time.Minute)
defer memDriver.Close(nil)
limiter, err := distlimit.New(memDriver, distlimit.WithLimit(10))
if err != nil {
panic(err)
}
fmt.Printf("distlimit initialized successfully! Pointer: %p\n", limiter)
}

Run the file:

Terminal window
go run main.go