A high-performance, multi-threaded asynchronous HTTP server engine written in Pure Rust.
Rustrate is a lightweight web server designed to handle multiple independent server instances simultaneously, each with its own configuration and lifecycle.
- Hybrid Concurrency Model:
- Isolation: Each
[server]block defined in the configuration runs on its own dedicated OS Thread. - Async Runtime: Inside each thread, a Tokio runtime handles thousands of concurrent requests using non-blocking I/O.
- Isolation: Each
- Protocol Support:
- HTTP/1.0: Stable
- HTTP/1.1: Stable (Keep-alive, Chunked Transfer, etc.)
- HTTP/2.0: Work-in-Progress (Frame parsing and stream multiplexing)
- Built-in SPA Support: Smart routing for Single Page Applications (automatically falls back to
index.html). - Native TLS/SSL: Supports HTTPS using
.pemcertificates and keys. - Security & Constraints: Fine-grained control over
max-header-size,max-body-size, andmax-header-length.
Rustrate uses a server.conf file to manage multiple listeners. This allows you to run an HTTP and HTTPS server (or multiple sites) from a single binary:
[server]
port: 80
root: W:\path\to
index: index.html
spa: true
max-header-size: 2048
max-header-length: 25
max-body-size: 2097152
[server]
port: 443
root: W:\path\to
index: index.html
spa: true
max-header-size: 2048
max-header-length: 25
max-body-size: 2097152
tls-crt: W:\path\to\cert\localhost.pem
tls-key: W:\path\to\cert\localhost-key.pem
Ensure you have the Rust toolchain (Edition 2021 or later) installed.
The server looks for a server.conf file in the project root. Each block spawns a unique OS thread with its own Tokio runtime.
To compile and start the engine in production mode:
cargo run --release
Unlike traditional servers that use a single global runtime, Rustrate uses a hybrid approach:
- Master Thread: Parses the
server.confand spawns worker threads. - Worker Threads: Each worker thread is dedicated to one port/server block and runs an independent
tokio::runtime. - Request Handling: Within each runtime, requests are handled asynchronously.
When spa: true is set, any request that doesn't match a static file will be automatically served the index.html.
Distributed under the MIT License.