Production ARM VM Deployment & Operations Guide

Code Version: 0.8.0 | Wiki Version: 0.8.0

1. Target Architecture & Hardware Envelope

The drt-multi-venue production trading engine is engineered specifically for deployment on an Oracle Cloud Infrastructure (OCI) Ampere® Altra® Compute Instance running Ubuntu 26.04.1 LTS / 24.04 LTS (ARM64 / aarch64).

Hardware Parameter Specification Operational Role & Capacity Plan
Processor Architecture Ampere® Altra® aarch64 (ARM64) High-efficiency concurrent async I/O and low-power streaming
Compute Allocation 2 OCPU (2 Physical Cores / 2 Threads) Up to 2.3 OCPU aggregated container quota, OS headroom reserved
Physical Memory 12 GB RAM (DDR4-3200 ECC) Max 3.4 GB container budget, >8.6 GB host reserve for DuckDB & ML
Storage Subsystem 50 GB NVMe Boot Volume High-IOPS local storage for Parquet archives, DuckDB WAL, and Redis AOF
Host Operating System Ubuntu 26.04.1 LTS / 24.04 LTS Standard production Linux kernel with QEMU multiarch binary support

Formal Memory Allocation Constraint

To prevent Out-Of-Memory (OOM) kernel panics and reserve ample headroom for future high-frequency inference models and local DuckDB query caches, container resource limits are strictly constrained:

$$\sum_{i \in \text{Services}} M_i^{\text{limit}} = M_{\text{redis}} + M_{\text{fxcm-gw}} + M_{\text{venue-fxcm}} + M_{\text{ib-gw}} + M_{\text{venue-ibkr}} = 600\text{ MB} + 1024\text{ MB} + 500\text{ MB} + 800\text{ MB} + 500\text{ MB} = 3,424\text{ MB} \approx 3.4\text{ GB}$$ $$M_{\text{reserve}} = M_{\text{total}} - \sum M_i^{\text{limit}} = 12.0\text{ GB} - 3.4\text{ GB} = 8.6\text{ GB} \quad (> 70\% \text{ safety buffer})$$

2. Production Container Orchestration Topology

Each subsystem runs in an isolated Docker container constrained by CPU quotas and memory ceilings defined in docker-compose.yml:

Service Name Container Image / Platform Memory Limit CPU Quota Persistence & Ports
redis redis:7-alpine (ARM64 native) 600m 0.3 AOF (--appendonly yes), Port 127.0.0.1:6379, Named volume redis-data
fxcm-gateway python:3.7-slim (linux/amd64 via QEMU) 1024m 1.0 Port 5001, ForexConnect C++ SDK REST API
venue-fxcm Custom Dockerfile (python:3.11-slim ARM64) 500m 0.3 Mounts ./data, ./cache, ./common
ib-gateway gnzsnz/ib-gateway:latest (Multiarch) 800m 0.4 Port 127.0.0.1:4002:4004, JAVA_HEAP_SIZE: 512m
venue-ibkr Custom Dockerfile (python:3.11-slim ARM64) 500m 0.3 Mounts ./data, ./cache, ./common
Multiarch Emulation Notice: The FXCM ForexConnect C++ libraries are compiled exclusively for x86_64 (linux/amd64). On ARM64 Ampere A1 hosts, transparent user-space emulation is achieved via qemu-user-static and Linux binfmt-support, allowing the FXCM gateway container to run with native stability alongside ARM64 native workers.

3. Fast-Track: Turnkey 1-Command Deployment on Fresh VM

⚡ 1-Command Automated Turnkey Installation:

On any freshly commissioned Ubuntu 24.04 / 26.04 LTS instance (ARM64 Ampere A1 or x86_64) with no software pre-installed, you can deploy the complete stack with a single turnkey command:

# Option A: Clone via SSH (Recommended for GitHub SSH Keys) & Bootstrap
git clone git@github.com:stdevconsulting/drt-multi-venue.git ~/drt-multi-venue && cd ~/drt-multi-venue && ./scripts/setup_new_vm.sh

