A high-performance, extensible reverse proxy server written in Go. Designed with clean architectural patterns and robust concurrency primitives, it supports dynamic load balancing, fault tolerance, and performance-critical features. Core components are decoupled using interfaces and Go idioms, enabling modularity and testability.
- High Performance: Efficient request routing with O(log n) lookup time
- Load Balancing: Multiple algorithms (Round Robin, Least Connections, Weighted Round Robin)
- Health Checks: Automatic backend health monitoring
- Circuit Breaker: Fault tolerance with exponential backoff
- Rate Limiting: Token bucket algorithm for request throttling
- Caching: LRU cache for response optimisation
- Metrics: Comprehensive monitoring and statistics
- Configuration: YAML-based configuration management
The proxy follows several design patterns:
- Strategy Pattern: Pluggable load balancing algorithms
- Observer Pattern: Health check notifications
- Circuit Breaker Pattern: Fault tolerance
- Factory Pattern: Backend creation
- Singleton Pattern: Configuration management
# Build the project
go build -o proxy cmd/proxy/main.go
# Run with default configuration
./proxy
# Run with custom configuration
./proxy -config config.yaml
server:
port: 8080
timeout: 30s
backends:
- url: "http://localhost:3001"
weight: 1
- url: "http://localhost:3002"
weight: 2
load_balancer:
algorithm: "round_robin" # round_robin, least_connections, weighted_round_robin
health_check:
interval: 30s
timeout: 10s
path: "/health"
rate_limit:
requests_per_second: 100
burst: 10
cache:
max_size: 1000
ttl: 300s
# Run all tests
go test ./...
# Run tests with coverage
go test -cover ./...
# Run benchmarks
go test -bench=. ./...
- Throughput: 10,000+ requests/second
- Latency: Sub-millisecond routing overhead
- Memory: Efficient O(1) backend selection
- Scalability: Horizontal scaling support
- Fork the repository
- Create a feature branch
- Add comprehensive tests
- Ensure all tests pass
- Submit a pull request
MIT License