---
title: Cluster
description: 'Manage server cluster settings.'
---

import { Callout } from "fumadocs-ui/components/callout";

When you deploy applications in dokploy, all of them run on the same node. If you wish to run an application on a different server, you can use the cluster feature.

The idea of using clusters is to allow each server to host a different application and, using Traefik along with the load balancer, redirect the traffic from the dokploy server to the servers you choose.

<ImageZoom src="/assets/docker-swarm.png" alt="Docker Swarm Diagram" width={1000} height={600} className="rounded-lg"/>

## Server Scaling Methods

There are two primary ways to scale your server:

1. **Vertical Scaling**: This involves adding more resources to the same dokploy server, such as more CPU and RAM.
2. **Horizontal Scaling**: This method involves adding multiple servers.

### Vertical Scaling

We recommend using vertical scaling to increase the processing capacity of your applications since it's faster and requires less additional configuration.

To perform vertical scaling, you need to add more resources to your dokploy server, that is, more CPU and RAM. This is done through your VPS provider.

It's ideal to first check the vertical scaling limit you can handle. If you find it insufficient, you may consider horizontal scaling.

### Horizontal Scaling

Horizontal scaling usually requires more additional configuration and involves adding more servers (VPS).

If you choose the second option, we will proceed to configure the different servers.

## Requirements for Cluster Setup

1. dokploy server running (Manager).
2. Have at least one extra server with the same architecture as the dokploy server.
3. Have a Docker registry.

## Configuring the Docker Registry

To start, we need to configure a Docker registry, as when deploying an application, you need a registry to deploy and download the application image on the other servers.

### External Registry

You can use any external registry of your choice. Here are some popular options:

1. **Docker Hub** - Free tier available, easy to set up
2. **GitHub Container Registry (ghcr.io)** - Free for public repositories
3. **DigitalOcean Container Registry** - Simple setup with good integration
4. **Amazon ECR** - AWS's managed container registry
5. **Google Container Registry** - Google Cloud's managed registry
6. **Azure Container Registry** - Microsoft's managed registry

Make sure to enter the correct credentials and test the connection before adding the registry to your cluster configuration.

Once configured, the Cluster section will be unlocked.

## Understanding Docker Swarm

We suggest you read this information to better understand how Docker Swarm works and its orchestration: [Docker Swarm documentation](https://docs.docker.com/engine/swarm/) and its architecture: [How Swarm mode works](https://docs.docker.com/engine/swarm/how-swarm-mode-works/nodes/).

## Managing Your Cluster

Now you can do two things:

1. Add workers.
2. Add managers.

Managers have two functionalities:

1. Manage the cluster state.
2. Schedule the services.

Workers have a single purpose, which is to run the containers, acting under the rules created or established by the manager.

## Adding Nodes

You can click the 'Add Node' button, which will display the instructions you need to follow to add your servers as nodes and join them to the dokploy manager node.

<ImageZoom src="/assets/add-node.png" alt="Add Node" width={800} height={630} className="rounded-lg"/>

Once you follow the instructions, the workers or managers will appear in the table.

<ImageZoom src="/assets/nodes.png" alt="View Nodes" width={800} height={630} className="rounded-lg"/>

<Callout type="info">
  **Storage Cleanup Note**: Dokploy does not perform automatic cleanup of storage for workers or other associated nodes that are not the Dokploy server. For automatic cleanup, you can add your node as a remote server and configure cleanups, or create a schedule that performs that cleanup. Additionally, you don't need to perform setup when you only add the node as a remote server. For more information, see the [Remote Servers documentation](/docs/core/remote-servers).
</Callout>
