Back to articles
Technology Insight

Scaling Infrastructure Instantly: How to Replicate 100 Identical VPS Nodes in 60 Seconds Using NixOS Flakes

May 30, 2026

The DevOps Conundrum: The Illusion of Replicability

In modern cloud infrastructure, consistency is the ultimate metric of operational success. Yet, enterprise DevOps teams frequently battle configuration drift. A package updated on server 12 behaves differently than on server 84; a subtle environment variable omission causes a staging-to-production mismatch; standard configuration management tools like Ansible or Puppet apply changes sequentially, leading to execution delays and transient errors. When scaling an application horizontally across 100 identical VPS (Virtual Private Server) nodes, traditional imperative approaches fail to meet the speed and reliability demands of high-throughput businesses.

Enter NixOS and its groundbreaking ecosystem feature: NixOS Flakes. By treating your entire operating system configuration as a pure, deterministic function, NixOS allows systems administrators to achieve absolute reproducibility. This comprehensive guide details how to construct a deployment framework capable of provisioning and configuring 100 identical VPS instances simultaneously in less than 60 seconds.

Understanding the Secret Weapon: What are NixOS Flakes?

Standard NixOS relies on channels, which can introduce variance over time based on when a system fetches updates. NixOS Flakes solve this by introducing a flake.lock file, bringing the exact dependency locking mechanism found in modern programming languages (like package-lock.json in Node.js or Cargo.lock in Rust) to the operating system level.

"Flakes allow you to define hermetic, reusable, and composable Nix packages and system configurations. If it builds on your workstation today, it will build exactly the same way on 100 remote servers tomorrow."

The core benefits of adopting Flakes for massive enterprise fleets include:

  • Bit-for-Bit Reproducibility: Every dependency, kernel patch, and configuration file is explicitly pinned.
  • Atomic Rollbacks: If a deployment fails or introduces a regression, servers can revert to the previous working state instantaneously.
  • Parallel Execution: Because configurations are pre-computed as static derivations, remote deployment tools can push configurations to hundreds of target nodes concurrently.

Architecting the 60-Second Deployment Pipeline

To replicate 100 identical VPS nodes in 60 seconds, we avoid sequential SSH loops. Instead, we use a highly parallelized deployment framework combining a base system golden image or localized building, and a concurrent deployment tool such as Colmena or nix-darwin/deploy-rs. The process relies on pre-building the system derivation locally (or via a CI/CD runner) and copying the closure paths over high-speed network backbones directly to the target nodes via SSH.

Step 1: Structuring the Flake Project

To begin, we establish a centralized repository that defines our entire infrastructure fleet. The file structure is designed for modularity and scaling:

/infra-flake
├── flake.nix
├── flake.lock
├── common/
│   └── configuration.nix
└── hosts/
    ├── node001.nix
    ├── node002.nix
    └── ... (or generated dynamically)

Step 2: Defining the flake.nix for Scale

The master flake.nix file defines the source inputs (Nixpkgs repository) and outputs (the explicit server configurations). To efficiently scale to 100 nodes without writing 100 separate files manually, we utilize Nix's functional capabilities to programmatically generate host definitions.

Below is an enterprise-grade abstraction snippet for flake.nix:

{
  description = "Enterprise 100-VPS Production Fleet";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
    colmena.url = "github:zhaofengli/colmena";
  };

  outputs = { self, nixpkgs, colmena, ... }:
    let
      system = "x86_64-linux";
      pkgs = nixpkgs.legacyPackages.${system};
      
      # Helper function to generate 100 identical nodes
      makeNode = id:
        {
          deployment = {
            targetHost = "node${id}.yourdomain.internal";
            targetUser = "root";
            tags = [ "production" "webcluster" ];
          };
          
          imports = [ ./common/configuration.nix ];
        };
        
      # Programmatically generate nodes 001 through 100
      nodeRange = builtins.genList (x: 
        let 
          id = pkgs.lib.fixedWidthString 3 "0" (builtins.toString (x + 1));
        in 
          { name = "node${id}"; value = makeNode id; }
      ) 100;
    in
    {
      colmena = { 
        meta = { 
          nixpkgs = pkgs;
          description = "Production Cluster";
        };
      } // (builtins.listToAttrs nodeRange);
    };
}

Step 3: The Universal Node Template (configuration.nix)

The common/configuration.nix file contains the immutable blueprint for your application stack. Whether it contains a Nginx reverse proxy, a Docker daemon, microservices, or custom security hardening rules, it applies identically to every node in the cluster.

{ pkgs, ... }:
{
  boot.loader.grub.device = "/dev/vda";
  networking.firewall.allowedTCPPorts = [ 80 443 ];
  
  services.nginx = {
    enable = true;
    virtualHosts."app.internal" = {
      root = "/var/www/html";
    };
  };

  users.users.root.openssh.authorizedKeys.keys = [
    "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAI... production-key"
  ];

  system.stateVersion = "23.11";
}

Executing the 60-Second Replicating Flash-Deployment

With our Flake structured, replication is reduced to a single command execution. Because NixOS evaluations generate a static system path derivation, the deployment utility can perform an optimized transfer.

  1. Pre-building the derivation: Run colmena build to compile all server specifications simultaneously on your high-powered build server. This takes care of dependency resolution before touching a single production machine.
  2. Concurrent push: Run the deployment parallelized execution command: colmena apply --parallel 100.

During this window, the deployment utility establishes concurrent SSH connections to all 100 targets. It cross-references the remote system hash with the newly built local hash. If the system binaries are identical, it skips them; if there are deltas, it pushes only the missing binary paths (closures) to the remote systems via Nix SSH-store copy over high-speed networks, then executes an instantaneous switch command to swap the active operating system environment symlinks.

Because the heavy lifting (compilation, configuration layout evaluation) is done entirely on the build server, the remote nodes only need to pull, unpack, and activate the new symlink configuration. The activation phase takes less than 3 seconds per machine, resulting in a total deployment window of under 60 seconds across the entire 100-VPS fleet.

Overcoming Practical Bottlenecks at Scale

While NixOS Flakes provide the mathematical and technical framework for instantaneous cloning, real-world networks introduce challenges. To guarantee the 60-second execution target, implement these optimization protocols:

1. Implement a Local Binary Cache

Avoid having 100 VPS machines request dependencies from the public cache simultaneously. Set up a local binary cache like Harmonia or Attic on your infrastructure network backbone. This enables servers to pull system paths via gigabit local switching speeds.

2. Optimize SSH Multiplexing

Ensure your deployment configuration allows aggressive connection reuse and concurrent file streams. Adjusting your local ~/.ssh/config to allow persistent ControlMaster connections limits the cryptographic handshake overhead when establishing dozens of parallel execution channels.

Conclusion: The Future of Immutable Infrastructure

Replicating 100 VPS instances identically used to require complex snapshot configurations, slow cloud-init provisioning scripts, or heavy orchestration layers that often drifted out of sync. By moving the absolute point of truth to a declarative, lock-file-backed system framework like NixOS Flakes, you transform your infrastructure into a reliable, lightning-fast compiler output.

By investing in a reproducible pipeline, enterprise infrastructure scales horizontally with predictable timelines, zero-drift guarantees, and operational peace of mind.

Scaling Infrastructure Instantly: How to Replicate 100 Identical VPS Nodes in 60 Seconds Using NixOS Flakes | DPTCloud