Back to articles
Technology Insight

Building a High-Speed, Real-Time Push Notification Service with Gotify on Your Own Cloud VPS

June 2, 2026

Introduction: The Need for Self-Hosted Real-Time Notifications

In today's fast-paced digital ecosystem, real-time communication is no longer a luxury; it is a fundamental business requirement. Whether it is alerting system administrators about server critical failures, notifying traders about market shifts, or sending instant transactional updates to users, milliseconds matter. While third-party push notification services like Firebase Cloud Messaging (FCM), OneSignal, or Pusher are widely adopted, they come with inherent trade-offs: escalating costs at scale, potential latency variations, and, most importantly, the sacrifice of data privacy.

For enterprises and privacy-conscious developers, hosting your own notification infrastructure is the definitive solution. By leveraging Gotify—a self-hosted, open-source notification server designed specifically for sending and receiving messages—and deploying it on a dedicated Cloud VPS (Virtual Private Server), you can establish a private, high-speed, and cost-effective notification pipeline. This guide provides an enterprise-grade architectural blueprint to build, secure, and optimize your own Gotify notification ecosystem.

Why Gotify? The Lightweight Powerhouse

Gotify stands out in the self-hosted landscape due to its minimalist design and exceptional performance metrics. Written in Go, it compiles into a single, highly efficient binary that requires minimal CPU and memory resources, making it an ideal candidate for Cloud VPS environments.

  • True Real-Time Performance: Utilizing persistent WebSockets, Gotify ensures instantaneous message delivery from your backend scripts directly to your client devices without the overhead of continuous HTTP polling.
  • Absolute Data Sovereignty: Because the entire stack resides on your private Cloud VPS, sensitive operational data and user metrics never leave your secure perimeter.
  • Restful API & Simplicity: Gotify provides a clean, well-documented REST API for sending messages, making integration with existing CI/CD pipelines, monitoring tools (like Prometheus or Grafana), and custom applications incredibly straightforward.
  • Multi-Client Support: Gotify features an intuitive web UI, a robust Command Line Interface (CLI), and a native Android application that handles background connections efficiently without draining device battery life.

System Architecture and Prerequisites

Before initiating the deployment, it is vital to outline a secure and resilient architecture. We will not expose the Gotify application directly to the public internet. Instead, we will deploy it behind a Reverse Proxy (such as Nginx or Traefik) which will handle SSL termination and traffic routing. This ensures that all incoming WebSocket and HTTP connections are strictly encrypted via TLS.

Hardware and Software Requirements

To follow this guide, ensure your environment meets these baseline specifications:

  • Cloud VPS: Minimum 1 vCPU, 1 GB RAM, and 20 GB SSD running a modern Linux distribution (Ubuntu 22.04 LTS or Debian 12 recommended).
  • Domain Name: A registered domain or subdomain (e.g., push.yourdomain.com) with A/AAAA records pointed to your VPS public IP address.
  • Docker & Docker Compose: Installed on the host system to containerize the services and simplify lifecycle management.

Step-by-Step Deployment Guide

Step 1: Setting Up the Directory Structure

Log in to your Cloud VPS via SSH and create a dedicated workspace for your Gotify ecosystem. Keeping configuration files organized prevents permission issues and streamlines backups.

mkdir -p ~/gotify/data
cd ~/gotify

Step 2: Configuring Docker Compose

Using Docker Compose allows us to define the Gotify service and its environment variables cleanly. Create a file named docker-compose.yml within your workspace directory:

version: '3.8'

services:
  gotify:
    image: gotify/server:latest
    container_name: gotify_server
    restart: always
    ports:
      - "127.0.0.1:8080:80"
    environment:
      - GOTIFY_DEFAULTUSER_PASS=ChangeThisSecurePassword123!
      - GOTIFY_UPLOADEDIMAGESDIR=data/images
      - GOTIFY_PLUGINSDIR=data/plugins
    volumes:
      - ./data:/app/data
Security Note: Notice that we bind the container port to 127.0.0.1:8080. This restricts direct external access to the port, forcing all external traffic to pass through our secure reverse proxy. Be sure to change the default password before starting the container.

Step 3: Launching the Gotify Container

Execute the following command to download the official image and start the Gotify service in detached mode:

docker-compose up -d

Verify that the container is running optimally by checking its log output: docker-compose logs -f. You should see indications that the database initialization was successful and the server is listening for traffic.

