Kairos Gateway
High-performance multi-protocol API gateway built with Rust and Actix-Web.
Overview
kairos-gateway is the main executable binary for the Kairos API Gateway. It provides a production-ready, feature-rich gateway with support for multiple protocols including HTTP, WebSocket, FTP, and DNS.
Features
- 🚀 High Performance: Built with Actix-Web for maximum throughput
- 🔄 Multi-Protocol Support: HTTP, WebSocket, FTP, DNS
- ⚖️ Load Balancing: Round-robin, least connections, random, IP hash strategies
- 🔐 Security: JWT authentication, rate limiting, request validation
- 🏥 Health Checks: Automatic backend health monitoring
- 🔁 Retry Logic: Configurable retry with exponential backoff
- 📊 Metrics & Monitoring: Built-in metrics collection and health endpoints
- 🔧 Hot Reload: Configuration updates without downtime
- 🌐 Web UI: Modern admin interface for management
Installation
From crates.io
From Docker
From Source
Quick Start
1. Create Configuration File
Create a config.json file:
2. Run the Gateway
# Using binary
# Using Docker
# Using cargo
3. Test the Gateway
# Health check
# Test your route
Configuration
The gateway uses a JSON configuration file. See the main documentation for complete configuration reference.
Environment Variables
RUST_LOG: Log level (debug, info, warn, error)KAIROS_HOST: Server host (default: 0.0.0.0)KAIROS_PORT: Server port (default: 5900)CONFIG_PATH: Path to config.json (default: ./config.json)
Example with Environment Variables
RUST_LOG=debug KAIROS_PORT=8000
Protocol Support
HTTP/HTTPS
- Request proxying and transformation
- Header manipulation
- Path rewriting
- Method filtering
WebSocket
- Bidirectional message forwarding
- Connection upgrading
- Binary and text frame support
- Close frame handling
FTP
- File upload/download
- Directory listing
- Passive mode support
DNS
- Query forwarding
- Response caching
- Custom DNS resolution
Advanced Features
Load Balancing
Configure load balancing strategy per route:
Available strategies:
round_robin: Distribute evenly across backendsleast_connections: Send to backend with fewest active connectionsrandom: Random backend selectionip_hash: Consistent hashing based on client IP
Circuit Breaker
Automatic failure detection and recovery:
JWT Authentication
Secure routes with JWT tokens:
Rate Limiting
Protect your backends from overload:
Monitoring
Health Endpoints
GET /health- Overall gateway healthGET /health/ready- Readiness checkGET /health/live- Liveness check
Metrics Endpoints
GET /metrics- Prometheus-compatible metricsGET /metrics/requests- Request statisticsGET /metrics/backends- Backend health status
Web UI
Access the admin interface at http://localhost:5900/ (when enabled in config)
Docker Deployment
Docker Compose Example
services:
kairos-gateway:
image: ghcr.io/danielsarmiento04/kairos-rs:0.2.10
container_name: kairos-gateway
restart: unless-stopped
ports:
- "5900:5900"
volumes:
- ./config.json:/app/config.json:ro
environment:
- RUST_LOG=info
- KAIROS_HOST=0.0.0.0
- KAIROS_PORT=5900
Multi-Platform Support
The Docker image supports both AMD64 and ARM64 architectures:
# Pull for your platform automatically
# Or specify platform
Performance
Benchmarks on a 4-core machine:
- Throughput: ~50K requests/second
- Latency (p50): <1ms
- Latency (p99): <10ms
- Memory: ~50MB base + ~10MB per 10K concurrent connections
Troubleshooting
Enable Debug Logging
RUST_LOG=debug
Check Backend Connectivity
Exec into Docker Container
Dependencies
This crate depends on kairos-rs which provides the core gateway functionality.
Documentation
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
License
Licensed under MIT License. See LICENSE for details.