Minato is a high-performance, feature-rich reverse proxy and load balancer written in Go with in-memory caching and hot configuration reloads
- High-speed load balancing with path and domain-based routing
- In-memory LRU caching with absolute TTL eviction
- Health monitoring of upstream backend servers with automatic Failover and Recovery
- HTTP cache-control header support (max-age, no-store, no-cache)
- Thread-safe design with no locks in hot request path to upstreams
- A complete custom implementation for
net/http/httputil.ReverseProxy - Streaming-safe response handling (SSE/chunked)
- Hot-reloadable runtime configuration using
SIGHUPand reuse of state for optimising GC pressure
Minato behaves like a tiny CDN layer embedded into your infrastructure.
- Round Robin - Evenly distribute requests across healthy backends
- Least Connections - Route to backend with fewest active connections
- Dual-Layer Checks - Fast TCP check followed by HTTP endpoint verification
- Automatic Failover - Unhealthy backends automatically removed from rotation
- Recovery Detection - Backends automatically restored when healthy
- Configurable Endpoints - Per-backend health check URIs
- LRU Cache - Scratch implementation of LRU using Go maps and doubly linked lists
- Absolute TTL - TTL based LRU eviction which respects cache-control headers
- HTTP Cache-Control Aware - Respects
max-age,no-cache, andno-storedirectives - Size-Limited - Configurable capacity and max response body size prevents memory exhaustion
- Quick Start
- Installation
- Configuration
- Usage
- Architecture
- Performance
- Caveats & Limitations
- Development
- Contributing
-
Clone the repository
git clone https://github.com/kunalvirwal/minato.git cd minato -
Configure your services (edit
config.yaml)services: - name: "my-service" listen_port: 80 balancer: "RoundRobin" hosts: - "http://example.com/" upstreams: - host: "http://localhost:8001" health_uri: "/health" - host: "http://localhost:8002" health_uri: "/health"
-
Run Minato
sudo go run ./cmd
Or build and run
go build -o minato ./cmd sudo ./minato -
Test it
curl -H "Host: example.com" http://localhost/
- Go 1.21+
- Root/sudo privileges - Required for binding to ports < 1024
# Clone repository
git clone https://github.com/kunalvirwal/minato.git
cd minato
# Install dependencies
go mod download
# Build binary
go build -o minato ./cmd
# Run
sudo ./minatoConfiguration is managed through config.yaml in the root directory.
# Cache Configuration (Optional)
cache:
enabled: true # Enable/disable response caching
max_body_size: 1048576 # Max cacheable response size (1MB)
capacity: 100 # Number of global cache entries
type: "LRU" # Cache eviction policy: "LRU"
ttl: 300 # Time-to-live in seconds
# Service Definitions (Required)
services:
- name: "service-name" # Unique service identifier
listen_port: 80 # Port to listen on
balancer: "RoundRobin" # Load balancing algorithm
# Domains/paths this service handles
hosts:
- "http://example.com/"
- "http://example.com/api"
# Backend servers
upstreams:
- host: "http://backend1:8000"
health_uri: "/health"
- host: "http://backend2:8000"
health_uri: "/health"| Option | Type | Description |
|---|---|---|
enabled |
bool | Enable response caching |
max_body_size |
int | Maximum response body size to cache (bytes) |
capacity |
int | Maximum number of cached responses |
type |
string | Cache eviction policy (LRU or LFU) |
ttl |
int | Cache entry time-to-live (seconds) |
| Option | Type | Required | Description |
|---|---|---|---|
name |
string | β | Unique service identifier |
listen_port |
int | β | Port number to listen on |
balancer |
string | β | Load balancing algorithm (RoundRobin) |
hosts |
array | β | List of domain/path combinations to route |
upstreams |
array | β | Backend server configurations |
| Option | Type | Required | Description |
|---|---|---|---|
host |
string | β | Backend server URL (with protocol) |
health_uri |
string | β | Health check endpoint path |
Note : The Upstream[Host] field and Service[hosts] fields allows path to be a part of URLs. So for inbound hosts the largest matching path prefix will be given priority.
Update config.yaml and send a SIGHUP signal:
# Find the process ID
sudo ps aux | grep minato
# Send reload signal
sudo kill -1 <PID>What happens during reload:
- β New configuration is validated
- β New backend servers are added
- β Older unused backend servers are cleaned up
- β Existing connections continue uninterrupted
- β New listeners start on new ports
- β Old listeners on removed ports shut down gracefully
- β A fresh cache instance replaces the old one.
minato/
βββ cmd/
β βββ main.go # Entry point, signal handling
β βββ helper.go # Config building, cleanup
βββ internal/
β βββ backend/ # Backend server abstraction
β βββ balancer/ # Load balancing algorithms
β βββ cache/ # Response caching (LRU)
β βββ config/ # YAML config parsing and global config generation
β βββ healthcheck/ # Health monitoring
β βββ proxy/ # Reverse proxy implementation
β βββ state/ # Global state management and Runtime resource management
β βββ utils/ # Logging utilities
βββ Readme_Assets/ # Documentation assets
βββ config.yaml # Main configuration file
βββ go.mod
βββ README.md
The benchmark above demonstrates the performance impact of enabling in-memory caching. Testing was conducted with 10,000 requests distributed across 125 concurrent connections to two nginx backend upstreams.
Key Results:
| Metric | Without Cache | With Cache | Improvement |
|---|---|---|---|
| Average Latency | 8.33ms | 1.88ms | 4.4x faster |
| Requests/Second | 14,951.71 | 65,712.20 | 4.4x throughput |
Caching reduced max latency by 35% and increased throughput by 4.4x, making it highly effective for serving cacheable content at scale.
Contributions welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- β
Run
go fmtbefore committing - β
Test with
-raceflag - β Update documentation for new features
- β Add comments for exported functions
- β Keep hot path lock-free
This project is licensed under the MIT License - see the LICENSE file for details.
