How alexspx/oxidegate works
Project type and purpose
• OxideGate is a cloud-native, high-performance reverse proxy written in Rust.
• It accepts HTTP/1.1 and HTTP/2 client requests, applies routing and load-balancing logic, and forwards requests to backend services.
• Key features: asynchronous I/O (Tokio), HTTP server (hyper), configurable routing, multiple load-balancing algorithms.
File structure
• Top-level:
• Cargo.toml, Cargo.lock – Rust package definition.
• dockerfile – container build.
• k6/ – performance test script.
• src/ – application source.
• tests/ – unit tests for load-balancer.
• src/ breakdown:
• config.rs – loads and validates the TOML configuration.
• lib.rs – library entry points and shared types (types.rs).
• main.rs – application bootstrap (reads config, starts servers).
• load_balancer/ – implementations of RoundRobin, LeastConnections, WeightedRoundRobin.
• proxy_service/ – core HTTP proxy logic:
– gateway_body.rs – body handling
– proxy_bridge.rs – connects client and backend streams
– proxy_handler.rs – request/response routing handler
• server/ – server lifecycle management:
– http.rs, https.rs – hyper server setup
– server_manager.rs – spawns listeners, handles shutdown
• tests/load_balancer.rs – verifies each LB algorithm.
README for additional insights
• Configurable via environment variable CONFIG_FILE referencing a TOML.
• Sections: server, frontends, backends, LB algorithms.
• Example config shows how path_prefixes and backend servers map.
a. Main components
1. External Clients – HTTP/1.1 and HTTP/2 requests.
2. OxideGate Proxy
• Configuration Loader (config.rs)
• Server Manager (server_manager.rs)
• HTTP Listener (http.rs) / HTTPS Listener (https.rs)
• Proxy Service
‑ Proxy Handler
‑ Proxy Bridge
‑ Gateway Body
• Load-Balancer Module
‑ RoundRobin
‑ LeastConnections
‑ WeightedRoundRobin
3. Backend Services – one or more HTTP servers (any implementation).
4. k6 Tester (optional) – simulates load.
b. Relationships and interactions
• Clients send requests → Server Manager routes to HTTP/HTTPS Listener.
• Listener forwards incoming requests to Proxy Handler.
• Proxy Handler consults Configuration to identify which backend and LB algorithm.
• Load-Balancer picks a backend server instance.
• Proxy Bridge opens connection to that backend and streams data (gateway_body).
• Responses flow back along the same chain to the client.
• Tests (k6) target the public proxy endpoint.
c. Architectural patterns and principles
• Modular separation: configuration, server orchestration, HTTP transport, proxy logic, load-balancing.
• Strategy pattern for LB algorithms: interchangeable implementations behind a common trait.
• Asynchronous event-driven design via Tokio and hyper.
d. Key technologies
• Rust (Cargo, Tokio, hyper)
• TOML config loader (serde)
• Docker for containerization
• k6 for performance testing