Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
AeroSocket
A fast, zero-copy WebSocket library for Rust.
AeroSocket handles millions of concurrent connections efficiently. Existing libraries often trade performance for usability. AeroSocket provides both high performance and a clean API.
Key Features
- High Performance: Zero-copy message handling achieves 2.5M messages per second on modest hardware
- Clean API: Natural builder patterns with sensible defaults
- Production Ready: Rate limiting, TLS, graceful shutdown, and comprehensive error handling
Quick Start
Basic echo server:
use *;
async
And a client:
use *;
async
TLS client (wss) with a custom CA and SNI:
use *;
async
Add this to your Cargo.toml:
[]
= { = "0.5", = ["full"] }
= { = "1.0", = ["full"] }
Performance
Benchmarks on AWS c6i.large with Rust 1.75 and 10k concurrent connections:
| Metric | AeroSocket | tokio-tungstenite | fastwebsockets |
|---|---|---|---|
| Throughput (small msgs) | 2.5M msg/s | 1.2M msg/s | 1.8M msg/s |
| Latency P99 | < 50μs | 120μs | 80μs |
| Memory usage | 40% less | baseline | 25% less |
| Zero-copy | Yes | No | Yes |
Results may vary by workload and configuration.
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Application │───▶│ AeroSocket │───▶│ Transport │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│ │
▼ ▼
┌──────────────┐ ┌──────────────┐
│ Protocol │ │ TCP/TLS/QUIC │
└──────────────┘ └──────────────┘
│
▼
┌──────────────┐
│ Zero-Copy │
│ Engine │
└──────────────┘
The zero-copy engine minimizes allocations by passing references instead of copying payloads. This is crucial for high-throughput messaging.
Use Cases
AeroSocket is suitable for:
- Chat applications and collaborative editors
- Trading platforms requiring low-latency market data
- Game servers for multiplayer backends
- IoT systems with sensor networks and real-time monitoring
Features
Implemented:
- Full RFC6455 WebSocket protocol
- TCP and TLS transports
- Rate limiting (independent of backpressure) and backpressure
- Structured logging with tracing
- Graceful shutdown
- Client authentication (Basic/Bearer)
- CORS origin validation
- Per-message deflate compression (
compressionfeature) - Prometheus metrics exporter (
prometheusfeature) - WASM browser client (
aerosocket-wasm) - WASM server-side handlers (
wasm-handlersfeature) - Client automatic reconnection (constant / exponential / jitter)
Planned:
- QUIC transport
- Load balancing
- Kubernetes operator
Installation
[]
= { = "0.5", = ["full"] }
Minimal Setup
[]
= { = "0.5", = false, = ["transport-tcp"] }
Available flags on the aerosocket crate:
full— Enable server, client, TCP, TLS, WASM, serde, rkyvserver— Server APIclient— Client APItransport-tcp— TCP transport (on by default)transport-tls— TLS transporttokio-runtime— Tokio integrationserde— JSON serialization helpersrkyv— Zero-copy serialization helpers
Examples
Zero-copy operations:
let data = from;
conn.send_binary_bytes.await?; // No allocation
WASM Handlers (Preview)
Enable wasm-handlers feature on aerosocket-server to use WASM-based handlers:
[]
= { = "0.5", = ["wasm-handlers"] }
Load WASM handler from file:
use *;
let server = builder
.bind?
.build_with_wasm_handler_from_file?;
WASM ABI:
- Export linear memory
- Export
on_message(ptr: i32, len: i32) -> i32 - Host writes UTF-8 to memory, WASM processes in-place, returns new length
This repo includes two small example crates you can copy or adapt:
aerosocket-wasm-handler— simple text transformer that prefixes messages with"WASM: ".aerosocket-wasm-json-handler— JSON-aware handler that parses the incoming text as JSON, wraps it in a small metadata envelope, and serializes it back to JSON.
Security
Security features include:
- TLS 1.2/1.3 with configurable certificates
- Rate limiting and connection quotas
- Input validation for WebSocket frames
- Memory safety through Rust
- Backpressure to prevent resource exhaustion
Example production configuration:
use *;
let server = builder
.bind?
.max_connections
.backpressure
.tls
.transport_tls
.idle_timeout
.build?;
Documentation
Contributing
See CONTRIBUTING.md for details.
License
MIT or Apache 2.0