Back to articles
AI & Cloud

Deploy SurrealDB on Cloud VPS: Next-Gen Database Combining Graph, Document, and SQL

Guide to deploying SurrealDB on Cloud VPS with a next-generation database architecture integrating graph, document, and SQL. Includes configuration, optimization, testing, and...

DPTCloud Engineering4 min read
Deploy SurrealDB on Cloud VPS: Next-Gen Database Combining Graph, Document, and SQL

Introduction to SurrealDB and Benefits of Deployment on Cloud VPS

SurrealDB is a next-generation database that integrates three core data models: graph, document, and SQL into a single system. Its modern architecture enables faster application development, greater flexibility, and improved efficiency—especially for complex data systems such as social networks, content management platforms, and AI applications.

Deploying SurrealDB on a Cloud VPS provides high RAM capacity, strong performance, and easy scalability, allowing you to fully leverage SurrealDB’s capabilities without investing in physical infrastructure. This makes it an ideal choice for developers looking to self-host a high-performance database with low cost and high efficiency.

Requirements and Preparation Steps

System Requirements

  • Cloud VPS with at least 2GB RAM and 1 CPU core
  • Operating system: Ubuntu 20.04 or 22.04
  • Docker and Docker Compose installed
  • Stable internet connection

Tool Setup

Ensure the following tools are installed before deployment:

sudo apt update
sudo apt install docker.io docker-compose -y
sudo systemctl enable docker
sudo systemctl start docker

Deploying SurrealDB on Cloud VPS

Docker Compose Configuration

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

version: '3.8'
services:
  surrealdb:
    image: surrealdb/surrealdb:latest
    container_name: surrealdb
    ports:
      - "8000:8000"
      - "8001:8001"
    volumes:
      - ./data:/data
    environment:
      - SURREALDB_AUTH=false
      - SURREALDB_ROOT_USER=root
      - SURREALDB_ROOT_PASS=root
    restart: unless-stopped

Note: In production environments, enable authentication and use strong passwords.

Starting SurrealDB

Run the following command to start the container:

docker-compose up -d

After startup, SurrealDB will run on port 8000 (HTTP) and 8001 (WebSocket).

Testing and Connection Verification

Accessing the Admin Interface

Open a browser and navigate to http://:8000. You will see the SurrealDB Console interface.

Running a Test Query

In the Console interface, run the following command to verify connectivity:

USE NS test;
USE DB test;
CREATE user:admin SET name = 'Admin', role = 'admin';
SELECT * FROM user;

If the query returns results, SurrealDB is functioning correctly.

Performance Optimization and Security

Optimizing Docker Storage Driver

To improve performance, switch to Fuse OverlayFS if using an older kernel:

sudo docker info | grep "Storage Driver"
# If aufs or overlay, switch to fuse-overlayfs
sudo apt install fuse-overlayfs -y
sudo systemctl restart docker

For detailed guidance, see: Optimizing Docker Storage Driver.

Securing SurrealDB

  • Use strong passwords for the root user
  • Set SURREALDB_AUTH=true in the environment
  • Restrict access via firewall to approved IP addresses
  • Enable SSL if required

Integration with Applications

SurrealDB supports multiple programming languages including JavaScript, Python, Go, and Rust. Example with JavaScript:

const Surreal = require('surrealdb');

const db = new Surreal('http://localhost:8000');

async function connect() {
  await db.connect();
  await db.use('test', 'test');
  const result = await db.select('user');
  console.log(result);
}

connect();

Alternative Solutions and Comparison

Compare SurrealDB with existing database systems:

Feature SurrealDB Neo4j MongoDB PostgreSQL
Data Format Graph, Document, SQL Graph Document SQL
Development Time Low Medium Low Medium
Performance High High High Medium

Troubleshooting

  • Cannot connect to port 8000: Check firewall and port forwarding on the VPS.
  • Container fails to start: Check logs with docker logs surrealdb.
  • No data visible: Ensure correct namespace and database are used.

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