# Option B: Clone via HTTPS & Bootstrap
git clone https://github.com/stdevconsulting/drt-multi-venue.git ~/drt-multi-venue && cd ~/drt-multi-venue && ./scripts/setup_new_vm.sh

Note: Because stdevconsulting/drt-multi-venue is a private repository, direct anonymous curl to raw.githubusercontent.com returns HTTP 404. Cloning via SSH (or HTTPS with credentials) securely authorizes access.

What this script automates with zero manual intervention:

  • Installs all system packages (curl, git, ufw, iptables-persistent, netfilter-persistent, python3-venv, build-essential, jq)
  • Installs official Docker Engine and Docker Compose v2 plugin
  • Registers multiarch QEMU binary emulation (tonistiigi/binfmt) for transparent x86_64 FXCM execution on ARM64
  • Initializes persistent storage directories (./data, ./cache, ./logs) with open write permissions
  • Creates Python .venv and installs FastAPI, Uvicorn, WebSockets, DuckDB, pytz, and psutil
  • Generates production environment files (.env.production & .env)
  • Configures host firewall: UFW and Oracle Cloud iptables accept rules for Ports 22, 8050, 80, 443, 5001 and saves persistently
  • Enables and starts systemd boot services (drt-multi-venue.service and drt-dashboard.service)
  • Schedules the 1-minute system watchdog monitoring cron job
  • Builds and starts all Docker containers (docker compose up -d --build)
  • Runs live smoke tests (Redis event bus, Web Dashboard API) and outputs your public dashboard URL!

4. Complete Technical Reference & Manual Step-by-Step Breakdown

For operations teams seeking deep inspection of each individual layer, the detailed manual procedure is documented below:

Step 0: Oracle Cloud Infrastructure (OCI) VM Provisioning & VCN Ingress Rules

Before connecting to the instance via SSH, provision the Ampere ARM VM and configure network ingress rules in the Oracle Cloud Console:

0.1 Provisioning Specifications (OCI Console)

0.2 OCI VCN Security List Ingress Rules (CRITICAL)

By default, Oracle Cloud hypervisors silently drop all inbound traffic except port 22. You MUST add ingress rules to your VCN's Security List:

  1. Navigate to: Networking → Virtual Cloud Networks → [Your VCN]
  2. Click Security Lists on the left menu, then select Default Security List for [Your VCN]
  3. Click Add Ingress Rules and create the following entries:
Stateless Source CIDR Protocol Source Port Destination Port Purpose
No 0.0.0.0/0 (or your IP) TCP All 22 SSH Administrative Access
No 0.0.0.0/0 (or your IP) TCP All 8050 DRT Web Dashboard & Control Center
No 0.0.0.0/0 TCP All 80, 443 HTTP / HTTPS (Nginx / SSL / Cloudflare)
No 10.0.0.0/16 (or admin IP) TCP All 5001 FXCM Gateway Direct Health / Diagnostics

Step 1: Initial SSH Connection & Hardware Verification

Connect to the newly commissioned VM from your local workstation:

# 1. Connect via SSH to the Ampere VM
ssh -i ~/.ssh/id_rsa ubuntu@<YOUR_ARM_VM_IP>

# 2. Verify ARM64 architecture (MUST return 'aarch64')
uname -m

# 3. Check physical memory (should report ~11-12 GB)
free -h

# 4. Check disk storage on root NVMe volume
df -h /

# 5. Set system timezone to UTC for exact financial market alignment
sudo timedatectl set-timezone UTC

Step 2: System Package Update & Essential Tooling Installation

Enable Ubuntu's universe repository (required for multiarch and compilation packages), bring the base operating system up to date, and install critical system packages:

# 1. Ensure software-properties-common is installed and enable the universe repository
sudo apt update
sudo apt install -y software-properties-common
sudo add-apt-repository -y universe
sudo apt update && sudo apt upgrade -y

