Deploy Oxy on AWS
This guide walks you through deploying Oxy on Amazon EC2 instances with direct access. We’ll cover everything from setting up a virtual machine to configuring Oxy with proper data persistence.Prerequisites
Before you begin, make sure you have:- An AWS account
- A domain name (optional, but recommended for production deployments)
- Basic familiarity with Linux command line
Creating an EC2 Instance
Follow these steps to create an EC2 instance in Amazon Web Services:Access AWS Management Console
Navigate to EC2 Dashboard
Launch an Instance
- Name: Choose a name for your instance (e.g.,
oxy-server
) - Application and OS Images:
- Select Ubuntu Server 22.04 LTS (64-bit ARM or x86)
- For best value, choose the ARM-based Amazon Machine Image (AMI)
- Instance type:
- For ARM-based, select
t4g.small
(2 vCPU, 2 GB memory) ort4g.medium
(2 vCPU, 4 GB memory) - For x86-based, select
t3.small
(2 vCPU, 2 GB memory) ort3.medium
(2 vCPU, 4 GB memory)
- For ARM-based, select
- Key pair: Create a new key pair or select an existing one
- If creating a new one, make sure to download and save the private key file
- Network settings:
- Allow SSH traffic from your IP
- Allow HTTP traffic on port 3000 (custom TCP rule: TCP, Port 3000, Source: 0.0.0.0/0)
- Storage:
- Default 8 GB gp3 root volume is sufficient to start
Note Your Public IP
Pointing Your Domain to Your EC2 Instance (Optional)
If you have a domain name and want to use it with your Oxy deployment:Access DNS Settings
Add DNS Records
- A Record:
- Host/Name:
@
or your subdomain (e.g.,oxy
) - Value/Points to: Your EC2 instance’s public IP address
- TTL: 3600 (or as recommended by your registrar)
- Host/Name:
Wait for DNS Propagation
Setting Up the EC2 Instance
Connect to your EC2 instance and prepare it for Oxy deployment:Connect to Your Instance
Update System and Install Essential Packages
Installing Oxy CLI
Let’s install Oxy directly on the EC2 instance:Install Required Dependencies
Install Oxy
Verify the Installation
Setting Up Oxy Workspace
Let’s use the built-inoxy init
command to initialize a new workspace with all the necessary files and configuration:
Create and Navigate to Workspace Directory
Initialize Oxy Project
- Create a
config.yml
file with your database and model configurations - Set up sample project files
- Create necessary directories like
agents
andworkflows
- Database settings (You can start with DuckDB for simplicity)
- Model configuration (e.g., OpenAI with your API key)
Alternative: Set Up Git and Clone Existing Project
oxy init
.Create Data Directory
Configure Environment Variables
.env
file in the workspace directory:OXY_STATE_DIR
, Oxy will use the default location ~/.local/share/oxy/
.
We recommend setting it explicitly for production deployments to make backups and maintenance easier.oxy init
process.Setting Up and Starting Oxy as a Service
Let’s configure Oxy to run automatically on system startup and restart if it fails:Create a Systemd Service File
ubuntu
user which is standard on EC2 Ubuntu instances. If you’re using a different username, adjust accordingly.Save and exit.Enable and Start the Service
Verify the Service
View Logs (if needed)
Test the Connection
Access Your Deployment
Security Group Configuration
To ensure your Oxy deployment is accessible, verify your EC2 instance’s security group allows inbound traffic on port 3000:Access Security Groups
Find Your Instance's Security Group
Add Inbound Rule for Port 3000
- Type: Custom TCP
- Port range: 3000
- Source: 0.0.0.0/0 (for public access) or your specific IP range for restricted access
- Description: Oxy HTTP access
Save Changes
Optional Configuration and Management
Everything up to this point completes the core setup of your Oxy deployment. The following sections cover additional aspects of managing your deployment that you may want to explore as needed.Data Persistence
It’s important to understand how Oxy handles data persistence:- Oxy uses SQLite for its internal database by default
- All data is stored in the directory specified by
OXY_STATE_DIR
environment variable (we set it to ~/oxy-data) - If
OXY_STATE_DIR
is not set, Oxy uses~/.local/share/oxy/
by default - This directory contains database files, semantic information, cached query results, and workflow history
Managing Your Deployment
Stopping the Service
Updating Oxy
Backup Data
Machine Recommendations
Usage Level | ARM-based (Best Value) | x86-based |
---|---|---|
Small (1-3 users) | t4g.small (2 vCPU, 2 GB memory) or t4g.medium (2 vCPU, 4 GB memory) | t3.small (2 vCPU, 2 GB memory) or t3.medium (2 vCPU, 4 GB memory) |
Medium (3-5 users) | t4g.large (2 vCPU, 8 GB memory) | t3.large (2 vCPU, 8 GB memory) |
Large (5-15 users) | t4g.xlarge (4 vCPU, 16 GB memory) | t3.xlarge (4 vCPU, 16 GB memory) |
Scaling on AWS
As your usage grows, you may need to scale your deployment:Vertical Scaling
- Stop your EC2 instance from the AWS Management Console
- Change the instance type to a larger size (e.g., from t4g.small to t4g.medium)
- Start the instance again
- Reconnect and start your Oxy service:
Storage Scaling
If you need more storage for your Oxy data:-
Create a new EBS volume in the AWS Management Console:
- Go to EC2 → Volumes → Create Volume
- Choose a size and volume type (gp3 is recommended for balanced cost/performance)
- Create in the same Availability Zone as your EC2 instance
-
Attach the volume to your EC2 instance:
- Select the volume you created
- Actions → Attach Volume
- Select your instance and choose a device name (e.g., /dev/sdf)
-
Connect to your VM and mount the disk:
-
To make the mount persistent across reboots, add it to fstab:
Troubleshooting
Cannot access Oxy through the domain or public IP
Cannot access Oxy through the domain or public IP
- Check your EC2 instance security group: Ensure it allows inbound traffic on port 3000 from 0.0.0.0/0 (or your specific IP range)
- Verify Oxy is running:
sudo systemctl status oxy
- Test local connection:
curl http://localhost:3000
- For domain issues: Run
dig yourdomain.com
to verify DNS is pointing to your EC2 instance’s public IP - Check if your EC2 instance’s public IP has changed (this can happen after stop/start)
Oxy service won't start
Oxy service won't start
- View detailed logs:
sudo journalctl -u oxy -f
- Verify environment file exists:
cat ~/oxy-workspace/.env
- Check service file:
sudo cat /etc/systemd/system/oxy.service
- Ensure workspace exists:
ls -la ~/oxy-workspace
- Verify Oxy binary is installed:
which oxy
Data not persisting between restarts
Data not persisting between restarts
- Verify data directory exists:
ls -la ~/oxy-data
- Check environment variable is set:
grep OXY_STATE_DIR ~/oxy-workspace/.env
- If you didn’t set
OXY_STATE_DIR
, check the default location:ls -la ~/.local/share/oxy/
- Ensure proper permissions:
sudo chown -R ubuntu:ubuntu ~/oxy-data
Instance stopped responding
Instance stopped responding
- Check if you’ve hit CPU credit limits (t-series instances are burstable)
- Consider upgrading to a larger instance type if consistently hitting limits
- View system metrics in the AWS EC2 console to diagnose resource constraints
- Check available disk space:
df -h
Connection refused or timeout errors
Connection refused or timeout errors
- Verify the EC2 instance is running in the AWS Console
- Check if the security group allows traffic on port 3000
- Ensure Oxy service is running:
sudo systemctl status oxy
- Test if the port is open:
sudo netstat -tlnp | grep :3000
Next Steps
Once your AWS EC2 deployment is running:- Configure agents and workflows in your workspace
- Set up regular backups for your data
- Consider implementing a CI/CD pipeline for deploying configuration updates
- Monitor your EC2 instance’s resource usage and scale as needed