Menu

Post image 1
Post image 2
1 / 2
0

Ractors vs Fibers: Ruby Concurrency Without the Hand-Waving

DEV Community·Temitope·22 days ago
#WnEyyFGt
#part#fibers#ruby#ractor#fiber#fullscreen
Reading 0:00
15s threshold

Ruby has had a concurrency story for years. For most of that time, the story was "threads exist but the GIL means they don't give you parallelism for CPU-bound work, and Fibers are for cooperative scheduling if you want to manage it yourself." Ruby 3 changed the first half of that sentence. Ractors (introduced in Ruby 3.0, still experimental as of 3.3) give you genuine parallelism — multiple Ractors run on multiple OS threads without the GIL constraining them. Fibers (overhauled in Ruby 3.1 with Fiber::Scheduler ) give you async I/O concurrency without threads. These are different tools for different problems. This article puts them side by side with real code so you can reason about which one belongs in your next design. The Core Distinction, Precisely Before the code: get the mental model right. Fibers are cooperative. A Fiber runs until it explicitly yields. The scheduler decides what runs next. There is still only one OS thread (by default).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More