Thanos vs VictoriaMetrics: Choosing the Right Prometheus HA Solution for Production
This article compares Thanos and VictoriaMetrics for Prometheus high availability, analyzing architecture differences, resource costs, and PromQL compatibility, then provides detailed VictoriaMetrics cluster deployment configs, troubleshooting commands, migration tools, and operational best practices for 10M+ active series.
Reading font
01 Architecture Differences: Thanos vs VictoriaMetrics
Single-node Prometheus hits HA bottlenecks due to its local TSDB memory index model conflicting with stateless compute needs. At 5–10M active series, even Prometheus v3.15/v3.16 faces OOM, 10–30 min WAL replay, and federation cannot globally deduplicate historical data.
Two architectural paths emerged:
Thanos (ecosystem enhancement, v0.42.4) : Keeps Prometheus as scrape/hot node; Sidecar uploads 2h TSDB blocks to object storage (S3/OSS/MinIO). Stateless Query, Store Gateway, and single-instance Compactor assemble global view.
VictoriaMetrics (storage engine rewrite, LTS v1.148.9 / stable v1.156.0) : Abandons Prometheus TSDB format, uses custom LSM-tree MergeSet index and columnar Parts. Splits cluster into stateless write ( vminsert), stateless query ( vmselect), stateful storage ( vmstorage), with lightweight vmagent handling scrape and remote_write distribution.
1.1 Core Data Flow Topologies
VictoriaMetrics Cluster (v1.148.9 LTS) typical dual-AZ topology:
+-------------------------------------------------------------------+
| Collection Layer (stateless, local disk only for offline buffer) |
| [vmagent-az1: 10.10.1.11:8429] [vmagent-az2: 10.10.1.12:8429] |
| | (scrape targets) | (scrape targets) |
| +---------------+----------------+ |
| v (Remote Write + zstd, round-robin/shard) |
+-------------------------------------------------------------------+
| Ingress & Routing Layer (stateless, horizontal scale) |
| [vminsert-1: 10.10.2.11:8480] [vminsert-2: 10.10.2.12:8480] |
| | consistent hash (by MetricName+Labels) |
| +---------------+----------------+ |
+------------------------|----------------|-------------------------+
| Stateful Storage Layer (Shared-Nothing, default -replicationFactor=2) |
| [vmstorage-1: 10.10.3.11:8400] [vmstorage-2: 10.10.3.12:8400] |
| [vmstorage-3: 10.10.3.13:8400] (internal ports: 8400 insert / 8401 query) |
+------------------------^----------------^-------------------------+
| Query & Alert Layer (stateless, aggregation & dedup) |
| [vmselect-1: 10.10.2.21:8481] [vmselect-2: 10.10.2.22:8481] |
| ^ |
| [Grafana / vmalert: 10.10.2.30:8880] -> [vmauth: :8427] |
+-------------------------------------------------------------------+Thanos Sidecar (Prometheus v3.15 + Thanos v0.42.4) topology:
+-------------------------------------------------------------------+
| Collection & Hot Layer (dual replica scrape same targets, external_labels differ) |
| [Prom-A: 10.10.1.21:9090] <=> [Sidecar-A: 10.10.1.21:10901(gRPC)]|
| [Prom-B: 10.10.1.22:9090] <=> [Sidecar-B: 10.10.1.22:10901(gRPC)]|
| | (every 2h block upload) | (StoreAPI gRPC) |
+--------|--------------------------------|-------------------------+
| v | |
| [Object Storage S3/MinIO] <--- [Compactor: 10.10.3.21:10902 (STRICT SINGLE INSTANCE!)]|
| ^ | |
| | (local LRU index cache) | |
| [Store Gateway: 10.10.3.22:10901] | |
+--------|--------------------------------|-------------------------+
| +---------------+----------------+ |
| v (gRPC fanout + replica label dedup) |
| [Thanos Query: 10.10.2.25:10902/10904] <--- [Query-Frontend: 9090]|
+-------------------------------------------------------------------+Key engineering difference: VictoriaMetrics consolidates storage, index merging, and dedup inside vmstorage single binary; write path completes sharding and multi-replica. Thanos splits collection+hot storage, cold gateway, background compaction/downsampling, global query fanout into 4+ independent microservices; gRPC links and object storage consistency latency become troubleshooting focus.
02 Multi-Dimensional Selection Matrix (10M Active Series Baseline)
Baseline: 10M active series, 15s scrape interval, 667k samples/sec write, 90-day retention.
Storage Engine : VictoriaMetrics uses custom MergeSet + columnar zstd; Thanos uses Prometheus TSDB Block + object storage. VM compresses floats & label values 3–5x better.
Per-sample Disk : VM 0.4–0.8 Bytes/sample; Thanos local 1.3–1.8 Bytes, S3 ~1.2 Bytes. 90-day full retention: VM disk < half of Thanos.
Active Series Memory : VM ~1.2–1.8 KB/series (incl. index cache); Prometheus ~4–6 KB/series + Store cache. Dual Prometheus memory ~3x VM.
Component Count & Complexity : VM 4 core ( vmagent / vminsert / vmstorage / vmselect); Thanos 6+ ( Prom / Sidecar / Query / Frontend / Store / Compactor). Thanos Compactor has single-point lock & disk-full risk.
Dedup & HA Mechanism : VM vmagent active-active + vmstorage multi-replica / vmselect read-time dedup; Thanos Prometheus dual scrape + Thanos Query by replica label. VM supports native multi-tenant isolation; Thanos needs Receive mode.
PromQL Compatibility : VM MetricsQL (PromQL superset, ~99% compatible); Thanos 100% native PromQL (reuses Prometheus engine). Few native histogram reset edge-case semantic differences.
Hardware (10M series) : VM vmstorage x3 (8C 32G 2TB NVMe) + stateless ~16C 32G; Thanos Prom x2 (16C 64G 1TB SSD) + Store/Query/Compact ~24C 64G + S3. Thanos hot data still depends on large-memory Prometheus instances.
Monthly Cloud Cost (AWS us-west-2) : VM EC2+EBS gp3 ~ $1,450/mo (no object storage API fees); Thanos EC2+EBS+S3 storage & GET/LIST ~ $2,380/mo . Object storage high-frequency small-file scans inflate S3 API bill.
Weekly Ops Effort : VM ~0.2 person-days (single-binary upgrade, auto compaction); Thanos ~0.8 person-days (watch Compactor disk, Store cache, block corruption). Small/lean SRE teams prefer VM; heavy S3 ecosystem may choose Thanos.
Quick Selection Verdict
Primary: VictoriaMetrics Cluster – for 5M–100M active series, extreme memory/disk cost-efficiency, minimal ops overhead for long-term monitoring.
Alternative: Thanos – only if org has mature kube-prometheus-stack, strict 100% native PromQL (especially Native Histograms experimental), and existing enterprise S3/OSS quota.
03 VictoriaMetrics Cluster Full Production Config & Commands
Based on Ubuntu 24.04 LTS / Rocky Linux 9 with VictoriaMetrics v1.148.9 LTS (long-term support, stability & security validated).
3.1 Environment Pre-checks
Before deploying vmstorage and vmagent, verify kernel file descriptors, virtual memory mapping, and disk scheduler meet high-concurrency time-series write requirements.
# One-liner to check OS version, kernel params, disk mounts & free space
cat /etc/os-release | grep -E '^(NAME|VERSION)=' && \
uname -r && \
sysctl vm.max_map_count fs.file-max net.core.somaxconn && \
df -hT /data/vmstorage && \
lsblk -d -o NAME,ROTA,SCHED,SIZETypical baseline output:
NAME="Ubuntu"
VERSION="24.04.1 LTS (Noble Numbat)"
6.8.0-45-generic
vm.max_map_count = 262144 <-- critical: default 65530 triggers ENOMEM on large mmap, recommend >= 262144
fs.file-max = 2097152 <-- recommend >= 1048576
net.core.somaxconn = 32768 <-- prevent high-concurrency remote_write connection queue overflow
Filesystem Type Size Used Avail Use% Mounted on
/dev/nvme1n1 xfs 2.0T 12G 1.9T 1% /data/vmstorage <-- production strongly recommends XFS or ext4, disable NFS/CIFS
nvme1n1 0 none 2.0T <-- ROTA=0 means NVMe SSD, scheduler none is optimalIf vm.max_map_count < 262144, apply via dedicated sysctl config:
cat <<'EOF' | sudo tee /etc/sysctl.d/99-victoriametrics.conf
vm.max_map_count = 262144
fs.file-max = 2097152
net.core.somaxconn = 32768
vm.dirty_background_ratio = 5
vm.dirty_ratio = 15
EOF
sudo sysctl --system3.2 Core Component Production Configs & "Four-Dimensional Breakdown"
1) vmstorage (Stateful Storage Node, Systemd Service)
Create /etc/systemd/system/vmstorage.service (for node 10.10.3.11):
[Unit]
Description=VictoriaMetrics Storage Node (v1.148.9 LTS)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
LimitNOFILE=1048576
LimitNPROC=65536
ExecStart=/usr/local/bin/vmstorage-prod \
-storageDataPath=/data/vmstorage \
-retentionPeriod=90d \
-vminsertAddr=10.10.3.11:8400 \
-vmselectAddr=10.10.3.11:8401 \
-httpListenAddr=10.10.3.11:8482 \
-memory.allowedPercent=65 \
-dedup.minScrapeInterval=15s \
-search.maxUniqueTimeseries=500000 \
-bigMergeConcurrency=4 \
-smallMergeConcurrency=8 \
-loggerFormat=json
Restart=always
RestartSec=5s
KillSignal=SIGINT
TimeoutStopSec=120
[Install]
WantedBy=multi-user.targetApply changes : Modify systemd unit params then
sudo systemctl daemon-reload && sudo systemctl restart vmstorage(restart required, no hot reload).
Four-dimensional breakdown :
2) vminsert & vmselect (Stateless Ingest & Query Layers)
vminsertservice ( 10.10.2.11):
[Unit]
Description=VictoriaMetrics Insert Node
After=network-online.target
[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
LimitNOFILE=1048576
ExecStart=/usr/local/bin/vminsert-prod \
-httpListenAddr=10.10.2.11:8480 \
-storageNode=10.10.3.11:8400,10.10.3.12:8400,10.10.3.13:8400 \
-replicationFactor=2 \
-maxConcurrentInserts=64 \
-memory.allowedPercent=70 \
-loggerFormat=json
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.targetvmselectservice ( 10.10.2.21):
[Unit]
Description=VictoriaMetrics Select Node
After=network-online.target
[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
LimitNOFILE=1048576
ExecStart=/usr/local/bin/vmselect-prod \
-httpListenAddr=10.10.2.21:8481 \
-storageNode=10.10.3.11:8401,10.10.3.12:8401,10.10.3.13:8401 \
-replicationFactor=2 \
-dedup.minScrapeInterval=15s \
-search.maxConcurrentRequests=16 \
-search.maxQueryDuration=30s \
-search.maxMemoryPerQuery=2GB \
-cacheDataPath=/var/cache/vmselect \
-memory.allowedPercent=70
Restart=always
RestartSec=5s
[Install]
WantedBy=multi-user.targetFour-dimensional breakdown :
3) vmagent (HA Collection & Buffer Layer)
Config /etc/victoriametrics/prometheus.yml (supports curl -X POST http://10.10.1.11:8429/-/reload hot reload, no collection interruption):
global:
scrape_interval: 15s
scrape_timeout: 10s
external_labels:
cluster: "prod-cn-east-1"
# Note: when vmagent dual-active writes same cluster, can use same label or rely on dedup
replica: "az1"
scrape_configs:
- job_name: "node_exporter"
metrics_path: "/metrics"
static_configs:
- targets:
- "10.10.10.1:9100"
- "10.10.10.2:9100"
relabel_configs:
- source_labels: [__address__]
regex: "([^:]+):.*"
target_label: instance
replacement: "${1}"
metric_relabel_configs:
# Production cardinality guard: drop useless high-cardinality kernel slab/percpu metrics
- source_labels: [__name__]
regex: "node_systemd_unit_state|go_gc_.*"
action: dropvmagentsystemd service (uses controlled-permission env file for auth credentials):
[Unit]
Description=VictoriaMetrics Agent
After=network-online.target
[Service]
Type=simple
User=victoriametrics
Group=victoriametrics
EnvironmentFile=/etc/victoriametrics/vmagent.env
ExecStart=/usr/local/bin/vmagent-prod \
-promscrape.config=/etc/victoriametrics/prometheus.yml \
-httpListenAddr=10.10.1.11:8429 \
-remoteWrite.url=http://10.10.2.11:8480/insert/0/prometheus/api/v1/write \
-remoteWrite.url=http://10.10.2.12:8480/insert/0/prometheus/api/v1/write \
-remoteWrite.tmpDataPath=/var/lib/vmagent-remotewrite-data \
-remoteWrite.maxDiskUsagePerURL=20GB \
-remoteWrite.queues=8 \
-remoteWrite.maxBlockSize=32MB \
-remoteWrite.dropSamplesOnOverload=false \
-promscrape.streamParse=true
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
[Install]
WantedBy=multi-user.target/etc/victoriametrics/vmagent.envpermissions must be strict 0600:
sudo install -o victoriametrics -g victoriametrics -m 0600 /dev/null /etc/victoriametrics/vmagent.envVerification commands & output:
sudo systemctl daemon-reload && \
sudo systemctl enable --now vmstorage vminsert vmselect vmagent && \
curl -sS -m 3 http://10.10.1.11:8429/targets | head -n 15Status:
node_exporter (2/2 up)
Endpoint State Labels
http://10.10.10.1:9100/metrics UP {instance="10.10.10.1",job="node_exporter"} <-- UP means collection path healthy
http://10.10.10.2:9100/metrics UP {instance="10.10.10.2",job="node_exporter"}3.3 High-Frequency One-Liners & Troubleshooting Cheatsheet
Check long-lived connections & send queue backlog between vmstorage and vminsert / vmselect ( ss ):
ss -tinp state established '( sport = :8400 or sport = :8401 )' | \
awk 'NR>1 {print $1, $2, $3, $4, $5}' | head -n 20Recv-Q Send-Q Local Address:Port Peer Address:Port
0 0 10.10.3.11:8400 10.10.2.11:48292 <-- Send-Q >0 sustained means network saturated or peer consumption blocked
0 4194304 10.10.3.11:8401 10.10.2.21:51034 <-- key: 8401 Send-Q backlog 4MB indicates vmselect slow readsFor questions about attribution, corrections or content rights, please contactand we will review it promptly.