Kino: A high-performance Ractor web server for Ruby 4.0
Kino: A High-Performance Ractor Web Server for Ruby 4.0+
Kino is a cutting-edge web server designed specifically for Ruby 4.0 and beyond, leveraging Ractors to achieve true parallelism. It is built on Rack 3 and utilizes a hybrid architecture: a high-efficiency Rust front-end (powered by tokio and hyper) that distributes traffic to either parallel Ruby Ractors or a threaded fallback mode for legacy compatibility (including Rails).
🏗️ Architecture Overview
Unlike traditional Ruby servers that must fork multiple processes to utilize multiple CPU cores—resulting in significant memory overhead—Kino uses a single process with multiple Ractors.
Key Performance Gains
- Throughput: On 8-core hardware, Kino generally outperforms Puma fork clusters by to on I/O-light tasks.
- Efficiency: In specific benchmark Ractor apps, it can be faster.
- Memory: Uses roughly less RAM than Puma when serving Rails in threaded mode.
- CPU Bound: Ractor mode executes CPU-heavy tasks faster than GVL-constrained threaded mode within the same process.
🛠️ Feature Set
Kino provides a production-ready suite of tools:
- Resilience: Crash supervision with automatic respawning and graceful draining.
- Traffic Control: Bounded queues that trigger
503 Service Unavailablebackpressure. - Security: Hardened intake featuring TLS (via
rustls), body-size limits, and deadlines for TLS handshakes and "slowloris" attacks. - Observability: Live statistics, async application logging, and a customizable
on_errorhook for integration with error trackers. - Developer Experience: A familiar config DSL, a dedicated CLI, and the same worker thread topology users expect.
[!IMPORTANT] Experimental Status: Because Ractors are still experimental in Ruby 4.0, Kino is also considered experimental. It is intended as the premier vehicle for testing Ractors today and the gold standard once they stabilize.
The kino --check Tool
Debugging Ractor::IsolationError can be a nightmare. Kino solves this with a built-in analyzer:
kino --check
This command scans your application and explicitly lists every finding that prevents your app from running in Ractor mode.
❓ Why Kino?
The fundamental limitation of Ruby has long been the GVL (Global VM Lock), which dictates that:
To bypass this, servers traditionally use process forking. However, the memory cost is high because each fork requires a copy of the application. Ractors change this by providing independent locks, allowing true parallel Ruby execution within a single process.
Ruby 4.0 introduced critical improvements—such as Ractor::Port and shareable_proc—which reduced lock contention and made a Ractor-based server viable. For a deeper dive into the Rust integration, see doc/why-kino.md.
📊 Benchmarks
Environment: AWS c7a.2xlarge (8-core AMD EPYC 9R14, 16 GB RAM, Amazon Linux 2023).
Setup: Ruby 4.0.5 + YJIT. Puma uses 8 workers 3 threads. Kino uses 8 workers (1 thread for Ractor, 3 for threaded).
Request Throughput (req/s)
Measured via wrk (8s window, 64 connections).
| Endpoint | Kino :ractor | Kino :ractor (32 workers) | Kino :threaded | Puma (Cluster) |
|---|---|---|---|---|
/plaintext | 229,534 | 250,222 | 182,997 | 216,994 |
/10k | 178,083 | 189,862 | 151,034 | 160,400 |
/cpu (fib) | 77,999 | 70,885 | 66,100 | 58,006 |
/io (5ms) | 1,552 | 5,888 | 6,274 | 4,709 |
/io_native | 1,570 | 6,274 | 6,274 | 4,695 |
Notes on Results:
- Lanes: The
+ lanes(experimental per-worker-queue) config achieved the highest plaintext/10k speeds. - CPU: Ractor mode is faster than the fork cluster on pure CPU tasks.
- I/O Tuning: Since Kino slots are threads (not processes), you can increase
workersto handle I/O wait. Increasing to 32 workers boosted I/O throughput by over Puma while remaining CPU-efficient. - Legacy: The old CPU-tuning recipes are
retiredno longer necessary;threads 1is now the default.
Memory Consumption (PSS)
1. Synthetic Benchmark App (Ractor-shareable)
| Mode | Kino (1 Process) | Puma (8 Workers) | Ratio |
|---|---|---|---|
:ractor (8x1) | 148 MB | 1,068 MB | |
:threaded (8x3) | 107 MB | 1,068 MB |
2. Real Rails App (Threaded Fallback only)
| Mode | Kino :threaded | Puma (8 Workers) | Ratio |
|---|---|---|---|
| PSS | 92 MB | 389 MB |
🚀 Quick Start
Installation
Add the gem to your project or install via CLI. Ensure you are using Ruby 4.0+.
Basic Usage
You can launch the server using the CLI:
kino start --port 3000 --mode ractor
Configuration
Kino supports a flexible DSL for defining worker topology and thread counts, mirroring the familiarity of other Ruby servers while adding Ractor-specific controls.