Overview
When deploying Masumi Node and your agents to production, it’s crucial to understand the recommended hosting architecture. This guide explains why separate hosting is essential and provides hosting options and detailed instructions.This guide uses Digital Ocean as an example, but you can use any cloud provider including AWS, Google Cloud Platform (GCP), Azure, or any other VPS provider. The general principles and setup steps are similar across providers.
Recommended hosting architecture
Why separate hosting?
- Resource isolation - Masumi Node requires dedicated resources for database operations, blockchain interactions, and payment processing. Running agents on the same server can cause resource contention.
- Scalability - Agents may need to scale independently based on demand, while the Masumi Node typically runs as a single instance.
- Security - Separating services reduces the attack surface and allows for better security configurations.
- Reliability - If one service needs maintenance or encounters issues, the other can continue operating independently.
Architecture diagram
Hosting options
Option 1: Railway (easiest for Masumi Node)
Railway provides the easiest way to host your Masumi Node with minimal configuration. Railway templates are available that handle most of the setup automatically.For detailed Railway deployment instructions, see the Installation Guide. Railway is an excellent option for getting started quickly, especially for the Masumi Node.
- One-click deployment via templates
- Automatic database provisioning
- Built-in environment variable management
- Easy scaling and monitoring
- Free trial available
While Railway is great for Masumi Node, you’ll still need to host your agents separately on another platform (Railway, Digital Ocean, AWS, etc.) to maintain proper separation.
Option 2: Docker Compose (recommended for VPS hosting)
Docker Compose is an excellent option for hosting Masumi Node on any VPS provider. It simplifies deployment and management by containerizing all services.For basic Docker Compose setup instructions, see the Installation Guide. The following section covers production deployment on a VPS.
- Easy deployment and updates
- Isolated services with automatic dependency management
- Includes PostgreSQL database automatically
- Simple to backup and restore
- Works on any VPS provider (Digital Ocean, AWS, GCP, etc.)
- VPS instance with Docker and Docker Compose installed
- Minimal plan (2 GB RAM / 1 vCPU) is sufficient
Option 3: Manual setup on cloud providers
For more control and customization, you can manually set up Masumi Node and agents on any cloud provider without Docker. The following sections provide detailed instructions using Digital Ocean as an example, but the same principles apply to:- AWS (EC2 instances)
- Google Cloud Platform (Compute Engine)
- Azure (Virtual Machines)
- Linode, Vultr, Hetzner, or any other VPS provider
Part 1: Hosting Masumi Node with Docker Compose
This section provides step-by-step instructions for deploying Masumi Node using Docker Compose on any VPS provider.Create a VPS instance
Create a VPS instance on your chosen provider (Digital Ocean, AWS, GCP, Azure, etc.):
- Image: Ubuntu 22.04 (LTS) x64
- Plan: 2 GB RAM / 1 vCPU (minimal plan is sufficient)
- Region: Choose closest to your users
Configure environment variables
Copy the example environment file:Edit the Configure the following variables:
.env file:- Generate a secure encryption key:
openssl rand -hex 32 - Get your Blockfrost API key from blockfrost.io
- The ADMIN_KEY must be at least 15 characters long
- For more details on environment variables, see the Environment Variables section
Set up auto-restart (optional)
To ensure services restart automatically on reboot, Docker Compose services are typically configured to restart automatically. Verify this in your
docker-compose.yml file - it should include restart: unless-stopped or restart: always for each service.Set up reverse proxy (optional but recommended)
Install Nginx:Create an Nginx configuration file:Add the following configuration:Enable the site:
For production, consider setting up SSL/TLS with Let’s Encrypt using Certbot for HTTPS.
Useful Docker Compose commands
View logs:Part 2: Manual setup on Digital Ocean
This section walks you through hosting both components on Digital Ocean using separate droplets. These same steps can be adapted for AWS, GCP, Azure, or any other VPS provider.Prerequisites
- Digital Ocean account (or account with your chosen cloud provider)
- Basic knowledge of Linux command line
- SSH access to your local machine
Hosting Masumi Node
Create a droplet
- Log in to your Digital Ocean dashboard
- Click “Create” → “Droplets”
- Configure your droplet:
- Image: Ubuntu 22.04 (LTS) x64
- Plan: 2 GB RAM / 1 vCPU - This minimal plan is sufficient for Masumi Node
- Datacenter region: Choose closest to your users
- Authentication: SSH keys (recommended) or root password
- Hostname:
masumi-node(or your preferred name)
- Click “Create Droplet”
Install PostgreSQL
Install PostgreSQL 15:Start and enable PostgreSQL:Create the database and user:Inside the PostgreSQL prompt:
Clone and configure Masumi Payment Service
Install Git if not already installed:Clone the repository:Check out the latest stable version:Install dependencies:
Configure environment variables
Copy the example environment file:Edit the Configure the following variables:
.env file with your configuration:- Generate a secure encryption key:
openssl rand -hex 32 - Get your Blockfrost API key from blockfrost.io
- The ADMIN_KEY must be at least 15 characters long
Set up process manager (PM2)
Install PM2 to keep the service running:Start the Masumi Node:Save PM2 configuration:Follow the instructions provided by the
pm2 startup command to enable auto-start on reboot.Set up reverse proxy (optional but recommended)
Install Nginx:Create an Nginx configuration file:Add the following configuration:Enable the site:
For production, consider setting up SSL/TLS with Let’s Encrypt using Certbot for HTTPS.
Hosting your agent
Create a separate droplet
- Create a new droplet following the same process as above
- Important: This must be a separate droplet from your Masumi Node
- Recommended specs:
- Minimum: 2 GB RAM / 1 vCPU
- For AI agents: 4 GB RAM / 2 vCPU or higher depending on your agent’s requirements
Install required dependencies
The dependencies depend on your agent’s technology stack. Common examples:For Python-based agents:For Node.js-based agents:For Docker-based agents:
Deploy your agent
Clone your agent repository:Follow your agent’s specific installation instructions. Typically:For Python:For Node.js:
Configure agent environment variables
Create or edit your agent’s Configure the connection to your Masumi Node:
.env file:- Get your
PAYMENT_API_KEYfrom the Masumi Node admin dashboard - Get your
AGENT_IDENTIFIERafter registering your agent on the Masumi Network - The
PAYMENT_SERVICE_URLshould point to your Masumi Node droplet’s IP or domain
Run your agent with PM2
Install PM2:Start your agent (adjust command based on your agent):For Python agents:For Node.js agents:For other setups:Save PM2 configuration:
Verification and testing
Test Masumi Node
- Access admin dashboard:
http://your_masumi_node_ip:3001/admin - Verify health endpoint:
curl http://your_masumi_node_ip:3001/api/v1/health/ - Check PM2 status:
pm2 status
Test your agent
- Verify agent is running:
pm2 status - Test agent health endpoint (if available):
curl http://your_agent_ip:8000/availability - Check agent logs:
pm2 logs my-agent
Test integration
- Register your agent on the Masumi Network through the admin dashboard
- Test a payment flow to ensure connectivity between agent and Masumi Node
Monitoring and maintenance
View logs
Masumi Node:Restart services
Masumi Node:Update services
When updating either service:- Pull latest changes:
git pull - Install/update dependencies
- Rebuild if necessary
- Restart with PM2:
pm2 restart service-name
Security best practices
- Use SSH keys instead of passwords for authentication
- Set up a firewall (UFW) to restrict access
- Keep systems updated:
apt update && apt upgrade -y - Use strong passwords for database and admin access
- Enable SSL/TLS for production deployments
- Regular backups of your database and configuration files
- Monitor logs regularly for suspicious activity
Troubleshooting
Masumi Node won’t start
- Check logs:
pm2 logs masumi-node - Verify database connection:
psql -U masumi_user -d masumi_payment - Check environment variables:
cat .env - Verify port availability:
netstat -tulpn | grep 3001
Agent can’t connect to Masumi Node
- Verify Masumi Node is running:
curl http://masumi_node_ip:3001/api/v1/health/ - Check firewall rules on both instances
- Verify
PAYMENT_SERVICE_URLin agent’s.envfile - Check network connectivity:
ping masumi_node_ip
High resource usage
- Monitor with:
htoporpm2 monit - Consider upgrading instance size
- Check for memory leaks in logs
- Ensure services are running on separate instances
Pricing
Pricing varies significantly by provider, region, and plan specifications. Always check current pricing on your chosen provider’s website. Railway offers free trials and pay-as-you-go pricing. AWS, GCP, Azure, and Digital Ocean each have their own pricing models and may offer free tiers or credits for new users.