The dRuby Book

What’s in This Book

This book covers a wide range of topics related to distributed computing and more. The main focus is on dRuby, but you’ll also find out about other libraries I created, such as ERB, Rinda, and Drip, and how to integrate them with dRuby. You’ll learn about some advanced Ruby techniques, such as multithreading, security, and garbage collection. dRuby exposes some unique problems that you might not often encounter, so you’ll find out how to deal with those situations too.

Chapter 1, Hello, dRuby

The fun part starts here. We’ll launch multiple terminals and access dRuby via irb. You’ll learn how to use dRuby and write some simple programs to explore the power of dRuby.

Chapter 2, Architectures of Distributed Systems

You’ll learn about distributed object systems in general and how dRuby is different from others.

Chapter 3, Integrating dRuby with eRuby

eRuby is a templating system often used to render HTML. ERB is an implementation of eRuby that I wrote, and it’s also part of the Ruby standard libraries. In this chapter, I’ll explain how easily you can integrate ERB with dRuby.

Chapter 4, Pass by Reference, Pass by Value

Even though dRuby is a seamless extension of Ruby, there are a few differences. In this chapter, you’ll learn two ways of exchanging objects over processes: by reference and by value.

Chapter 5, Multithreading

You need to know about multithreading to have a better understanding of how dRuby works. When using dRuby, multiple processes work in coordination with multithreading. In this chapter, you’ll learn about threading in Ruby and how you can synchronize threads, which is important for avoiding unexpected bugs.

Chapter 6, Coordinating Processes Using Rinda

Linda is a system for multiple processes to coordinate with one another. In this chapter, you’ll learn how to coordinate processes via TupleSpace using Rinda, the Ruby implementation of Linda.

Chapter 7, Extending Rinda

Rinda started as a port of Linda, but I added a few extra functionalities I thought necessary while developing applications with Rinda. You’ll also learn about a service registration service called Ring, which comes with Rinda.

Chapter 8, Parallel Computing and Persistence with Rinda

After releasing Rinda, I created an extension library called more_rinda that adds parallel computing capability and a persistence layer to Rinda. They are not part of Ruby standard libraries but have interesting extensions—with some drawbacks. I’ll explain why. If you’re interested in parallel computing or NoSQL, this is a chapter you shouldn’t miss.

Chapter 9, Drip: A Stream-Based Storage System

If more_rinda is the trial and error of all my attempts at the art of distributed programming, Drip is my solution. Drip is a stream-based storage system, with fault tolerance and a messaging system built in. I will explain the basic usage of Drip by comparing Queue and Hash and also talk about the design policy behind Drip.

Chapter 10, Building a Simple Search System with Drip

We’ll create a simple desktop search system using Drip. You will experience how you can use Drip as both a storage system and a process coordination tool. We will also talk about the RBTree data structure we used in the search system, which Drip uses internally.

Chapter 11, Handling Garbage Collection

You may not need to worry about garbage collection when you use Ruby daily, but there are a few things you have to know when you use dRuby. Ruby has a garbage collection system that cleans up unused objects, but this doesn’t consider how dRuby passes references across processes. In this chapter, you’ll see how to protect dRuby referenced objects from garbage collection and what you have to know about garbage collection when you are building applications.

Chapter 12, Security in dRuby

dRuby lets you communicate with other processes seamlessly, but this also means you have to be more careful about security to prevent unintended access. You’ll learn what dRuby does and doesn’t do when it comes to security and what you have to do at the application level. I’ll also explain how to use dRuby over networks using SSH port forwarding.

Everyone should read Chapter 1, Hello, dRuby and Chapter 6, Coordinating Processes Using Rinda to get a basic understanding of dRuby and Rinda. If you already use dRuby and are seeking some practical tips, then you’ll find the following chapters packed with detailed explanations: Chapter 4, Pass by Reference, Pass by Value; Chapter 5, Multithreading; Chapter 11, Handling Garbage Collection; and Chapter 12, Security in dRuby. If you’re new to dRuby, you might find the level of detail in these chapters overwhelming. Feel free to read only the first section of these chapters and jump to the following chapters. You can always refer to these chapters as a reference when you encounter problems using dRuby.

Newly added for this English edition or greatly modified are the following chapters: Chapter 3, Integrating dRuby with eRuby; Chapter 8, Parallel Computing and Persistence with Rinda; and Chapter 9, Drip: A Stream-Based Storage System. They’re packed with unique ways to use each library and also contain many new concepts.