DEV Community

Cover image for A Web Stack on a €5.93 Aéza VPS: From a Clean Server to a Tested Restore
Aeza
Aeza

Posted on

A Web Stack on a €5.93 Aéza VPS: From a Clean Server to a Tested Restore

An Aéza VPS for €5.93 per month gives you 1 vCPU, 2 GB of memory and 30 GB of NVMe. You can get an application running on it in an evening. The hard part is making the service come back on its own after a reboot, keep its data, restore from a backup and tell you honestly where it slows down.

Let's build that kind of web stack on a VPS for a small product catalog: Caddy with HTTPS, a Flask application, PostgreSQL, Redis and Prometheus. Every config and script is included in full, so you can copy them and reproduce the stack yourself. For load testing, we provide a ready-made scenario with pass criteria.

Can you build a production web stack on one inexpensive VPS?

Yes, for a small service with moderate load. A single production VPS can hold an HTTPS proxy, the application, a database, a cache and lightweight monitoring, as long as every component has a memory limit. But one server remains a single point of failure: if it goes down, the whole service goes down with it. So backups and external uptime checks must live on another machine.

What we are building and how we will know it works

The catalog does two things. GET /items/42 returns a product card, and POST /events with an API token records a view event. On first start, PostgreSQL creates 10,000 products and an events table, and Redis caches cards for 60 seconds.

Only SSH and ports 80 and 443 are open to the outside, and Caddy listens on the latter. From there, a request goes to Gunicorn running the application, which talks to PostgreSQL and Redis on the internal Docker network. Prometheus collects metrics from the application and the server, with node_exporter supplying the server side. The Prometheus UI is reachable only from localhost.

A single server is a starter architecture for a service that can afford downtime while it is being restored. It is not enough for strict availability requirements. We will consider the stack ready when it meets five conditions:

  • The site opens over HTTPS, and HTTP requests are redirected.
  • After a reboot, containers come back on their own and the data stays in place.
  • If the database is unavailable, the proxy stops sending requests to the application.
  • A database dump restores onto a clean PostgreSQL, and the restore time is known.
  • Under load, p95 stays below 300 ms and p99 below 800 ms. These thresholds are examples; set your own.

A clean server: SSH, updates and firewall

For this example we use Ubuntu 24.04 LTS on amd64, the hostname catalog-01 and the UTC time zone, so logs from different machines line up:

sudo hostnamectl set-hostname catalog-01
sudo timedatectl set-timezone UTC
sudo apt update && sudo apt full-upgrade -y
Enter fullscreen mode Exit fullscreen mode

Before you disable password login, test key login in a second session and keep the first one open. If the control panel offers a server console, open it in advance: if you make a mistake in the firewall rules, it will be your only way in.

The next step in setting up a website VPS is the firewall. Block all incoming traffic and open only what is needed. If your SSH runs on a different port, replace 22:

sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 443/udp
# Prometheus in a container reads node_exporter on the host
sudo ufw allow from 172.30.0.0/24 to any port 9100 proto tcp
sudo ufw enable
Enter fullscreen mode Exit fullscreen mode

There is a trap here. Ports published by Docker bypass UFW rules, because Docker writes its own iptables chains. That is why PostgreSQL and Redis are not published in compose.yaml at all, and Prometheus is bound to 127.0.0.1. The 172.30.0.0/24 subnet is defined in compose.yaml. If it is already taken on your network, change it in both places.

Install Docker Engine following the official Ubuntu guide on docs.docker.com, and take node_exporter from the distribution repository:

sudo apt install -y prometheus-node-exporter
sudo systemctl enable --now docker
Enter fullscreen mode Exit fullscreen mode

Which ports does a production web stack on one VPS need?

Three ports to the outside are enough: SSH for the admin, 80 for the HTTPS redirect and certificate issuance, and 443 for the site itself, plus 443/UDP if you want HTTP/3. Do not publish the database, Redis, the application or monitoring: the internal Docker network and localhost are all they need.

