Running a Super Lightweight Distributed rqlite Database Cluster on 3 VPS with 1 vCPU for High Availability
This guide details deploying a lightweight distributed rqlite database cluster across three 1 vCPU VPS servers to achieve high availability for time-sensitive applications. rqlite,...
Image credit: WebTechExperts · Pixabay Content License
This guide details deploying a lightweight distributed rqlite database cluster across three 1 vCPU VPS servers to achieve high availability for time-sensitive applications. rqlite, a SQL database based on SQLite with integrated Raft consensus, ensures data synchronization and automatic failover. The guide covers initial setup, network configuration, activity testing, and common troubleshooting steps.
Introduction to rqlite and Benefits of a 3-VPS Configuration
rqlite is a distributed database system that uses the Raft consensus protocol to synchronize data across nodes, ensuring data integrity and high availability. Each node in the rqlite cluster operates as a SQLite server with an HTTP interface, allowing access via REST APIs. Deploying on three VPS servers with 1 vCPU is optimal for small systems, as it provides sufficient processing power to handle simple SQL queries and data synchronization without requiring large resources. With three nodes, the system can continue operating if one node fails, since Raft requires a majority to confirm transactions. This setup achieves high availability without the complexity of traditional distributed databases or Kubernetes.
Prerequisites and Initial Setup
To begin, you need three Linux-based VPS servers (Ubuntu 20.04 or 22.04 is recommended). Each VPS should have at least 1 vCPU, 1GB RAM, and 10GB of storage. The VPS instances must be able to communicate over the network, either internally or publicly. First, update the system and install essential tools:
sudo apt update && sudo apt upgrade -y\nsudo apt install -y curl wgetNext, download and install rqlite using the official installation script:
curl -s https://rqlite.io/install.sh | bashRun this command on each VPS. After installation, start the rqlite service:
sudo systemctl start rqlite\nsudo systemctl enable rqliteDistributed Cluster Configuration
To form a cluster, each node must know the addresses of the other two nodes. On each VPS, edit the rqlite configuration file (typically located at /etc/rqlite/rqlite.conf) and set the following parameters:
http_addr = \"0.0.0.0:4001\"\nraft_addr = \"0.0.0.0:4002\"\njoin = [\"http://VPS1_IP:4001\", \"http://VPS2_IP:4001\", \"http://VPS3_IP:4001\"]Replace VPS1_IP, VPS2_IP, and VPS3_IP with the actual IP addresses of each server. After configuring, restart the service:
sudo systemctl restart rqliteTo verify the cluster status, use the following command:
curl http://localhost:4001/raft/leaderIf the response returns the IP address of a node, the cluster is active. You can access the database via the HTTP API. For example, to create a table:
curl -X POST -H \"Content-Type: application/json\" -d '{\"sql\": \"CREATE TABLE test (id INTEGER PRIMARY KEY, name TEXT)\"}' http://localhost:4001/db/queryVerification and Troubleshooting
To verify high availability, test the cluster by stopping the service on one VPS:
sudo systemctl stop rqliteThen, check if the remaining nodes can still process queries. If they can, the cluster is operating correctly. If not, review the rqlite logs:
sudo journalctl -u rqlite -n 50If nodes cannot connect, ensure that ports 4001 (HTTP) and 4002 (Raft) are open in the firewall. On Ubuntu, use UFW:
sudo ufw allow 4001/tcp\nsudo ufw allow 4002/tcpSystem Requirements and Checks
Below is a checklist to ensure the system runs reliably:
- Restart each VPS after installation.
- Run
curl http://localhost:4001/raft/leaderon each node to confirm the leader. - Perform simple SQL queries to verify read/write functionality.
- Test failover by shutting down one node and verifying cluster operation.
- Ensure logs show no connection or synchronization errors.
References and Notes
For more information on rqlite, refer to the official documentation at https://rqlite.io/docs/. This guide is based on rqlite’s core principles and cluster configuration. Larger systems may require additional features such as load balancing, regular backups, and monitoring. With a 1 vCPU configuration, rqlite is suitable for small applications but not for high-load or large-scale data scenarios. Alternatives like etcd or Consul may be better suited for larger deployments.
Related infrastructure & engineering guides: NVMe Cloud VPS for Docker, Nginx & Databases · Turn an iPad or Chromebook into a High-Performance Programming Machine Using Coder
Recommended NVMe Cloud VPS Plans to Deploy This Setup
Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.
VPS-3E
10% VAT included
- CPU: 2 vCPU
- RAM: 4 GB
- SSD: 50 GB NVMe
