tako-rs 1.0.0

Tako is a lightweight async web framework for Rust.
Documentation

Build Workflow Crates.io License

๐Ÿ™ Tako โ€” Lightweight Async Web Framework in Rust

Tako ("octopus" in Japanese) is a pragmatic, ergonomic and extensible async web framework for Rust. It aims to keep the mental model small while giving you firstโ€‘class performance and modern conveniences outโ€‘ofโ€‘theโ€‘box.

Blog posts:

โœจ Highlights

  • Multi-protocol โ€” HTTP/1.1, HTTP/2, HTTP/3 (QUIC), WebSocket, WebTransport, SSE, gRPC, TCP, UDP, Unix sockets, PROXY protocol.
  • Dual runtime โ€” First-class support for both Tokio and Compio async runtimes (including TLS + HTTP/2 on both).
  • 22+ extractors โ€” Strongly-typed request extractors: JSON, form, query, path, headers, cookies (signed/private), JWT, Basic/Bearer auth, API key, Accept, Range, protobuf, and more.
  • Rich middleware โ€” Auth (JWT, Basic, Bearer, API key), CSRF, sessions, body limits, request IDs, security headers, upload progress, compression, rate limiting, CORS, idempotency, metrics.
  • SIMD JSON โ€” Route-level configurable SIMD-accelerated JSON parsing (sonic-rs / simd-json) with automatic size-based dispatch.
  • Background job queue โ€” In-memory task queue with named handlers, retry policies (fixed / exponential backoff), delayed jobs, dead letter queue, and graceful shutdown.
  • Streaming & SSE โ€” Built-in helpers for Server-Sent Events and arbitrary Stream responses.
  • GraphQL โ€” Async-GraphQL integration with extractors, responses, and WebSocket subscriptions.
  • OpenAPI โ€” Automatic API documentation via utoipa or vespera integration.
  • TLS โ€” Native rustls-based HTTPS with ALPN negotiation.
  • Compression โ€” Brotli, gzip, deflate, and zstd response compression.
  • Signals โ€” In-process pub/sub signal system for decoupled event-driven architectures.
  • Static files & file streaming โ€” Serve directories and stream files with range request support.
  • Graceful shutdown โ€” Drain in-flight connections before exit across all server variants.

Feature Matrix

Transports & Protocols

Protocol Tokio Compio Feature flag
HTTP/1.1 โœ… โœ… default
HTTP/2 โœ… โœ… http2
HTTP/3 (QUIC) โœ… โ€” http3
TLS (rustls) โœ… โœ… tls / compio-tls
WebSocket โœ… โœ… default / compio-ws
WebTransport โœ… โ€” webtransport
SSE โœ… โœ… default
gRPC (unary) โœ… โ€” grpc
Raw TCP โœ… โ€” default
Raw UDP โœ… โ€” default
Unix sockets โœ… โ€” default (unix only)
PROXY protocol v1/v2 โœ… โ€” default

Extractors (22+)

Extractor Description
Json<T> JSON body (with optional SIMD acceleration)
Form<T> URL-encoded form body
Query<T> URL query parameters
Path<T> Route path parameters
Params Dynamic path params map
HeaderMap Full request headers
Bytes Raw request body
State<T> Shared application state
CookieJar Cookie reading/writing
SignedCookieJar HMAC-signed cookies
PrivateCookieJar Encrypted cookies
BasicAuth HTTP Basic authentication
BearerAuth Bearer token extraction
JwtClaims<T> JWT token validation & claims
ApiKey API key from header/query
Accept Content negotiation
AcceptLanguage Language negotiation
Range HTTP Range header
IpAddr Client IP address
Protobuf<T> Protocol Buffers body
SimdJson<T> Force SIMD JSON parsing
Multipart Multipart form data

Middleware

Middleware Description
JWT Auth Validate JWT tokens on routes
Basic Auth HTTP Basic authentication
Bearer Auth Bearer token validation
API Key Auth Header or query-based API key
CSRF Double-submit cookie CSRF protection
Session Cookie-based sessions (in-memory store)
Security Headers HSTS, X-Frame-Options, CSP, etc.
Request ID Generate/propagate X-Request-ID
Body Limit Enforce max request body size
Upload Progress Track upload progress callbacks
CORS Cross-Origin Resource Sharing
Rate Limiter Token-bucket rate limiting
Compression Brotli / gzip / deflate / zstd
Idempotency Idempotency key deduplication
Metrics Prometheus / OpenTelemetry export

Feature Flags

Flag Description
http2 HTTP/2 support (ALPN h2)
http3 HTTP/3 over QUIC (enables webtransport)
tls HTTPS via rustls
compio Compio async runtime (alternative to tokio)
compio-tls TLS on compio
compio-ws WebSocket on compio
grpc gRPC unary RPCs with protobuf
protobuf Protobuf extractor (prost)
plugins CORS, compression, rate limiting
simd SIMD JSON parsing (sonic-rs + simd-json)
multipart Multipart form-data extractors
file-stream File streaming & range requests
async-graphql GraphQL integration
graphiql GraphiQL IDE endpoint
signals In-process pub/sub signal system
jemalloc jemalloc global allocator
zstd Zstandard compression (in plugins)
tako-tracing Distributed tracing subscriber
utoipa OpenAPI docs via utoipa
vespera OpenAPI docs via vespera
metrics-prometheus Prometheus metrics export
metrics-opentelemetry OpenTelemetry metrics export
zero-copy-extractors Zero-copy body extraction
client Outbound HTTP client

Documentation

API Documentation

MSRV 1.87.0 | Edition 2024

Tako in Production

Tako already powers real-world services in production:

๐Ÿ”ฅ Benchmarking the Hello World

+---------------------------+------------------+------------------+---------------+
| Framework ๐Ÿฆ€              |   Requests/sec   |   Avg Latency    | Transfer/sec  |
+---------------------------+------------------+------------------+---------------+
| Tako (not taco! ๐ŸŒฎ)       |    ~148,800      |    ~649 ยตs       |   ~12.6 MB/s  |
| Tako Jemalloc             |    ~158,059      |    ~592 ยตs       |   ~13.3 MB/s  |
| Axum                      |    ~153,500      |    ~607 ยตs       |   ~19 MB/s    |
| Actix                     |    ~126,300      |    ~860 ยตs       |   ~15.7 MB/s  |
+---------------------------+------------------+------------------+---------------+

๐Ÿ‘‰ Command used: `wrk -t4 -c100 -d30s http://127.0.0.1:8080/`

๐Ÿ“ฆ Installation

Add Tako to your Cargo.toml:

[dependencies]
tako-rs = "*"

๐Ÿš€ Quick Start

Spin up a "Hello, World!" server in a handful of lines:

use anyhow::Result;
use tako::{
    responder::Responder,
    router::Router,
    types::Request,
    Method,
};
use tokio::net::TcpListener;

async fn hello_world(_: Request) -> impl Responder {
    "Hello, World!".into_response()
}

#[tokio::main]
async fn main() -> Result<()> {
    // Bind a local TCP listener
    let listener = TcpListener::bind("127.0.0.1:8080").await?;

    // Declare routes
    let mut router = Router::new();
    router.route(Method::GET, "/", hello_world);

    // Launch the server
    tako::serve(listener, router).await;

    Ok(())
}

๐Ÿ“œ License

MIT โ€” see LICENSE for details.

Made with โค๏ธ & ๐Ÿฆ€ by the Tako contributors.