Caddy and HTTPS

Caddy is convenient because it obtains and renews a Let's Encrypt certificate on its own. If you prefer Nginx on a VPS, the setup is the same, except you will issue the certificate with certbot. Set the domain in the .env file next to compose.yaml and point the A record at the server's IP. Add AAAA only if IPv6 actually works on the server, otherwise domain validation during certificate issuance may fail.

{$DOMAIN} {
    encode zstd gzip
    header {
        Strict-Transport-Security "max-age=31536000"
        X-Content-Type-Options "nosniff"
        Referrer-Policy "strict-origin-when-cross-origin"
        -Server
    }

    # Application metrics are only for Prometheus inside the Docker network
    respond /metrics* 404

    reverse_proxy app:8000 {
        # Active check: two failures in a row take the app out of rotation
        health_uri /readyz
        health_interval 10s
        health_timeout 2s
        health_fails 2
        transport http {
            dial_timeout 2s
            response_header_timeout 5s
        }
    }

    # Request log goes to container output; Caddy redacts Authorization itself
    log
}
Enter fullscreen mode Exit fullscreen mode

Every 10 seconds Caddy requests /readyz. After two failed checks in a row it stops sending traffic to the application, and after the first successful one it brings it back. dial_timeout limits how long it takes to open a connection to the application, and response_header_timeout limits the wait for a response. Five seconds is plenty for short catalog requests; for heavy exports you will need to raise the timeout.

The token will not end up in the log: Caddy records the Authorization header as REDACTED. Docker caps log size at three files of 10 MB per container, as set in compose.yaml. Certificates live in the caddy_data volume and survive container re-creation. After a server reboot, it is handy to check the certificate expiry from another machine:

echo | openssl s_client -connect catalog.example.com:443 \
  -servername catalog.example.com 2>/dev/null | openssl x509 -noout -enddate
Enter fullscreen mode Exit fullscreen mode

The application: container, restarts and secrets

We run the stack with Docker Compose. Image versions are pinned to tags and latest is never used: an upgrade should be a deliberate step on your part, not a side effect of re-creating a container.

name: catalog

x-logging: &logging
  driver: json-file
  options:
    max-size: "10m"
    max-file: "3"

services:
  caddy:
    image: caddy:2.11.7-alpine
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    environment:
      DOMAIN: ${DOMAIN:?set DOMAIN in .env}
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    depends_on: [app]
    logging: *logging

  app:
    build: ./app
    image: catalog-app:1.0.0
    restart: unless-stopped
    environment:
      DB_HOST: db
      DB_NAME: catalog
      DB_USER: catalog_app
      REDIS_URL: redis://redis:6379/0
    secrets: [db_app_password, api_token]
    healthcheck:
      test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"]
      interval: 15s
      timeout: 3s
      retries: 3
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_started
    stop_grace_period: 30s
    mem_limit: 256m
    logging: *logging

  db:
    image: postgres:18.6-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: catalog
      POSTGRES_PASSWORD_FILE: /run/secrets/db_admin_password
    secrets: [db_admin_password, db_app_password]
    command: ["postgres", "-c", "shared_buffers=128MB", "-c", "work_mem=4MB", "-c", "max_connections=30"]
    volumes:
      - pgdata:/var/lib/postgresql
      - ./db/init:/docker-entrypoint-initdb.d:ro
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d catalog"]
      interval: 10s
      timeout: 3s
      retries: 5
    mem_limit: 512m
    logging: *logging

  redis:
    image: redis:8.10.3-alpine
    restart: unless-stopped
    command: ["redis-server", "--maxmemory", "64mb", "--maxmemory-policy", "allkeys-lru", "--save", "", "--appendonly", "no"]
    mem_limit: 128m
    logging: *logging

  prometheus:
    image: prom/prometheus:v3.15.1
    restart: unless-stopped
    command: ["--config.file=/etc/prometheus/prometheus.yml", "--storage.tsdb.retention.time=15d"]
    ports:
      - "127.0.0.1:9090:9090"
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
      - promdata:/prometheus
    extra_hosts:
      - "host.docker.internal:host-gateway"
    mem_limit: 300m
    logging: *logging