Securing Traffic with Nginx and Let's Encrypt

To handle high-speed WebSocket connections securely, Nginx must be configured properly to upgrade HTTP connections and manage TLS handshakes efficiently.

1. Install Nginx and Certbot

Run the package manager updates and install Nginx along with the Certbot client for automated SSL management:

sudo apt update
sudo apt install nginx certbot python3-certbot-nginx -y

2. Configure the Nginx Virtual Host

Create a new Nginx configuration file for your notification domain:

sudo nano /etc/nginx/sites-available/gotify

Paste the following production-ready configuration block, substituting push.yourdomain.com with your actual domain:

server {
    listen 80;
    server_name push.yourdomain.com;

    location / {
        proxy_pass [http://127.0.0.1:8080](http://127.0.0.1:8080);
        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;

        # Crucial configuration for Gotify WebSockets
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";

        # Performance and timeout optimizations
        proxy_connect_timeout 7d;
        proxy_send_timeout 7d;
        proxy_read_timeout 7d;
    }
}

Enable the site configuration by creating a symbolic link, test the syntax for errors, and reload Nginx:

sudo ln -s /etc/nginx/sites-available/gotify /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

3. Automate SSL Provisioning

Generate a trusted Let's Encrypt SSL certificate by executing Certbot. The tool will automatically modify your Nginx file to enforce HTTPS redirection:

sudo certbot --nginx -d push.yourdomain.com

Integration: Sending Notifications at Scale

Now that your secure, high-speed notification server is active, you can access the dashboard by navigating to your domain via a web browser. Log in with your admin credentials to create your first application token. Gotify separates notification streams by Applications, allowing you to generate distinct API tokens for different microservices or tasks.

Sending Messages via cURL (Bash)

Integrating Gotify into server cronjobs or deployment scripts takes just a single command:

curl -X POST "[https://push.yourdomain.com/message?token=YOUR_APP_TOKEN](https://push.yourdomain.com/message?token=YOUR_APP_TOKEN)" \
     -F "title=Server Alert" \
     -F "message=High CPU utilization detected on Production-Node-01." \
     -F "priority=8"

Advanced Integration via Python

For more sophisticated application backends, integrating Gotify natively into asynchronous code blocks guarantees low latency without blocking application execution threads:

import requests

def send_gotify_notification(token, title, message, priority=5):
    url = f"[https://push.yourdomain.com/message?token=](https://push.yourdomain.com/message?token=){token}"
    payload = {
        "title": title,
        "message": message,
        "priority": priority
    }
    try:
        response = requests.post(url, json=payload, timeout=5)
        return response.status_code == 200
    except requests.exceptions.RequestException as e:
        print(f"Notification failed: {e}")
        return False

# Example usage within an application workflow
send_gotify_notification("Axxxxxxxxxxxxxx", "Database Backup", "Daily backup completed successfully.", priority=2)

Performance Optimization and Hardening

To transform your Gotify deployment into an enterprise-grade infrastructure capable of handling thousands of concurrent push events seamlessly, consider implementing these systems-level optimizations:

  1. Adjust Linux File Descriptors: Because WebSockets maintain persistent, open network connections, the default operating system file limits may be reached quickly under high load. Increase the limits by modifying /etc/security/limits.conf to include * soft nofile 65535 and * hard nofile 65535.
  2. Fine-Tune WebSocket Keep-Alives: The Nginx proxy configurations include a 7d (seven-day) timeout window. This prevents stateful firewalls or routers from dropping idle client connections unexpectedly, ensuring your client applications remain connected without incurring the overhead of frequent reconnect handshakes.
  3. Implement Database Backups: Gotify utilizes an optimized SQLite database engine by default. Ensure your infrastructure lifecycle management includes automated snapshots or daily cron-driven copies of the ~/gotify/data directory to a remote, secure storage location.

Conclusion: Take Back Control of Your Infrastructure

Deploying Gotify on your own Cloud VPS balances simplicity, speed, and privacy. By removing reliance on external vendor APIs, you eliminate third-party runtime dependencies, protect operational metadata, and control costs effectively. With its Go-powered engine and optimized WebSocket backbone, your newly deployed push notification service is fully prepared to deliver real-time data efficiently across all enterprise operations.

Building a High-Speed, Real-Time Push Notification Service with Gotify on Your Own Cloud VPS | DPTCloud