Back to articles
AI & Cloud

Guide to Serverless-like Workflow Management with Hatchet on VPS for Enterprises

A detailed guide to deploying Hatchet on a VPS to build a serverless workflow management system, enabling businesses to automate processes at scale with low cost and high scalability.

DPTCloud Engineering4 min read
Guide to Serverless-like Workflow Management with Hatchet on VPS for Enterprises

Image credit: geralt · Pixabay Content License

Introduction to Hatchet and Serverless Workflow Management on VPS

Hatchet is an automation workflow management platform designed to operate like a serverless system, enabling businesses to deploy and manage millions of tasks (workflows) without managing server infrastructure. With automatic scaling and high concurrency, Hatchet is ideal for complex business automation processes such as order processing, notification dispatching, or scheduled reporting.

In this guide, we will deploy Hatchet on a Virtual Private Server (VPS) to build a fully self-hosted serverless workflow management solution. This approach allows businesses to reduce infrastructure costs, improve scalability, and maintain complete control over their automation workflows.

Requirements and Environment Setup

To deploy Hatchet on a VPS, you need a server with high RAM capacity (at least 8GB, preferably 16GB) to ensure performance when handling millions of workflows. This VPS can be provided by providers such as High-RAM Cloud VPS for Self-Hosted LLMs & API Gateways or Dedicated Compute Servers for AI & Inference Workloads.

Technical Requirements

  • OS: Ubuntu 20.04 or 22.04 LTS
  • RAM: 8GB or more
  • Storage: 50GB SSD or more
  • Stable Internet connection
  • SSH access with root privileges

Deploying Hatchet on VPS

We will use Docker to deploy Hatchet, simplifying installation and dependency management.

1. Install Docker and Docker Compose

Run the following commands on your VPS:

sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io
sudo systemctl enable docker
sudo systemctl start docker
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

2. Create docker-compose.yml File

Create a docker-compose.yml file with the following content:

version: '3.8'
services:
  hatchet:
    image: hatchethq/hatchet:latest
    ports:
      - "3000:3000"
    environment:
      - HATCHET_DATABASE_URL=postgresql://hatchet:hatchet@db:5432/hatchet
      - HATCHET_REDIS_URL=redis://redis:6379
    depends_on:
      - db
      - redis
  db:
    image: postgres:14
    environment:
      - POSTGRES_DB=hatchet
      - POSTGRES_USER=hatchet
      - POSTGRES_PASSWORD=hatchet
    volumes:
      - db_data:/var/lib/postgresql/data
  redis:
    image: redis:6
    ports:
      - "6379:6379"
volumes:
  db_data:

3. Start the Services

Run the following command:

docker-compose up -d

Managing and Monitoring Workflows

Once Hatchet is running, you can access the management interface at http://:3000. From here, you can create, run, and monitor automation workflows.

Running a Simple Workflow

We will create a simple workflow to send an email notification:

curl -X POST http://:3000/workflows \
  -H "Content-Type: application/json" \
  -d '{
    "name": "SendEmailNotification",
    "steps": [
      {
        "name": "SendEmail",
        "type": "http",
        "url": "https://api.sendgrid.com/v3/mail/send",
        "method": "POST",
        "headers": {
          "Authorization": "Bearer YOUR_SENDGRID_API_KEY"
        },
        "body": {
          "personalizations": [{"to": [{"email": "[email protected]"}]}],
          "from": {"email": "[email protected]"},
          "subject": "Workflow completed",
          "content": [{"type": "text/plain", "value": "Your workflow has finished."}]
        }
      }
    ]
  }'

Scaling and Optimization Solutions

To handle millions of workflows, consider the following solutions:

  • Database Optimization: Use PostgreSQL with appropriate indexes and data partitioning.
  • Redis Enhancement: Configure Redis cluster for high-load handling.
  • Cloud Object Storage Integration: Store large data such as logs or processing results into JuiceFS and Cloud Object Storage.
  • Network Optimization: Use Sing Box to optimize international network connections.

Verification and Testing

To verify Hatchet is working correctly, you can:

  • Access http://:3000 and check the service status.
  • Run a test workflow and monitor its status in the interface.
  • Check logs using the command: docker-compose logs hatchet.

Troubleshooting

  • Cannot access the website: Check if port 3000 is open on the VPS firewall. Use the command: sudo ufw allow 3000.
  • Database fails to start: Verify that the docker-compose.yml file has the correct PostgreSQL configuration.
  • Redis cannot connect: Ensure Redis is running and port 6379 is not blocked.

References

DPTCloud Tier III Infrastructure

High-RAM Cloud VPS Plans Optimized for AI, Databases & Cache

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02Recommended

VPS-4E

297.000 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe
ECO · vn-02

VPS-5E

614.900 ₫ / mo

10% VAT included

  • CPU: 8 vCPU
  • RAM: 16 GB
  • SSD: 100 GB NVMe
ADVANCED · vn-03Recommended

VPS-4T

548.900 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478