networks:
  default:
    ipam:
      config:
        - subnet: 172.30.0.0/24

secrets:
  db_admin_password:
    file: ./secrets/db_admin_password
  db_app_password:
    file: ./secrets/db_app_password
  api_token:
    file: ./secrets/api_token

volumes:
  caddy_data:
  caddy_config:
  pgdata:
  promdata:
Enter fullscreen mode Exit fullscreen mode

Every service has its own memory limit, otherwise the stack can easily outgrow 2 GB. restart: unless-stopped brings a container back after a process crash and after a Docker restart, but leaves alone a container you stopped manually. stop_grace_period gives Gunicorn time to finish the responses in flight.

The application is plain Flask under Gunicorn: one process, four threads and a pool of at most four database connections. The files live in the app directory.

app/Dockerfile:

FROM python:3.14.10-slim
RUN useradd --system --uid 10001 app
WORKDIR /srv
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY app.py .
USER app
EXPOSE 8000
CMD ["gunicorn", "--workers", "1", "--threads", "4", "--graceful-timeout", "20", "--bind", "0.0.0.0:8000", "app:app"]
Enter fullscreen mode Exit fullscreen mode

app/requirements.txt:

flask==3.1.3
gunicorn==26.2.0
psycopg[binary]==3.3.6
psycopg-pool==3.3.3
redis==8.1.0
prometheus-client==0.26.0
Enter fullscreen mode Exit fullscreen mode

app/app.py:

import json
import os
from pathlib import Path

import redis
from flask import Flask, abort, request
from prometheus_client import Histogram, make_wsgi_app
from psycopg_pool import ConnectionPool
from werkzeug.middleware.dispatcher import DispatcherMiddleware


def secret(name):
    return Path("/run/secrets", name).read_text().strip()


pool = ConnectionPool(
    f"host={os.environ['DB_HOST']} dbname={os.environ['DB_NAME']} "
    f"user={os.environ['DB_USER']} password={secret('db_app_password')} connect_timeout=3",
    min_size=1, max_size=4, timeout=5, open=True,
)
cache = redis.Redis.from_url(os.environ["REDIS_URL"], socket_timeout=0.2)
API_TOKEN = secret("api_token")
DB_TIME = Histogram("catalog_db_seconds", "DB work including pool wait", ["op"])

app = Flask(__name__)
app.wsgi_app = DispatcherMiddleware(app.wsgi_app, {"/metrics": make_wsgi_app()})


@app.get("/healthz")
def healthz():
    return {"status": "ok"}


@app.get("/readyz")
def readyz():
    with pool.connection() as conn:
        conn.execute("SELECT 1")
    return {"status": "ready"}


@app.get("/items/<int:item_id>")
def item(item_id):
    key = f"item:{item_id}"
    try:
        cached = cache.get(key)
    except redis.RedisError:
        cached = None
    if cached:
        return app.response_class(cached, mimetype="application/json")
    with DB_TIME.labels("read").time(), pool.connection() as conn:
        row = conn.execute(
            "SELECT id, name, price FROM items WHERE id = %s", (item_id,)
        ).fetchone()
    if row is None:
        abort(404)
    body = json.dumps({"id": row[0], "name": row[1], "price": str(row[2])})
    try:
        cache.setex(key, 60, body)
    except redis.RedisError:
        pass
    return app.response_class(body, mimetype="application/json")