# 2. Install essential system utilities and development tools
sudo apt install -y \
  ca-certificates \
  curl \
  gnupg \
  lsb-release \
  git \
  htop \
  tmux \
  ufw \
  rsync \
  build-essential \
  python3-venv \
  python3-pip \
  python3-dev \
  jq

Step 3: Multiarch QEMU Emulation Setup (ARM64 → x86_64)

Enable transparent AMD64 emulation for the FXCM ForexConnect gateway binary. On Ubuntu 24.04/26.04, binfmt-support.service has been superseded by systemd's built-in systemd-binfmt.service, and the binary format package is qemu-user-binfmt:

Method A (Recommended via Docker binfmt container - zero host dependencies):

Once Docker is installed (Step 4), simply execute:

docker run --privileged --rm tonistiigi/binfmt --install all

Method B (Via host APT packages):

# 1. Install QEMU user binfmt package (on Ubuntu 26.04)
sudo apt install -y qemu-user-binfmt

# 2. Restart systemd-binfmt service
sudo systemctl restart systemd-binfmt.service

# 3. Verify kernel binfmt registration for x86_64 emulation
ls -la /proc/sys/fs/binfmt_misc/
# Look for 'qemu-x86_64' in the output

Step 4: Official Docker Engine & Docker Compose Plugin Installation

Install the upstream Docker Engine and Compose v2 plugin following official Docker repository guidelines:

# 1. Prepare Docker APT keyring directory
sudo install -m 0755 -d /etc/apt/keyrings

# 2. Import Docker's official GPG signing key
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# 3. Add the Docker official APT repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# 4. Update repository index and install Docker Engine & Compose
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

# 5. Enable and start Docker systemd service
sudo systemctl enable --now docker

# 6. Add the 'ubuntu' user to the docker group for non-root execution
sudo usermod -aG docker $USER

# 7. Apply the new group membership to the current shell session
newgrp docker

# 8. Test Docker native execution and x86_64 multiarch emulation
docker run --rm hello-world
docker run --rm --platform linux/amd64 alpine uname -m
# The second test MUST output: x86_64

Step 5: Codebase Deployment & Directory Initialization

Clone the project repository to /home/ubuntu/drt-multi-venue and initialize runtime data directories:

# 1. Clone the repository
git clone <YOUR_GIT_REPO_URL> /home/ubuntu/drt-multi-venue
cd /home/ubuntu/drt-multi-venue

# 2. Create persistent storage directories
mkdir -p data cache logs

# 3. Set open permissions for container non-root users (UID 1000)
chmod 777 data cache logs

Step 6: Host Python Virtual Environment & Dependencies

Initialize a dedicated Python virtual environment for host-level tools, CLI scripts, test runners, and the web dashboard service:

# 1. Create Python virtual environment in .venv
python3 -m venv .venv

# 2. Activate virtual environment
source .venv/bin/activate

# 3. Upgrade pip and install package with trading and dev dependencies
pip install --upgrade pip
pip install -e ".[trading,dev]"

Step 7: Production Environment Configuration (.env.production)

Configure host-isolated credentials and broker connectivity parameters:

# 1. Create production environment file from template
cp .env.example .env.production
ln -sf .env.production .env

# 2. Lock down permissions strictly to owner (zero-leak guarantee)
chmod 600 .env.production .env

# 3. Edit .env.production with your production/demo credentials
nano .env.production

Key environment parameters to verify in .env.production:

Setting Recommended Value Description
ENVIRONMENT production Runtime environment flag
TRADING_ENV DEMO (or LIVE) Active trading mode switch
REDIS_URL redis://127.0.0.1:6379 Redis Streams bus connection
FXCM_USERNAME your_fxcm_user FXCM Demo or Production login username
FXCM_PASSWORD your_fxcm_pass FXCM Demo or Production login password
FXCM_ENV Demo (or Real) FXCM ForexConnect environment target
IBKR_PAPER_TWS_USERID your_ibkr_user Interactive Brokers TWS paper username
IBKR_PAPER_TWS_PASSWORD your_ibkr_pass Interactive Brokers TWS paper password
MAX_AUTH_RETRIES 2 Zero-Account-Block anti-lockout circuit breaker cutoff

