Skip to content

Managed Instance

Moritz edited this page Nov 7, 2025 · 4 revisions

Galactic Logo

Getting Started: Managed Instance

A Managed Instance lets you run galactic clusters on separate machines or containers, all coordinated centrally by a galactic Bridge. This setup is ideal for scaling your Discord bot horizontally across multiple servers, VPS, or cloud environments.

Unlike a standalone instance, the managed instance does not launch clusters directly. Instead, it connects to a galactic Bridge server, which centrally manages the assignment of shards and clusters. Each managed instance acts as a "worker", following the Bridge's instructions for what shards and clusters to run.

When multiple managed instances connect to the same Bridge, the Bridge automatically balances the workload—running your bot in a distributed and resilient way.



2. Connect a Managed Instance

Use the ManagedInstance class to connect a machine to your Bridge. This process can be repeated on any number of hosts.

import {ManagedInstance} from "galactic.ts";

// Connects this instance to the bridge on localhost:3000
const machine = new ManagedInstance(
    `${__dirname}/bot.js`, // Paths to your bot entry script
    'localhost', // Bridge host
    3000, // Bridge port
    1, // Identifier for this instance
    { key: "value" }, // Optional metadata for this instance, that the bridge can use
    [], // Additional arguments to pass to the bot script
    false // Dev-Mode
);

machine.start(); // Start the managed instance
  • The instance contacts the bridge, receives cluster assignments, and launches clusters based on the bridge's instructions.

3. Implement Your Bot Logic

The bot logic is the same as for the standalone setup. Integrate Cluster into your extended Discord.js client as demonstrated below.

Create bot.ts


Summary

  • The Bridge centrally manages all sharding and clustering decisions.
  • Each managed instance listens for assignments and can run on different hosts, VMs, or containers.
  • With multiple managed instances, galactic automatically distributes your bot’s workload—maximizing scalability and resilience.

Clone this wiki locally