Back to articles
AI & Cloud

Guide to Deploying Plausible Analytics on a High Availability HA Cluster for Enterprises

A detailed guide to deploying Plausible Analytics on a High Availability (HA) cluster for enterprises, ensuring high stability, recovery, and automation. Covers configuration,...

DPTCloud Engineering4 min read
Guide to Deploying Plausible Analytics on a High Availability HA Cluster for Enterprises

Image credit: cegoh · Pixabay Content License

Introduction to Plausible Analytics and HA Benefits

Plausible Analytics is an open-source, lightweight, secure, and GDPR-compliant web analytics solution that replaces Google Analytics. With a self-hosted model, enterprises can maintain full control over their data, avoid leaks, and reduce costs. However, to ensure high stability and recovery capabilities, deploying Plausible Analytics on a High Availability (HA) cluster is essential for 24/7 operations.

In this guide, we will walk you through deploying Plausible Analytics on an HA cluster with three nodes (three Cloud Servers) using Redis Sentinel to synchronize data and ensure consistency. This guide is ideal for enterprises requiring reliable monitoring of websites, web applications, or APIs.

Requirements and Preparations

Deploying Plausible Analytics on an HA Cluster

We will deploy Plausible Analytics with the following HA architecture:

  • 3 nodes (server 1, server 2, server 3) running Plausible Analytics.
  • Redis Sentinel managing data synchronization and master/slave state.
  • Nginx acting as reverse proxy and load balancer.
  • PostgreSQL (or compatible) deployed on one or more nodes (optional).

1. Install and Configure Redis Sentinel

Redis Sentinel ensures stability by monitoring Redis nodes and automatically promoting a slave to master if needed.

# On each server, install Redis
sudo apt update
sudo apt install redis-server -y

# Create sentinel.conf configuration file
cat << EOF > /etc/redis/sentinel.conf
port 26379
sentinel monitor mymaster 192.168.1.10 6379 2
sentinel down-after-milliseconds mymaster 5000
sentinel failover-timeout mymaster 60000
sentinel parallel-syncs mymaster 1
EOF

# Start Redis Sentinel
sudo systemctl enable redis-server
sudo systemctl start redis-server

2. Configure Plausible Analytics with Redis Sentinel

Use Docker Compose to deploy Plausible Analytics. Configure Redis Sentinel in the docker-compose.yml file:

version: '3.8'

services:
  plausible:
    image: plausibleio/plausible:latest
    container_name: plausible
    ports:
      - "80:80"
    environment:
      - DB_HOST=192.168.1.10
      - DB_PORT=5432
      - DB_USER=plausible
      - DB_PASSWORD=yourpassword
      - DB_NAME=plausible
      - REDIS_URL=redis://192.168.1.10:6379
      - REDIS_SENTINEL_HOSTS=192.168.1.10:26379,192.168.1.11:26379,192.168.1.12:26379
      - REDIS_SENTINEL_MASTER_NAME=mymaster
    volumes:
      - ./data:/var/lib/plausible
    restart: unless-stopped

3. Configure Nginx as Reverse Proxy and Load Balancer

Set up Nginx as a reverse proxy and load balancer across Plausible nodes:

upstream plausible_backend {
    server 192.168.1.10:80;
    server 192.168.1.11:80;
    server 192.168.1.12:80;
}

server {
    listen 80;
    server_name analytics.yourcompany.com;

    location / {
        proxy_pass http://plausible_backend;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

Testing and Maintenance

1. Verify Functionality

Run the following commands to check Redis Sentinel status:

redis-cli -p 26379 sentinel masters
redis-cli -p 26379 sentinel slaves mymaster

Access https://analytics.yourcompany.com to verify Plausible Analytics runs normally across all nodes.

2. Maintenance and Recovery

  • Data backup: Regularly back up the /data directory.
  • Log monitoring: Use journalctl -u plausible to check logs.
  • Master failover: If the Redis master fails, Redis Sentinel automatically promotes a slave to master.

Troubleshooting

  • Access issues: Check DNS, firewall, and Nginx status.
  • Redis synchronization issues: Verify sentinel.conf and network connectivity between nodes.
  • Plausible fails to start: Check Docker logs and environment configuration.

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