Vapor HTTP
A dynamically scaling HTTP server written in Rust that auto-tunes thread count to maintain 85% CPU utilization per thread.
Features
- Auto-scaling: Starts at 1 thread, grows as needed up to 256 threads
- Target utilization: Scales up at >70% CPU usage, scales down at <30%
- Backpressure: Limits concurrent connections to available threads, preventing FD exhaustion
- Zero config: Works out of the box with sensible defaults
- Minimal: ~2MB memory baseline, bare metal performance
Quick Start
use Arc;
use ;
let handler = ;
new.run.await;
Installation
[]
= "0.1"
= { = "1", = ["full"] }
= "0.3"
Configuration
Custom Port
new.port.run.await;
Custom Thread Pool
use DynamicThreadPool;
let pool = with_limits;
new.pool.run.await;
Response Types
ok // 200 OK, text/plain
json // 200 OK, application/json
not_found // 404 Not Found
internal_error // 500 Internal Server Error
status.body // Custom status code
ok.with_header
Request Object
Examples
How Scaling Works
| Load | Threads | CPU/Thread |
|---|---|---|
| Idle | 1 | ~0% |
| Low | 1 | ~30-50% |
| Moderate | 1 | ~70% (triggers scale up) |
| Heavy | 2-4 | ~70-85% each |
| Very Heavy | 4+ | Scales as needed |
- Scale up: +1 thread when utilization > 70%
- Scale down: -1 thread when utilization < 30%
- Cooldown: 100ms between scaling decisions
- Max threads: 256
License
MIT