All Collections Getting Started with Hatchbox What are Clusters in Hatchbox?

What are Clusters in Hatchbox?

Clusters are a group of servers with separate responsibilities

Updated

Hatchbox groups your servers into "Clusters". In the cluster, each server is assigned roles to keep track of it's responsibilities. This enables Hatchbox to automatically assign firewall rules, add/remove IPs from load balancers, etc.

Example Production Cluster

Let's look at a production cluster of 5 servers:

  1. Load balancer server
  2. Web server
  3. Web server
  4. Background worker and cron server
  5. PostgreSQL server

With this cluster, our load balancer knows to forward HTTP requests to the web servers. Our web and background worker servers are the only ones the application code needs to be deployed to. The Postgres server needs to allow access from the web and background worker servers from their private IPs.

If we add a new web server to the cluster, it will be automatically added to the load balancer's list of upstreams and added to the firewall rules on the Postgres server.

Example Staging Cluster

For staging, you want to replicate your production environment but on a smaller scale.

  1. A server with load balancer and web server roles
  2. A server with background worker, cron, and PostgreSQL roles

With just 2 servers, we can replicate the production environment while keeping costs lower.

The staging cluster is also fully independent from the production cluster so any testing you do won't affect the production environment's resources.

Example Side Projects Cluster

Let's say you have multiple side projects that don't get a lot of traffic. You'd like to save money by running these all on the same server. To do this, we'd create a cluster with a single server in it:

  1. A server with web, background worker, cron, and PostgreSQL roles

This server runs everything, so we'd want to ensure this server is large enough to run multiple applications.

We'd want to choose a server with enough RAM to run all of the applications on it. Let's say we want to run 4 Rails applications that use 1GB of RAM each. We would choose an 8GB RAM server so we have plenty of RAM for the apps, databases, the OS, and plenty of breathing room.

With Hatchbox, we only pay $10/mo for these 4 apps. 🎉

On other hosting platforms, you'd have to pay 4x for the Rails processes, 4x for the Rails background workers, and 4x for the PostgreSQL databases.