Skip to content

Commit a441ced

Browse files
docker-compose: add limits to prom memory usage to prevent OOMs
Reasoning behind Prometheus command query flags: --query.max-samples: each Prometheus data sample is 16 bytes. 16B * 31250000 = 1/2 GB. --query.max-concurrency: the max # of concurrent queries (default is 20). these parameters are intended to limit the amount of memory Prometheus uses for its queries to ~1GB, because it's sensitive to OOMs.
1 parent 488a50d commit a441ced

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

docker-compose.nginx.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ version: "3.7"
22

33
services:
44
prometheus:
5-
command: "--config.file=/etc/prometheus/prometheus.yml --web.external-url=https://${LETSENCRYPT_FQDN?}/prometheus --web.route-prefix=/"
5+
# Reasoning behind Prometheus command query flags:
6+
# --query.max-samples: each Prometheus data sample is 16 bytes.
7+
# 16B * 31250000 = 1/2 GB.
8+
# --query.max-concurrency: the max # of concurrent queries (default is 20).
9+
# these parameters are intended to limit the amount of memory Prometheus
10+
# uses for its queries to ~1GB, because it's sensitive to OOMs.
11+
command: "--config.file=/etc/prometheus/prometheus.yml --web.external-url=https://${LETSENCRYPT_FQDN?}/prometheus --web.route-prefix=/ --query.max-samples=31250000 --query.max-concurrency=2"
612

713
grafana:
814
volumes:

docker-compose.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ services:
1515
volumes:
1616
- ./prometheus.yml:/etc/prometheus/prometheus.yml
1717
- prometheus-storage:/prometheus
18-
command: "--config.file=/etc/prometheus/prometheus.yml"
18+
# Reasoning behind Prometheus command query flags:
19+
# --query.max-samples: each Prometheus data sample is 16 bytes.
20+
# 16B * 31250000 = 1/2 GB.
21+
# --query.max-concurrency: the max # of concurrent queries (default is 20).
22+
# these parameters are intended to limit the amount of memory Prometheus
23+
# uses for its queries to ~1GB, because it's sensitive to OOMs.
24+
command: "--config.file=/etc/prometheus/prometheus.yml --query.max-samples=31250000 --query.max-concurrency=2"
1925
ports:
2026
- "9090:9090"
2127
depends_on:

0 commit comments

Comments
 (0)