Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

115 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Statico

A blazing-fast HTTP server in Rust for serving static responses. Designed strictly for benchmarking with minimal overhead.

Features

  • Multi-threaded with configurable worker threads
  • Per-thread Tokio runtime (single-threaded) for reduced context switching
  • SO_REUSEPORT for kernel-level load balancing across threads
  • Configurable responses: custom status codes, headers, and body
  • File-based responses via @filename syntax
  • Optional io_uring support on Linux (compile-time feature)
  • mimalloc allocator by default for reduced memory allocation overhead
  • Cross-platform: Linux, macOS, Windows

Performance

The following benchmark compares Statico against other popular HTTP servers and frameworks in a synthetic scenario where each server returns a minimal static response from memory. All servers were configured for maximum performance (no logging, CPU pinning where applicable, in-memory responses).

Performance Benchmark

Benchmark Results 1024 connections (requests/second)

Server1 thread2 threads4 threads
statico (monoio)656,517922,8251,436,420
statico (compio)652,743845,7681,395,047
statico (tokio-uring)589,086932,1431,393,573
statico (glommio)400,036816,9361,140,535
statico (smol)323,267525,824862,047
statico399,025638,7671,071,433
nginx (return)286,960379,974832,082
HAProxy181,127253,796515,162
Go net/http69,212168,220366,084
Go fasthttp172,359273,395605,603
Axum (Rust)121,680224,712414,640
actix-web (Rust)213,756343,037798,809

Key observations:

  • All four io_uring runtimes exceed 1.1M+ req/s at 4 threads: tokio-uring leads at 1.39M, followed by monoio (1.36M), compio (1.27M), and glommio (1.14M)
  • compio and glommio show super-linear scaling (2.5× and 2.85× respectively from 1→4 threads), suggesting better CPU cache utilisation at higher parallelism
  • io_uring runtimes are 27–64% faster than standard Tokio: at 1 thread monoio is ~64% ahead (656K vs 399K req/s); the gap narrows but persists at 4 threads (~30%)
  • Standard Statico already outperforms nginx by ~40% single-threaded (399K vs 287K req/s) and scales significantly better at higher thread counts
  • At 4 threads the top io_uring runtimes outperform Go fasthttp by 2.3×, actix-web by 1.7×, and Axum by 3.4×

Why is Statico fast?

  • mimalloc as the default global allocator reduces memory allocation overhead
  • Single-threaded Tokio runtimes per worker reduce contention across cores
  • SO_REUSEPORT for efficient kernel load balancing
  • File content loaded once at startup; body bytes cached as reference-counted Bytes
  • io_uring runtimes pre-encode the full HTTP response (headers + body) once at startup — zero allocation per request
  • io_uring runtimes handle HTTP pipelining: multiple requests parsed and answered in a single syscall round-trip
  • io_uring support on Linux (up to 40% faster)
  • glommio pins each worker thread to a dedicated CPU core for cache locality

Building

# Standard build (mimalloc enabled by default)
cargo build --release
# With specific runtimes (each requires its own feature flag)
cargo build --release --features tokio_uring # tokio-uring runtime
cargo build --release --features monoio # monoio runtime
cargo build --release --features glommio # glommio runtime
cargo build --release --features smol # smol runtime
cargo build --release --features compio # compio runtime (cross-platform)
cargo build --release --features full # all runtimes + mimalloc (named feature)
cargo build --release --all-features # all runtimes + mimalloc (cargo flag)

Usage

./target/release/statico [OPTIONS]

Options

OptionDescription
-t, --threads <THREADS>Number of worker threads to spawn (default: number of CPUs)
-p, --ports <PORTS>Ports to listen on, supports ranges (e.g., 8080, 8080,8100-8200) (default: 8080)
--bind-allEach thread binds to all specified ports (default: ports are balanced across threads)
-a, --address <ADDRESS>Address to listen on. If not specified, listen on all interfaces
-s, --status <STATUS>HTTP status code to return (default: 200)
-b, --body <BODY>Response body content (optional). Use @filename to load from file
-H, --header <HEADER>Custom headers in "Name: Value" format (can be specified multiple times)
-d, --delay <DELAY>Delay before sending the response (e.g., 100ms, 1s, 500us)
--body-delay <DELAY>Delay before sending the body only — HTTP headers are flushed immediately (e.g., 100ms, 1s, 500us). Supported by tokio and smol runtimes.
-m, --meterEnable real-time metrics: prints req/s, req Gbps, res/s, res Gbps every second. On exit (Ctrl+C) prints totals and, when multiple ports are used, per-port statistics.
-v, --verboseIncrease verbosity (can be repeated; supported by tokio and smol runtimes):
-v — request line + response status line
-vv — + request/response headers
-vvv — + body (readable text; non-printable bytes shown as inline hex)
-vvvv — + body as full hexdump
--http2Enable HTTP/2 (h2c) support (not supported with io_uring or smol runtimes)
--runtime <RUNTIME>Runtime to use: tokio, smol, tokio-uring, monoio, glommio, compio (default: tokio)
--cert <PATH>Path to TLS certificate (PEM). Enables HTTPS (requires --key). Supported by the tokio runtime only.
--key <PATH>Path to TLS private key (PEM). Enables HTTPS (requires --cert). Supported by the tokio runtime only.
--receive-buffer-size <SIZE>Receive buffer size
--send-buffer-size <SIZE>Send buffer size
--listen-backlog <SIZE>Listen backlog queue
--tcp-nodelaySet TCP_NODELAY option
--uring-entries <SIZE>Size of the io_uring Submission Queue (SQ) (default: 4096, Linux only)
--uring-sqpoll <MS>Enable kernel-side submission polling with idle timeout in milliseconds (Linux only)
-h, --helpPrint help
-V, --versionPrint version

