Senior Track Roadmap

Ruby: concurrency

This course compares Ruby's concurrency models: threads, Fibers, processes and Ractors. It separates work that waits from work that computes and explains why CRuby threads overlap I/O while CPU-bound work needs processes or Ractors. It covers fork and copy-on-write, the Ractor sharing rules and the Ruby 4.0.1 API, and the isolation error Active Record raises inside a Ractor. It treats thread safety as a design decision, with Mutex, Queue and per-request state. The last lesson applies a decision framework to three workloads inside a Rails process.

What you'll learn

  • ✓How threads, Fibers, processes and Ractors differ in parallelism and object sharing
  • ✓Why CRuby threads overlap I/O waits but not CPU-bound work
  • ✓How fork, copy-on-write and serialization shape the cost of processes
  • ✓The Ractor sharing rules, the Ruby 4.0.1 Ractor API and its current limits with Rails
  • ✓Designing thread-safe state with Mutex, Queue and ActiveSupport::CurrentAttributes
  • ✓Choosing a model for a workload and reading Puma's thread and connection settings
Free preview · Lesson 1 4 min read

Three models, one decision

A ticket lands on your board: "the checkout page calls four services and takes 1.8 seconds". You already know the fix is to stop calling them one after another. What you have to decide is which of Ruby's concurrency models to reach for, and that decision has three real candidates, not one.

Read the full lesson free →

Curriculum

7 lessons
Type to start searching...