Kino and Ractors: A Glimpse at Ruby's Memory-Efficient Parallel Future
How ractors could shape the way Ruby apps scale, and it has a Rusty taste.
For years, the standard answer to Ruby’s Global VM Lock has been to fork. Puma workers, Sidekiq processes, you name it; if you wanted more than one CPU core, you paid for it with memory. Each forked worker gets its own copy of the application, and while copy-on-write helps at first, that shared memory fragments as objects get allocated and caches grow.
Ractors promised a different path: true parallelism within a single process, with isolation instead of forking. But promises are cheap. What does it actually look like when you try to run real code on Ractors?
The most concrete answer so far comes from Kino, a Ractor-compatible web server, paired with community experiments running Rails on it.
How Kino Works Under the Hood
Kino is built for Ruby 4.0+ around Ractors from the ground up. It uses a Rust Tokio/Hyper front-end to own the network layer, ie. accepting connections, parsing HTTP asynchronously, then dispatches requests to Ractor-parallel Ruby workers within a single process. It’s Rack 3-based and offers multiple modes: :ractor for true parallel execution, :threaded as a fallback for apps that aren’t Ractor-safe yet, and :auto to pick based on environment.
The core promise: instead of paying for a full application copy per worker, you get parallel CPU utilization inside one process. Official benchmarks from the project claim roughly 7× less memory in ractor mode compared to a Puma cluster, with +32% throughput on pure CPU workloads.
Ruby Ractor 101: The Short Version
I already wrote about the basics of Ruby Ractors in my 2 parts series “The Actor Model on Ruby: A Side-by-Side with Elixir/OTP”, so for the win you may read Part 1 and Part 2 before continuing here.
Before the Rails story makes sense, you need just to keep in mind the three rules Ractors enforce. Everything else follows from them.
A Ractor is Ruby’s unit of true parallelism: an isolated execution context with its own heap, its own global-variable namespace, and its own copy of anything it doesn’t share. Unlike threads, which run under a single Global VM Lock and freely mutate the same objects, Ractors actually run at the same time on different cores, but only because Ruby forbids them from touching each other’s memory. Any object crossing a Ractor boundary must be either shareable (frozen, recursively, so nobody can mutate it), copied (the safe default, but expensive for large graphs), or moved (fast, but the sender loses access entirely). Globals, class variables, and unshareable class-level state are main-Ractor-only, which is why frameworks like Rails - built on exactly that kind of global state - aren’t Ractor-safe yet. The payoff is memory: instead of forking a full copy of your app per worker, you run many Ractors in one process and share the immutable parts, which is precisely the bet Kino makes to deliver its ~7× memory savings.
Rule 1: Shareable or copied. An object crossing a Ractor boundary must either be shareable (frozen, recursively) or be deep-copied. Primitives like integers, symbols, nil, frozen strings, and Class objects are shareable for free. Everything else needs Ractor.make_shareable:
CONFIG = Ractor.make_shareable({ timeout: 30, retries: 3 })
Ractor.new { CONFIG[:timeout] }.value #=> 30
For constants, the pragma automates it:
# shareable_constant_value: literal
DEFAULTS = { pool_size: 5, timeout: 30 } # auto-frozen, shareable
Rule 2: Move is fast but destructive. By default, send deep-copies. With move: true, ownership transfers and the sender’s reference becomes a Ractor::MovedObject:
data = ["a", "b"]
r = Ractor.new { Ractor.receive }
r.send(data, move: true)
data << "c" # raises Ractor::MovedError
This only works for T_STRING, T_ARRAY, and T_FILE - you can’t move a Thread.
Rule 3: Globals and class state are main-Ractor-only. Global variables, class variables, and unshareable class-level ivars raise Ractor::IsolationError from a non-main Ractor:
$counter = 0
Ractor.new { $counter += 1 }.join
#=> Ractor::RemoteError: can not access global variables from non-main Ractors
That’s the whole model. Shareable, copied, or moved; nothing else crosses the boundary. The memory savings Kino achieves come directly from this discipline, and the cost is that code assuming a single global VM often needs restructuring. For a deeper dive, the Ractor.make_shareable, shareable_constant_value, and Ractor::MovedError docs are the place to start.
The Rails Reality Check
Here’s where things get interesting (and complicated). Rails is not yet Ractor-safe. The framework stores global state in class-level instance variables (Rails.application, Rails.cache, Rails.logger, every mattr_accessor), and Ruby forbids non-main Ractors from reading or writing those.
A community gem called ractor-rails-shim attempts to bridge this gap. It reroutes Rails’ global accessors through Ractor-safe storage (ActiveSupport::IsolatedExecutionState or Ractor.store_if_absent) and freezes the app graph with Ractor.make_shareable. A real Rails 8.1 app running through this shim under kino -m ractor produced these numbers:
| Server | /up (rps) |
GET /posts (rps) |
Peak mem (MB) |
|---|---|---|---|
| Falcon forked | 22,637 | 5,296 | 736 |
| Puma clustered | 19,338 | 3,987 | 720 |
Kino :ractor |
3,136 | 655 | 166 |
The memory story is dramatic: 166 MB versus ~720 MB. But the throughput on database-backed routes collapsed. A stackprof profile showed 86% of time in Ruby core/Ractor runtime, spread across ~429 allocations per request, each more expensive under Ractor's isolated heaps and cross-Ractor GC coordination.
The fix turned out to be counterintuitive. Disabling YJIT brought `/up` from 2,800 to 13,269 rps. Replacing a pagination gem (Kaminari) that mutated method tables per request, creating global barriers and cache invalidation across all workers, took `GET /posts` from 419 to 1,409 rps. The overhead wasn't in Kino's dispatch; it was in code that assumes single Ractor execution.
The Escape Hatch Problem
Shopify’s earlier experiment with Basecamp’s Writebook exposed the same pattern from a different angle. They measured ~7× lower memory with 8 Ractors versus 8 forked Puma workers using Proportional Set Size (PSS), which fairly accounts for shared pages.
But latency on heavy endpoints increased. The reason: native extensions that aren’t Ractor-compatible have to be dispatched back to the main Ractor through an escape hatch. Every cross-Ractor round-trip costs time, and the penalty scales with how much of the request path touches incompatible code.
This isn’t a failure of Kino or Ractors. It’s a measurement of the transition cost. The memory opportunity is real, but the benefit depends on how much of your request path can remain natively Ractor-safe.
Where Kino Fits Today
Kino ships a diagnostic tool worth knowing about:
kino --check
This scans your application for Ractor incompatibilities, giving you a map of where the escape hatches will be needed.
For pure Ruby workloads and CPU-bound processing, I/O-light APIs, anything without heavy Rails coupling, Kino’s :ractor mode delivers on its promises. The official benchmarks show /plaintext at 229,534 rps and /cpu (fib) at 77,999 rps, both beating a Puma cluster while using a fraction of the memory.
For Rails applications, the :threaded fallback still offers memory savings (roughly 4× less than Puma in a hello-world test) but runs on the GVL, so throughput doesn’t scale across cores.
The Rails team’s first milestone is a freshly scaffolded app that’s fully Ractor-safe: routing, request/response cycle, view rendering, translations, database queries, asset pipeline, and Active Support helpers. Until that lands upstream, Kino’s Ractor mode is a proving ground, not a production drop-in.
But the data is now concrete. You can see the memory graph. You can see where latency hurts. You can profile your own allocations and ask: which of these 429 per-request allocations are avoidable? Which gems mutate global state? What would my app look like if it were designed for Ractor isolation from the start?
The fork-and-pray era of Ruby scaling has a credible alternative on the horizon. It runs on Ractors, inside a single process, behind a Rust front-end. And it’s asking uncomfortable questions about the assumptions baked into our frameworks.