Examples

# Basic server on port 8080
./target/release/statico
# Custom port and threads
./target/release/statico --ports 3000 --threads 4
# Multiple ports and ranges
./target/release/statico --ports 8080,8443,9000-9010
# Bind all threads to all ports (SO_REUSEPORT load balancing)
./target/release/statico --ports 8080,8081 --threads 4 --bind-all
# Custom response with headers
./target/release/statico --status 201 --body "Hello" -H "Content-Type: text/plain"# Multiple headers
./target/release/statico -H "Content-Type: application/json" -H "X-API-Key: secret"# JSON response
./target/release/statico -b '{"msg": "hi"}' -H "Content-Type: application/json"# Serve from file
./target/release/statico --body @response.json -H "Content-Type: application/json"# io_uring runtimes (Linux only, requires feature flags)
./target/release/statico --runtime tokio-uring --threads 8
./target/release/statico --runtime monoio --threads 8
./target/release/statico --runtime glommio --threads 8
# compio runtime (Cross-platform completion-based I/O, requires feature flag)
./target/release/statico --runtime compio --threads 8
# Add delay (latency simulation)
./target/release/statico --delay 100ms
# Delay body only (headers sent immediately, then body after delay)
./target/release/statico --body-delay 500ms
# Verbose logging
./target/release/statico -v # request/response line only
./target/release/statico -vv # + headers
./target/release/statico -vvv # + body (text)
./target/release/statico -vvvv # + body (hexdump)# Real-time metrics (req/s, Gbps); final report printed on Ctrl+C
./target/release/statico --meter
# Real-time metrics with per-port breakdown on exit
./target/release/statico --ports 8080,8081 --meter
# HTTPS (TLS) — supported by the `tokio` runtime only
./target/release/statico --cert cert.pem --key key.pem --ports 8443
# HTTPS with HTTP/2 (ALPN negotiates h2)
./target/release/statico --cert cert.pem --key key.pem --http2

Architecture

Threading Model

  • Main thread parses arguments and spawns workers
  • Each worker creates its own socket with SO_REUSEPORT
  • Each worker runs a single-threaded runtime (Tokio, smol, or io_uring-based)
  • Kernel load-balances connections across threads via SO_REUSEPORT

Runtimes

RuntimeFeature FlagNotes
tokio (default)Single-threaded Tokio runtime per worker; supports HTTP/1.1 and HTTP/2, verbose, body-delay, and HTTPS (TLS)
smolsmolAlternative async runtime via smol-hyper; supports HTTP/1.1 only; supports verbose and body-delay
tokio-uringtokio_uringio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
monoiomonoioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only
glommioglommioio_uring; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)
compiocompioio_uring/IOCP; pre-built responses; HTTP pipelining; HTTP/1.1 only; CPU-pinned (one core per thread)

Note:tokio-uring, monoio, and glommio are Linux-only and require the corresponding feature flags at compile time. compio is cross-platform.

Pre-built responses (io_uring / completion-based runtimes)

tokio-uring, monoio, glommio and compio encode the full HTTP response — status line, headers, and body — into a single byte buffer once at startup. Every subsequent request reuses that buffer without any allocation or serialization overhead.

The tokio and smol runtimes assemble the response per-connection using Hyper, caching only the body bytes as a reference-counted Bytes value.

Use Cases

  • Load testing and benchmarking HTTP clients
  • Mocking services and API endpoints
  • Static file serving without full web server overhead
  • Health check endpoints
  • Development and testing scenarios

License

MIT OR Apache-2.0

About

A blazing-fast HTTP server implemented in Rust that serves static responses at lightning speed

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages