Waking up to an OOM-killed Prometheus container during an incident is a rite of passage nobody wants. Prometheus excels at scraping targets and firing short-term alerts. Try keeping 6 to 12 months of metrics on a single node, though, and RAM usage climbs past 16 GB or 32 GB while Grafana panels time out.
Local storage architecture is the bottleneck. Prometheus maintains an in-memory inverted index for every active time series and buffers recent samples in a memory-mapped head block. Add ephemeral Kubernetes pods or high-cardinality labels, and that index balloons fast.
Traditional databases like MySQL, PostgreSQL, or MongoDB solve different problems—relational integrity, complex joins, or flexible documents. None of them can ingest 500,000+ timestamped numeric samples per second without choking. You need a purpose-built time-series database (TSDB).
VictoriaMetrics solves this without adding operational sprawl. It ships as a single, dependency-free binary in Docker, speaks PromQL natively, and ingests Prometheus remote_write streams directly. In production, it routinely uses 5x to 10x less RAM and disk space than Prometheus for long-term retention.
Quick Start: Deploy VictoriaMetrics on Docker in 5 Minutes
A single-node container is plenty to start. On modest hardware—say, 2 vCPUs and 2 GB of RAM—it comfortably handles millions of active time series.
Create a persistent Docker volume first, then launch the VictoriaMetrics container:
docker volume create vmdata
docker run -d \
--name victoriametrics \
--restart unless-stopped \
-p 8428:8428 \
-v vmdata:/victoria-metrics-data \
victoriametrics/victoria-metrics:v1.106.1 \
-storageDataPath=/victoria-metrics-data \
-retentionPeriod=12
Setting -retentionPeriod=12 keeps metrics for 12 months instead of the 1-month default. Port 8428 serves the HTTP query API, ingestion endpoints, and the built-in vmui web interface.
Now point your existing Prometheus server to VictoriaMetrics by adding a remote_write block to prometheus.yml:
global:
scrape_interval: 15s
remote_write:
- url: http://victoriametrics:8428/api/v1/write
Reload Prometheus and give it 30 seconds to flush a batch. Then verify that samples are landing by querying the PromQL-compatible API:
curl -s "http://localhost:8428/api/v1/query?query=up" | jq .
Seeing "status": "success" alongside your targets in data.result confirms the pipeline is live. Open http://localhost:8428/vmui in your browser to explore metrics and test queries right away.
Why Prometheus Struggles—and How VictoriaMetrics Fixes It
What Causes Prometheus Memory Spikes
Prometheus was built as a reliable monitoring and alerting engine, not a multi-year warehouse. Every new label combination—such as a restarted pod with a fresh hash—creates a new series in its head block and updates the postings index. Even after a pod terminates, its metadata stays in RAM until the two-hour block compacts to disk. Across 500 microservices redeploying daily over a 90-day window, stale series pile up and force you onto expensive high-memory instances.
How VictoriaMetrics Cuts RAM and Disk Usage
VictoriaMetrics borrows heavily from LSM-trees and column-oriented databases:
- Aggressive compression: Timestamps and values live in separate columnar blocks compressed with specialized encoding and ZSTD. A sample that takes 1–2 bytes in Prometheus typically shrinks to 0.4–0.8 bytes in VictoriaMetrics.
- Bounded memory caches: Instead of pinning the entire active index in RAM, an adaptive caching layer scales to fit your container memory limits.
- Background merges: Small data parts continuously merge into larger, sorted immutable parts on disk. Queries scanning 6 months of history stay fast because read amplification stays low.
- Drop-in compatibility: Because it implements the Prometheus HTTP API, you can point Grafana’s existing Prometheus data source to
http://victoriametrics:8428without rewriting a single dashboard.
Production Setup: Docker Compose, Retention, and Backups
Full Docker Compose Stack
Isolated docker run commands work fine for quick tests. Production setups need isolated networking, explicit memory limits, and Grafana wired up alongside Prometheus. Save this configuration as docker-compose.yml:
services:
victoriametrics:
image: victoriametrics/victoria-metrics:v1.106.1
container_name: victoriametrics
restart: unless-stopped
ports:
- "8428:8428"
volumes:
- vmdata:/victoria-metrics-data
command:
- "-storageDataPath=/victoria-metrics-data"
- "-retentionPeriod=12"
- "-dedup.minScrapeInterval=15s"
- "-memory.allowedPercent=70"
deploy:
resources:
limits:
memory: 2G
prometheus:
image: prom/prometheus:v2.55.0
container_name: prometheus
restart: unless-stopped
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- promdata:/prometheus
command:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.retention.time=2d"
depends_on:
- victoriametrics
grafana:
image: grafana/grafana:11.3.0
container_name: grafana
restart: unless-stopped
ports:
- "3000:3000"
volumes:
- grafanadata:/var/lib/grafana
depends_on:
- victoriametrics
volumes:
vmdata:
promdata:
grafanadata:
Two flags do the heavy lifting here. Keeping Prometheus at 2d of local retention gives you a 48-hour buffer during VictoriaMetrics upgrades without hogging RAM. Meanwhile, -dedup.minScrapeInterval=15s automatically deduplicates samples if you later add a second HA Prometheus instance scraping the same targets.
Zero-Downtime Snapshots for Backups
Copying raw database files while a TSDB is actively writing risks corruption. VictoriaMetrics exposes a snapshot API that creates a consistent, hard-linked point-in-time copy without pausing ingestion. Because the official image is built on scratch and has no shell or tar binary, use a lightweight Alpine container to archive the snapshot volume:
# 1. Create a consistent snapshot
SNAPSHOT=$(curl -s http://localhost:8428/snapshot/create | jq -r .snapshot)
echo "Created snapshot: $SNAPSHOT"
# 2. Archive the snapshot using a temporary Alpine container
docker run --rm \
-v vmdata:/data:ro \
-v "$(pwd)":/backup \
alpine tar -czf /backup/vm-backup.tar.gz -C "/data/snapshots/$SNAPSHOT" .
# 3. Delete the snapshot to free hard links
curl -s "http://localhost:8428/snapshot/delete?snapshot=$SNAPSHOT"
Hard links make snapshot creation take milliseconds. Extra disk usage stays near zero until background merges clean up older data parts.
Practical Tips from Running VictoriaMetrics in Production
- Set container memory limits explicitly: Pair Docker’s memory limit with
-memory.allowedPercent=70(up from the 60% default). VictoriaMetrics reads cgroup limits to size its internal caches, preventing sudden OOM kills on shared hosts. - Guard against label cardinality explosions: VictoriaMetrics tolerates high cardinality far better than Prometheus, but unbounded values like
request_idoruser_emailwill still bloat your index. Keep those fields in logs or traces. - Watch out for MetricsQL vs. PromQL: VictoriaMetrics extends PromQL with conveniences like
rollup_rate()and thedefaultoperator. They simplify messy Grafana panels, yet sticking to standard PromQL in alert rules keeps your setup portable. - Consider vmagent for edge nodes: If you only need to scrape metrics and forward them without local alerting, swap Prometheus out for
vmagent. It often runs in 20–50 MB of RAM and buffers samples to disk during network outages.
Offloading long-term metrics to VictoriaMetrics on Docker takes under ten minutes. Let Prometheus focus on short-term scraping and alerting, hand the 12-month history to VictoriaMetrics, and stop babysitting memory graphs.