@app.post("/events")
def event():
    if request.headers.get("Authorization") != f"Bearer {API_TOKEN}":
        abort(401)
    item_id = int(request.get_json(force=True)["item_id"])
    with DB_TIME.labels("write").time(), pool.connection() as conn:
        event_id = conn.execute(
            "INSERT INTO events (item_id) VALUES (%s) RETURNING id", (item_id,)
        ).fetchone()[0]
    return {"id": event_id}, 201
Enter fullscreen mode Exit fullscreen mode

The application has two checks. /healthz only confirms that the process responds; Docker uses it to mark the container. /readyz runs SELECT 1 against the database, and Caddy polls it. If PostgreSQL goes down, the proxy takes the application out of rotation, but nobody will restart the live process. Without an orchestrator, the unhealthy status in Docker is just a label and triggers no restart.

Passwords and the token live in the secrets directory, which goes into neither Git nor the image. Compose without Swarm mounts them into /run/secrets as plain unencrypted files and takes permissions from the host. We lock the directory against other users on the server and make the files inside readable, because processes with different UIDs read them inside the containers.

install -d -m 700 secrets
for name in db_admin_password db_app_password api_token; do
  openssl rand -hex 32 > "secrets/$name"
done
chmod 444 secrets/*
echo "DOMAIN=catalog.example.com" > .env
printf 'secrets/\n.env\nbackups/\n' >> .gitignore
Enter fullscreen mode Exit fullscreen mode

Start it up:

docker compose config --quiet
docker compose build
docker compose up -d
docker compose ps
Enter fullscreen mode Exit fullscreen mode

Now the key test for this section is a reboot. Note the number of events, send a couple of requests to /events, reboot the server and compare:

docker compose exec db psql -U postgres -d catalog -tAc "SELECT count(*) FROM events"
sudo reboot
# after logging back in
docker compose ps
curl -fsS https://catalog.example.com/items/42
docker compose exec db psql -U postgres -d catalog -tAc "SELECT count(*) FROM events"
Enter fullscreen mode Exit fullscreen mode

The event count must match what it was before the reboot. Do not use docker compose down -v in this project: the -v flag deletes named volumes, database included.

PostgreSQL and Redis on the same server

PostgreSQL on the VPS stores its data in the pgdata volume. In the official PostgreSQL 18 image, the volume mounts at /var/lib/postgresql, not /var/lib/postgresql/data as before. An old compose file must be fixed after the version upgrade, or the data will not survive container re-creation.

The schema, the application role and the sample products are created by the db/init/01-schema.sh script. The image runs it only on first start with an empty volume, so handle later schema changes with migrations. Remember to make the file executable: chmod +x db/init/01-schema.sh.

#!/bin/sh
set -eu
psql -v ON_ERROR_STOP=1 -U "$POSTGRES_USER" -d "$POSTGRES_DB" \
  -v app_password="$(cat /run/secrets/db_app_password)" <<'SQL'
CREATE ROLE catalog_app LOGIN PASSWORD :'app_password' CONNECTION LIMIT 10;
CREATE TABLE items (
  id integer PRIMARY KEY,
  name text NOT NULL,
  price numeric(10, 2) NOT NULL
);
CREATE TABLE events (
  id bigserial PRIMARY KEY,
  item_id integer NOT NULL REFERENCES items (id),
  created_at timestamptz NOT NULL DEFAULT now()
);
INSERT INTO items
SELECT g, 'Item ' || g, round((random() * 9900 + 100)::numeric, 2)
FROM generate_series(1, 10000) AS g;
GRANT SELECT ON items TO catalog_app;
GRANT SELECT, INSERT ON events TO catalog_app;
GRANT USAGE ON SEQUENCE events_id_seq TO catalog_app;
SQL
Enter fullscreen mode Exit fullscreen mode

The application runs as the catalog_app role, with rights only on its own tables and a limit of 10 connections. SELECT on events is required because of RETURNING id: without it, an INSERT that returns the ID fails.

shared_buffers=128MB and a 512 MB container limit look modest, but for 10,000 products that is more than enough. work_mem is allocated for every sort or hash operation inside a query, so raising it blindly is dangerous: a few heavy queries will eat the container's memory.

Redis works purely as a cache here: 64 MB, allkeys-lru eviction, persistence to disk turned off. Losing the cache is harmless, since the products live in PostgreSQL, and when Redis is unavailable the application goes straight to the database.

All that is left is to confirm that the database and Redis are not visible from outside:

sudo ss -lntp
Enter fullscreen mode Exit fullscreen mode

Among the ports the server listens on you will see 22, 80, 443, 9100 and 127.0.0.1:9090. Ports 5432 and 6379 must not be on the list.

Can the application and PostgreSQL share one VPS?

Yes, as long as they do not get in each other's way. For a small service it is even more convenient: there is no network latency between the application and the database, and fewer machines that can break. Move the database out when it and the application compete for memory, writes slow down responses, or they need to be upgraded and scaled independently.

VPS monitoring: what to watch before changing plans

For this stack, Prometheus with node_exporter is enough. VPS monitoring should not eat a small server itself: we keep metrics for 15 days, and the container is capped at 300 MB. We skip Grafana, since the built-in Prometheus UI is enough for troubleshooting.

prometheus/prometheus.yml:

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: node
    static_configs:
      - targets: ["host.docker.internal:9100"]
  - job_name: catalog
    static_configs:
      - targets: ["app:8000"]
Enter fullscreen mode Exit fullscreen mode

The UI opens through an SSH tunnel at http://127.0.0.1:9090 on your own computer:

ssh -L 9090:127.0.0.1:9090 admin@catalog-01
Enter fullscreen mode Exit fullscreen mode

The minimum set of metrics: CPU load and run queue, available memory, iowait and disk latency, free space and network traffic. On the application side there is the catalog_db_seconds histogram, which also includes the wait for a free connection in the pool. A few queries to start with:

# Share of CPU time spent waiting for disk
avg(rate(node_cpu_seconds_total{mode="iowait"}[5m]))
# Average disk read latency, seconds
rate(node_disk_read_time_seconds_total[5m]) / rate(node_disk_reads_completed_total[5m])
# p99 of database work by operation type
histogram_quantile(0.99, sum by (le, op) (rate(catalog_db_seconds_bucket[5m])))
Enter fullscreen mode Exit fullscreen mode

The rule is simple: prove the bottleneck first, upgrade second. If response p99 rises together with catalog_db_seconds while the CPU is idle, more cores will not help.

Prometheus on the same server will not tell you that the server is down. For that you need an external HTTPS check from another machine or a third-party service. Trigger its alert manually once to make sure it actually reaches you.

A backup only exists if it restores

A dump on the same disk is not a backup. A backup includes a database dump in pg_dump -Fc format, the configs, the application image and a list of versions. Secrets are stored elsewhere and only in encrypted form. backup.sh collects all of it:

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
stamp=$(date -u +%Y%m%dT%H%M%SZ)
mkdir -p backups
tmp="backups/.${stamp}.dump.tmp"
docker compose exec -T db pg_dump -U postgres -Fc catalog > "$tmp"
mv "$tmp" "backups/${stamp}.dump"
tar -czf "backups/${stamp}-config.tar.gz" compose.yaml Caddyfile app db prometheus
docker compose images > "backups/${stamp}-versions.txt"
docker image save catalog-app:1.0.0 | gzip > "backups/${stamp}-app-image.tar.gz"
echo "Done: backups/${stamp}.dump"
Enter fullscreen mode Exit fullscreen mode

The dump is first written to a temporary file and gets its real name only after it completes successfully, so an interrupted backup cannot pass itself off as finished. Now the test: restore-test.sh starts a temporary PostgreSQL with no network, restores the dump into it, counts products and events and prints the time taken.

#!/usr/bin/env bash
set -euo pipefail
dump="$1"
name="catalog-restore-test"
docker run -d --rm --name "$name" --network none \
  -e POSTGRES_PASSWORD=restore-test -e POSTGRES_DB=catalog \
  postgres:18.6-alpine > /dev/null
trap 'docker stop "$name" > /dev/null' EXIT
# The temporary init server listens only on a socket, so wait for TCP
until docker exec "$name" pg_isready -h 127.0.0.1 -U postgres -d catalog > /dev/null 2>&1; do
  sleep 1
done
start=$(date +%s)
docker exec -i "$name" pg_restore -U postgres -d catalog \
  --no-owner --no-privileges --exit-on-error < "$dump"
docker exec "$name" psql -U postgres -d catalog -tAc "SELECT count(*) FROM items"
docker exec "$name" psql -U postgres -d catalog -tAc "SELECT count(*), max(created_at) FROM events"
echo "Restore and check took $(( $(date +%s) - start )) s"
Enter fullscreen mode Exit fullscreen mode

Run both:

./backup.sh
./restore-test.sh backups/20261030T031500Z.dump
Enter fullscreen mode Exit fullscreen mode

We expect 10,000 products and as many events as existed at backup time. The time in the output is only part of the RTO, the time to bring the service back. On a clean machine you also need to install Docker, fetch the backup, deploy the configs and secrets and check over HTTPS. Walk through the whole path once and record the result in the runbook.

Ship the finished files off the server, for example to a Storage VPS: at Aéza these are virtual machines in Moscow with HDDs from 1 TB. You can schedule the job with cron:

# /etc/cron.d/catalog-backup: dump at 03:15 UTC as user deploy from the docker group
15 3 * * * deploy /opt/catalog/backup.sh && rsync -a /opt/catalog/backups/ backup@storage.example.com:/srv/catalog/
Enter fullscreen mode Exit fullscreen mode

Check delivery too, or one day you will find that backups sat only on the production server for a month. And remember the limitation of dumps: recent writes between backups are lost. If that loss is unacceptable, look at physical backups with WAL archiving.

Why doesn't a VPS snapshot replace a backup?

A snapshot lives in the same infrastructure as the server itself and can disappear together with it if the site has a problem. On top of that, a snapshot taken mid-write may contain an inconsistent database. A backup is a separate copy in a different place, and you have already tested restoring from it.

Load testing: where the stack hits its limit

A VPS load test is run from a different machine: a generator on the same server steals CPU from the application and skews the results. Here is the k6 scenario for the catalog, load/catalog.js:

import http from 'k6/http';
import { check } from 'k6';

const BASE = __ENV.BASE_URL;
const TOKEN = __ENV.API_TOKEN;
const RATE = Number(__ENV.RATE || 10);

export const options = {
  scenarios: {
    step: {
      executor: 'constant-arrival-rate',
      rate: RATE,
      timeUnit: '1s',
      duration: '5m',
      preAllocatedVUs: 20,
      maxVUs: 200,
    },
  },
  thresholds: {
    http_req_duration: ['p(95)<300', 'p(99)<800'],
    http_req_failed: ['rate<0.01'],
    dropped_iterations: ['count<1'],
  },
  summaryTrendStats: ['p(50)', 'p(95)', 'p(99)', 'max'],
};

export default function () {
  const id = Math.floor(Math.random() * 100) + 1;
  if (Math.random() < 0.9) {
    const res = http.get(`${BASE}/items/${id}`, { tags: { name: 'item' } });
    check(res, { 'item 200': (r) => r.status === 200 && r.json('id') === id });
  } else {
    const res = http.post(`${BASE}/events`, JSON.stringify({ item_id: id }), {
      headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${TOKEN}` },
      tags: { name: 'event' },
    });
    check(res, { 'event 201': (r) => r.status === 201 });
  }
}
Enter fullscreen mode Exit fullscreen mode

90% of requests read product cards and 10% write events. IDs come from the first hundred products, so most reads will hit the cache. To see how the database itself holds up, repeat the run with Redis stopped.

Raise the load in steps of five minutes each. A short burst will not show you steady state. k6 passes the environment variables into the scenario itself:

export BASE_URL=https://catalog.example.com
export API_TOKEN="$(cat api_token)"  # copy the token file from the server
for rate in 10 20 40 80; do
  k6 run -e RATE=$rate load/catalog.js
  sleep 60
done
Enter fullscreen mode Exit fullscreen mode

After each step k6 shows p50, p95 and p99 latency, the error rate and the thresholds from the scenario. Watch dropped_iterations separately: if k6 runs out of virtual users, it skips iterations, and the advertised 80 requests per second simply never reach the server.

For each step, record the achieved RPS, latency, errors and dropped iterations, and in Prometheus for the same window: CPU, memory, iowait and catalog_db_seconds. Keep an eye on the generator too: if it is the one maxed out, the server is not to blame. And if the cause is a slow query or slow code, write that down. A VPS upgrade will not fix it.

Scaling the VPS: what to move out first

Scaling a VPS should start from a measured bottleneck. Usually you first grow the current server, then move the database or background jobs to a second machine, and backups and archives to a Storage VPS. A physical server is needed when high load is constant. Microservices are not a required step on this list.

At Aéza, VPS CPU, RAM and disk are upgraded in the control panel without migration: the data stays, the server reboots and is back in about a minute. The post-reboot check from the application section comes in handy here as well.

Symptom What to check Next step
Memory runs short, swap grows Container memory, connections, work_mem Add RAM or move the database out
CPU busy for hours Code profile, Gunicorn threads, background jobs Optimize, add vCPU; with steady load, a physical server
Disk latency and catalog_db_seconds rise Queries, execution plan, WAL writes Fix the SQL or move the database out
Backups crowd out working data Retention, volume of new data Archive on a Storage VPS
High latency with free resources Network, distance to users A location closer to your audience

If measurements show that the virtual machine is consistently short on CPU or steady I/O, run the same k6 scenario on an Aéza Dedicated Server. Physical servers start at €68.17 per month. With only occasional spikes, the move will most likely be unnecessary.

When is one VPS no longer enough for production?

When the bottleneck stays put after optimization and an upgrade: the database and the application get in each other's way, the CPU sits near full load for long stretches, and p99 climbs even under normal load. You also need a second server when downtime during a restore has become unacceptable. One machine remains a single point of failure, however powerful it is.

Pre-launch production checklist

Before you call the server production, go through the list. It contains only what we set up and tested above:

  • HTTPS opens, the certificate is issued, and its expiry was checked after a reboot.
  • After sudo reboot, the containers came back on their own and the event count did not change.
  • The firewall allows only SSH, 80 and 443, and the database and Redis ports are not open on the host.
  • Secrets live outside Git and the image, and the directory is closed to other users.
  • Services have health checks, memory limits and log caps.
  • A dump is created on schedule and shipped to another server.
  • A restore onto a clean PostgreSQL has been tested and the time recorded.
  • Prometheus collects metrics, and you know where to look for latency and disk.
  • There is a runbook: who owns the service, how to access the server, where the configs, backups and keys are, how to restore the service and how to roll back an update.

For updates, keep the previous image. Build the new version with a new tag, for example catalog-app:1.0.1, test it, and if something goes wrong, put the old tag back in compose.yaml and run docker compose up -d. Database migrations do not roll back this way, so plan their way back in advance.

What makes a production server is not the size of the plan but two proven things: the service restores from a backup, and you can see where it slows down. For a start, this €5.93 VPS web stack is perfectly adequate while the load stays moderate. Reproduce it yourself, run the k6 scenario and compare your numbers with the thresholds. From there, grow wherever the first bottleneck you find points.

Top comments (0)