What the fork()?
summary
Explains how fork actually powers Spring and Puma: file descriptors travel via send_io / recv_io and are reopened with dup2, Puma balances workers by adding tiny sleeps between select and accept, and Spring preloads then forks to avoid reinitializing Rails. Recommends using posix_spawn or Process.spawn instead of manual fork+exec, running GC four times to be copy‑on‑write friendly (run GC 4 times before fork), measures with PSS, and shows a reduces memory usage up to 80% refork technique that succeeds in practice.
AI-written summary · about
chapters (10)
- 0:00Start
- 8:43Optimizing fork(): vfork()
- 9:40Optimizing fork(): Copy-on-Write
- 10:52Beyond fork(): Threads
- 14:48fork in Ruby
- 17:00Spring process tree
- 26:51'Fork Server' tips
- 28:49Parallel processing tips
- 30:47Fork Safety
- 35:12Experiment #2: Puma Refork
related talks
21mConquering Massive Traffic Spikes in Ruby Applications with Pitchfork
25mPuma or Falcon What's the Best Choice for Scalability?
25mUnderstanding Ruby Web Server Internals: Puma, Falcon, and...
41mHow Puma Works
36mUnicorn Unix Magic Tricks
27mIn-Depth Ruby Concurrency: Navigating the Ruby concurrency landscape
20mSubprocesses, Threads and Fibers
30mGrow Your Unix Beard Using Ruby
