chore: optimize resource allocation and memory settings in Docker Compose

- Added memory and CPU limits and reservations for Prometheus, Grafana, and Uptime Kuma services to enhance performance and resource management.
- Updated Prometheus and Grafana configurations with new storage block duration settings for improved memory optimization.
- Revised README to include additional commands for running specific services and restarting containers.
This commit is contained in:
2026-01-23 21:38:48 +03:00
parent 75cd722cc4
commit 9e03c1f6f2
3 changed files with 56 additions and 6 deletions

View File

@@ -13,6 +13,9 @@ services:
- '--storage.tsdb.retention.time=${PROMETHEUS_RETENTION_DAYS:-30}d'
- '--web.enable-lifecycle'
- '--web.external-url=https://${SERVER_IP}/prometheus/'
# Оптимизация памяти
- '--storage.tsdb.max-block-duration=2h'
- '--storage.tsdb.min-block-duration=2h'
ports:
- "9090:9090"
volumes:
@@ -26,6 +29,14 @@ services:
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
memory: 128M
cpus: '0.5'
reservations:
memory: 64M
cpus: '0.25'
# Grafana Dashboard
grafana:
@@ -39,6 +50,10 @@ services:
- GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
- GF_SERVER_ROOT_URL=https://${SERVER_IP}/grafana/
- GF_SERVER_SERVE_FROM_SUB_PATH=true
# Оптимизация памяти
- GF_DATABASE_MAX_IDLE_CONN=2
- GF_DATABASE_MAX_OPEN_CONN=5
- GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH=/etc/grafana/provisioning/dashboards/node-exporter-full-dashboard.json
ports:
- "3000:3000"
volumes:
@@ -53,6 +68,14 @@ services:
interval: 30s
timeout: 10s
retries: 3
deploy:
resources:
limits:
memory: 200M
cpus: '0.5'
reservations:
memory: 100M
cpus: '0.25'
# Uptime Kuma Status Page
uptime-kuma:
@@ -73,6 +96,14 @@ services:
timeout: 10s
retries: 3
start_period: 40s
deploy:
resources:
limits:
memory: 150M
cpus: '0.5'
reservations:
memory: 80M
cpus: '0.25'
# Alertmanager
alertmanager: