Vapor HTTP
A dynamically scaling HTTP server 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
Quick Start
use Arc;
use ;
let handler = ;
new.run.await;
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
Installation
[]
= "0.1"
= { = "1", = ["full"] }
= "0.3"
Examples
# Run hello world
# Run JSON API
How Scaling Works
Load Threads CPU/Thread
Idle 1 ~0%
Low 1 ~30-50%
Moderate 1 ~70% (scale up trigger)
Heavy 2 ~70-85% each
Very Heavy 4+ ~85% each, 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