Step 8: Launch Production Container Stack

Build and launch the Docker Compose production stack:

# Option A: Run automated deploy script
./scripts/deploy_production_arm.sh

# Option B: Launch manually with Docker Compose
docker compose up -d --build

# Inspect running container status
docker compose ps

# Verify real-time memory and CPU resource consumption
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.CPUPerc}}\t{{.MemPerc}}"

Step 9: Systemd Boot Auto-Start Registration

Install and enable systemd service unit files to ensure the entire trading stack and dashboard automatically start on host system boot:

# 1. Run the systemd setup script with sudo
sudo ./scripts/setup_systemd.sh

# 2. Verify drt-multi-venue container stack service status
sudo systemctl status drt-multi-venue.service

# 3. Verify drt-dashboard web control center service status
sudo systemctl status drt-dashboard.service

Step 10: Automated Host Watchdog Monitoring Cron

Configure the vitality watchdog script to run every minute via host crontab:

# 1. Ensure script is executable
chmod +x scripts/watchdog.sh

# 2. Register crontab entry for 1-minute vitality checks
(crontab -l 2>/dev/null; echo "* * * * * /home/ubuntu/drt-multi-venue/scripts/watchdog.sh >> /var/log/drt-watchdog.log 2>&1") | crontab -

# 3. Verify active crontab configuration
crontab -l

Step 11: Host Firewall (UFW & OCI iptables) Hardening

Configure Ubuntu's firewall to allow SSH and Web Dashboard access while blocking unauthorized ports. Note: Oracle Cloud Ubuntu images include default iptables reject rules that must also be configured to allow dashboard traffic:

# --- Part A: Oracle Cloud Host iptables (Required for Port 8050) ---
# Oracle Cloud Ubuntu images drop incoming traffic by default in iptables before UFW.
# Insert ACCEPT rules for Port 22 and Port 8050:
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 22 -j ACCEPT
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport 8050 -j ACCEPT

# Save iptables rules to persist across reboots:
sudo netfilter-persistent save 2>/dev/null || sudo iptables-save | sudo tee /etc/iptables/rules.v4 > /dev/null

# --- Part B: UFW Firewall Hardening ---
# 1. Default deny all incoming traffic, allow all outgoing traffic
sudo ufw default deny incoming
sudo ufw default allow outgoing

# 2. Allow SSH access
sudo ufw allow 22/tcp
sudo ufw allow OpenSSH

# 3. Allow Web Dashboard direct port (Port 8050)
sudo ufw allow 8050/tcp

# 4. (Optional) Allow HTTP/HTTPS if running Nginx reverse proxy
# sudo ufw allow 80/tcp
# sudo ufw allow 443/tcp

# 5. Enable UFW firewall
sudo ufw enable

# 6. Confirm firewall status
sudo ufw status verbose

Step 12: Seamless Stack Updates & Rebuilding from GitHub

When new updates or bug fixes are pushed to GitHub main, pull and redeploy the system without data loss:

# 1. Navigate to project root and pull latest changes
cd /home/ubuntu/drt-multi-venue
git pull origin main

# 2. Re-run production deployment script (handles container rebuilds & service reload)
./scripts/deploy_production_arm.sh

# 3. If dashboard was modified, restart the systemd dashboard unit:
sudo systemctl restart drt-dashboard.service

# 4. Confirm dashboard and containers are healthy:
sudo systemctl status drt-dashboard.service --no-pager
docker compose ps

5. Post-Deployment Verification & Smoke Tests

Execute the following diagnostic tests to verify end-to-end functionality across all layers:

