Chapter 5. Modeling Multimachine Clusters

Modern web applications are created using multiple distinct parts, sometimes known as services. At the most common level, this is seen with the separation of a web and database server. There can also be cache services, worker queues, and more. Complex websites are often created with hundreds of these services.

When websites are designed this way, it is often called a service-oriented architecture.

As explained in The Tao of Vagrant, Vagrant is supposed to provide the developer with a complete development environment when vagrant up is run. In some cases, this means multiple machines are required or preferable as part of a single development environment.

Historically, development on these sorts of applications was done by cramming all of the required services down onto one machine. This isn’t ideal for many reasons. First, this isn’t how the services exist in production, so it is easy to have things work in development in a way they don’t work in production, quickly leading to “works on my machine” bugs. Second, it is very difficult to test failure scenarios in development. What happens if a node in a cluster dies? What happens if there is too much backlog in the worker queue?

Vagrant lets you accurately model these scenarios using a feature called multimachine environments, which builds multiple virtual machines based on one Vagrantfile.

This is useful for properly isolating separate services as they are in production. You can then put your web ...

Get Vagrant: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.