Infrastructure & Backend Engineer

Mass Migration Automation: Multi-DNS to HestiaCP

Engineered automated Node.js scripts for massive infrastructure migration, successfully porting 524 domains across servers in under 4 hours via parallel execution.

Year
2024
Stack
Node.jsTypeScriptHestiaCP APICloudflare APINamecheap APISFTP
GitHub ↗

Mass Migration Automation: Porting 524 Domains in Less Than 4 Hours

The Overhead

Migrating hundreds of active domains across different servers is traditionally a massive operational bottleneck. Doing it manually introduces severe human error, unpredictable downtime, and immense overhead. The objective was to build a highly scalable, automated pipeline to handle DNS synchronization across multiple providers, server provisioning, file transfers, and SSL issuance with zero dropped payloads.

The Architecture

To handle the scale and avoid API rate limits or server I/O bottlenecks, I designed a 4-stage pipeline in Node.js utilizing p-limit for controlled concurrency. The system is strictly idempotent—powered by a custom StateManager that tracks the migration lifecycle, ensuring that if a process fails, it resumes exactly where it left off without duplicate executions.

Pipeline Design

The execution is split into 4 discrete, idempotent stages:

StageOperationMax ConcurrencyBottleneck
1DNS Record Sync20API rate limits
2Domain Provisioning10HestiaCP stability
3File Transfer5Server I/O
4SSL Issuance10ACME challenges

The Migration Lifecycle

The execution is heavily optimized for speed while respecting the limits of the target infrastructure. DNS propagation (which has a higher threshold) is run at a concurrency of 20, while file uploads (which are I/O intensive) are strictly capped at 5 concurrent streams to prevent server overload.

Execution Sequence

flowchart LR
    Pipeline["Node.js Pipeline"] --> StateManager["State Manager"]
    StateManager --> Read["Read Pending Tasks"]
    
    Read --> S1["Stage 1: DNS Sync<br>(Max 20)"]
    Read --> S2["Stage 2: Provisioning<br>(Max 10)"]
    Read --> S3["Stage 3: File Transfer<br>(Max 5)"]
    Read --> S4["Stage 4: SSL Issuance<br>(Max 10)"]
    
    S1 --> APIs["Cloudflare / Namecheap / Spaceship"]
    S2 --> Hestia["HestiaCP API"]
    S3 --> SFTP["SFTP Stream"]
    S4 --> ACME["Let's Encrypt ACME"]

Each stage writes its completion to the StateManager before advancing, ensuring the pipeline is resumable at any point.

Key Engineering Decisions

The Impact