4.1 Redis Bus & Heartbeat Liveness

# 1. Verify Redis server responsiveness
docker exec -it drt-redis redis-cli ping
# Expected output: PONG

# 2. Inspect active venue worker heartbeats
docker exec -it drt-redis redis-cli keys "heartbeat:*"

# 3. Query specific venue worker heartbeat value
docker exec -it drt-redis redis-cli get "heartbeat:fxcm"
docker exec -it drt-redis redis-cli get "heartbeat:ibkr"

4.2 Broker Gateway & Venue Worker Logs

# Follow live logs for FXCM and IBKR venue workers
docker compose logs -f --tail 50 venue-fxcm venue-ibkr

# Inspect FXCM gateway communication
docker compose logs -f --tail 50 fxcm-gateway

# Inspect IB Gateway connection status
docker compose logs -f --tail 50 ib-gateway

4.3 Host & Container Resource Telemetry

# 1. Container memory and CPU utilization
docker stats --no-stream --format "table {{.Name}}\t{{.MemUsage}}\t{{.CPUPerc}}\t{{.MemPerc}}"

# 2. Host available RAM verification (>8.0 GB free)
free -m

# 3. Disk space utilization in data/ and cache/
du -sh /home/ubuntu/drt-multi-venue/data /home/ubuntu/drt-multi-venue/cache

4.4 Circuit Breaker Liveness & Emergency Controls

# 1. Check circuit breaker status across all venues
source .venv/bin/activate
python3 scripts/reset_circuit_breaker.py --status

# 2. Test manual administrative reset broadcast (if tripped)
python3 scripts/reset_circuit_breaker.py --venue ALL

4.5 Test Order Submission

# Submit a small test order via CLI order management utility
python3 scripts/submit_test_order.py --venue FXCM --symbol EURUSD --side BUY --size 1000 --type MARKET

5. Operations & Maintenance Runbook

Routine Code Updates & Container Redeployment

When new code is pushed to version control, update and restart containers gracefully without data loss:

cd /home/ubuntu/drt-multi-venue

# 1. Pull latest code from repository
git pull origin main

# 2. Update host Python dependencies if pyproject.toml changed
source .venv/bin/activate && pip install -e ".[trading,dev]"

# 3. Rebuild and restart container stack
docker compose up -d --build

# 4. Restart host dashboard service if applicable
sudo systemctl restart drt-dashboard.service

Service Lifecycle Management Commands

Operation Command Description
Start All Services docker compose up -d Launches all containerized services in background
Stop All Services docker compose down Stops and removes containers (preserves volumes)
Restart Single Worker docker compose restart venue-fxcm Performs graceful restart of FXCM venue worker
Systemd Full Stack Restart sudo systemctl restart drt-multi-venue.service Restarts Docker Compose stack via systemd
Systemd Dashboard Restart sudo systemctl restart drt-dashboard.service Restarts Web Dashboard daemon
Run Manual Watchdog ./scripts/watchdog.sh Executes heartbeat and latency SLA inspection

Common Troubleshooting Scenarios

6. Weekly Scheduled Reboot & Clean Boot Guarantees

To clear long-lived QEMU/JVM/ForexConnect memory fragmentation and apply unattended kernel security updates safely without disrupting either equities/CFDs or weekend crypto bots, production hosts perform a coordinated weekly reboot every Saturday at 06:02:00 UTC via drt-weekly-reboot.timer.

Why Saturday 06:02 UTC?

Graceful Shutdown & Deterministic Boot Sequence

Operations & Dry-Run Commands

# Verify timer schedule on the production VM
systemctl list-timers drt-weekly-reboot.timer --no-pager

# Test shutdown sequence safely without rebooting
./scripts/weekly_reboot.sh --dry-run

# Temporarily pause / re-enable the weekly reboot timer
sudo systemctl disable --now drt-weekly-reboot.timer
sudo systemctl enable --now drt-weekly-reboot.timer