Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Unboxing Ruby Box

Avatar for Satoshi Tagomori Satoshi Tagomori
December 20, 2025
44

Unboxing Ruby Box

Introduction of Ruby Box and its use-case at Ruby Release 30th Anniversary Party #rubyrelease30th

Avatar for Satoshi Tagomori

Satoshi Tagomori

December 20, 2025
Tweet

Transcript

  1. ా᝷ ૱ (Satoshi Tagomori) @tagomoris ͘͞ΒΠϯλʔωοτ (2024.08ʙ) Ϋϥ΢υࣄۀຊ෦ ϓϩμΫτϚωʔδϟ Maintainer/Founder:

    OSS: Ruby, Fluentd, MessagePack, 
 Norikra, Woothee, …
 Event: ISUCON Service: Pathtraq
  2. Unboxing Ruby Box Introduce the use cases of Ruby Box

    • What ’ s “Ruby Box”? • Naming • Feature • Testing in boxes • Running boxes • Playing with boxes
  3. Naming What ’ s “Ruby Box”? • Ruby Box •

    Renamed from “Namespace” after RubyKaigi 2025 • Accessed as “Ruby::Box”
  4. Naming What ’ s “Ruby Box”? • Ruby Box •

    Renamed from “Namespace” after RubyKaigi 2025 • Accessed as “Ruby::Box” • NO MORE “Namespace”!
  5. Feature What ’ s “Ruby Box”? • Separating apps/libs into

    isolated spaces • Load apps/libs in a space • Hide changes from apps/libs in the space to others • Run methods de fi ned in the space with the de fi nition
  6. Before Ruby Box: Global Only All classes/modules are shared in

    the entire Ruby process Ruby Process Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7)
  7. Before Ruby Box: Global Only Monkey patches overwrite things globally

    Ruby Process Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7) class String def +(other) = “self:#{other}” User Library Code
  8. Before Ruby Box: Global Only Monkey patches overwrite things globally

    Ruby Process Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7) class String def +(other) = “self:#{other}” 😵 😵 😵 User Library Code
  9. Ruby Process Ruby Box Using Ruby Box Ruby Box provides

    separation for funky monkey patches! Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7) class String def +(other) = “self:#{other}” User Library Code 😀 😀 😀
  10. Ruby Process Ruby Box Using Ruby Box Ruby Box can

    load different sets of applications&libraries! Application Code App::Func User Library Code DB::Client (v2) Library Code ActiveSupport (v7) Ruby Box Application Code App::Func User Library Code DB::Client (v3) Library Code ActiveSupport (v8) "QQXJUI 0MEFSMJCWFSTJPOT "QQXJUI /FXFSMJCWFSTJPOT
  11. Ruby Process Testing in boxes Don ’ t you need

    a funky monkey patches in tests? • Applications tests sometimes need monkey patches • to mock library behaviors, IO objects, … • Most of tests can run without box. Just some of them can ’ t. • How about running tests in boxes? • Running all tests in boxes is too expensive • Run just some of them in boxes! Ruby Box Application Code Test Case Monkey Patches Test Case Test Case Test Case Test Runner
  12. Ruby Process Server Ruby Process Server Running Boxes (1) Library/middleware

    updates • You ’ re trying to update library versions of your app • Blue-green deployment using cloud services • Long-term parallel testing • Hard things • Building and keeping those infra components • Verifying responses (only with status, without Ruby code) "QQMJCT WFS "QQMJCT WFS Load Balancer 4FOESFRVFTUT  7FSJGZSFTQPOTFTʜ
  13. Server Ruby Process Ruby Box Ruby Box Running Boxes (2)

    Library/middleware updates • Running 2 sets of apps/libraries in 2 boxes • You can run 2 sets in a Ruby process • You can use Ruby code to check diffs! "QQMJCT WFS "QQMJCT WFS Application Server 3PVUFSFRVFTUT BTVTVBM  7FSJGZSFTQPOTFTVTJOH3VCZDPEF
  14. Play, and Fix Ruby Box Way to exit EXPERIMENTAL •

    Fix bugs • It still crashes (as you see) • Design new ways to • Provide hook points (box hides methods) • Stop using global variables (box hides global variable changes) • Work together with RubyGems • RubyGems has internal states (calling RubyGems from boxes doesn ’ t work)
  15. Play, and Fix Ruby Box WE NEED YOU! • There

    should be corner cases! • I need reports from various environments • You can fi nd new bugs of Ruby Box • You can fi x something for Ruby Box! • Libraries, middleware, …
  16. Enjoy Ruby 4.0! with Ruby Box! And, teach me your

    interesting/funky use cases of boxes!