small medium large xlarge

The dRuby Book: Distributed and Parallel Computing with Ruby


Cover image for The dRuby Book
Pages 280
Release P1.0 (2012-03-21)
ISBN 978-1-93435-693-7

Learn from legendary Japanese Ruby hacker Masatoshi Seki in this first English-language book on his own Distributed Ruby library. You’ll find out about distributed computing, advanced Ruby concepts and techniques, and the philosophy of the Ruby way—-straight from the source.

About This Book

dRuby has been part of the Ruby standard library for more than a decade, yet few know the true power of the gem. Completely written in Ruby, dRuby enables you to communicate between distributed Ruby processes as if there were no boundaries between processes. This is one of the few books that covers distributed and parallel programming for Ruby developers.

The dRuby Book has been completely updated and expanded from its Japanese version, with three new chapters written by Masatoshi-san. You’ll find out about the design concepts of the dRuby library, and walk through step-by-step tutorial examples. By building various distributed applications, you’ll master distributed programming as well as advanced Ruby techniques such as multithreading, object references, garbage collection, and security. Then you’ll graduate to advanced techniques for using dRuby with Masatoshi-san’s other libraries, such as eRuby and Rinda—-the Ruby version of the Linda distributed tuplespace system. In the three new chapters, you’ll see how to integrate dRuby and eRuby, get a thorough grounding in parallel programming concepts with Rinda, and create a full text search system using Drip.

Step by step, you’ll gain mastery of dRuby and distributed computing.

What You Need:

Ruby 1.9.2 or above. All exercises were run on OS X, though it should work on any operating system. You are expected to be comfortable reading Ruby code, as we do not explain basic syntax.

Q&A with author Masatoshi Seki

Q. In a nutshell: what is dRuby?

A. dRuby is a distributed object system. More precisely, it’s a library for Remote Method Invocation (RMI). You can easily publish your objects to others, or call objects in other processes.

Q. How is dRuby different from other distributed object systems? What’s unique about it?

A. The biggest difference is that dRuby is designed for (and written in) Ruby. It is ridiculously easy to start using distributed object systems. dRuby inherits lots of good parts from Ruby. For example, you can use a method with block, and dRuby dynamically chooses how to send a remote object, so you don’t have to describe an interface or its transportation method.

Q. How can dRuby and distributing programming change the way we develop our apps?

A. With the rise of web services, inter-process communication became a popular way to architect systems. You can choose inter-process communication not only for large-scale systems, but also for making small tools. Consequently, we’re facing issues with dealing with inter-process communication more than ever.

With dRuby, you can concentrate on building the core of your system while dRuby takes care of the complex inter-process communication layer. The easier it becomes to write an inter-process communication layer, the more often you will choose an inter-process communication architecture when you design your system.

Q. You’ve written a few other libraries – how do they interact with dRuby and what will we find useful about them?

In my book, I used dRuby as a glue to integrate with various other libraries of mine. For example, I used it with Rinda to turn its inter-thread coordination mechanism into inter-process coordination. I also turned the ERB templating system into a separate server to minimize preprocessing cost.

Many of my libraries have profound thoughts and ideas behind a relatively small number of APIs. It’s hard to grasp the whole picture just by glancing at API references. In this book, I provide various examples for combining these libraries to reveal their full intention and usefulness.

Q. If there’s one thing we should take away from your book, what would that be?

Many of my libraries are small and simple, but with deep philosophy behind them. My goal is for you to understand the thinking behind my libraries and use this understanding to strengthen your design skills.

Read the reviews .

You Might Also Like

  • Cover Image For Programming Concurrency on the JVM…
  • Cover Image For Programming Ruby 1.9…
  • Cover Image For Programming Erlang…


Each of our books has its own dedicated discussion area, where readers help each other out. Many authors also choose to drop by.

Join in…

Here are some recent topics:

Contents & Extracts

Full Table of Contents



  • Introducing dRuby
    • Hello, dRuby
    • Architectures of Distributed Systems excerpt
  • Understanding dRuby
    • Integrating dRuby with eRuby
    • Pass by Reference, Pass by Value
    • Multithreading excerpt
  • Process Coordination
    • Coordinating Processes Using Rinda
    • Extending Rinda
    • Parallel Computing and Persistence with Rinda excerpt (NOTE: use “gem install more_rinda” to try it out)
    • Drip: A Stream-Based Storage System
    • Building a Simple Search System with Drip
  • Running dRuby and Rinda in a Production Environment
    • Handling Garbage Collection
    • Security in dRuby

Brought to You By

Author Masatoshi Seki is a Ruby committer and an author of several Ruby standard libraries including dRuby, eRuby, and Rinda. He’s an expert in object-oriented programming, distributed systems, and eXtreme programming. His favorite Ruby methods are “method_missing” and “inject”. He’s the author of Distributed Object Programming with dRuby and Distributed Web Programming with dRuby, of which this book is an updated and expanded translation.

Translator Makoto Inoue is a database administrator turned Ruby developer living in London. He is passionate about evangelizing interesting, lesser-known technologies. He speaks about mobile development, NoSQL, and Real Time Web at conferences and meetups.