Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
98 lines (93 loc) · 3.26 KB
/
Copy pathdocker-compose.yml
File metadata and controls
98 lines (93 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
services:
origin:
image: postgres:18@sha256:78481659c47e862334611ccdaf7c369c986b3046da9857112f3b309114a65fb4
container_name: dba-origin
environment:
POSTGRES_USER: pgcache
POSTGRES_PASSWORD: pgcache
POSTGRES_DB: dba_se
ports:
- "55432:5432"
# postgres:18 stores data in a major-version-specific subdirectory under
# /var/lib/postgresql; mount the parent dir per the upstream image guidance
# (https://github.com/docker-library/postgres/pull/1259).
volumes:
- origin-data:/var/lib/postgresql
command:
- postgres
- -c
- wal_level=logical
- -c
- max_wal_senders=10
- -c
- max_replication_slots=10
- -c
- shared_buffers=256MB
- -c
- max_connections=300
pgcache:
# Multi-arch (amd64 + arm64) digest pin. Override with PGCACHE_IMAGE to
# benchmark a different release.
image: ${PGCACHE_IMAGE:-pgcache/pgcache:0.6.2-a3@sha256:31f99b5e4d246f693f3c1eaa446ccf745b2b17a4cf33bb7f19104bafc1a06bd3}
container_name: dba-pgcache
depends_on: [origin]
# Cap pgcache's auto-tuned memory: with mem_limit=4g, memory_detect inside
# the container returns 4g → shared_buffers = 1g → shm target = 2g. Keeps
# the stack within Docker Desktop's 8GB VM (origin + the rest leave
# little headroom).
mem_limit: 4g
shm_size: 2gb
environment:
UPSTREAM_URL: postgres://pgcache:pgcache@origin:5432/dba_se
LISTEN_PORT: 5432
METRICS_PORT: 9090
LOG_LEVEL: ${PGCACHE_LOG_LEVEL:-info}
ports:
- "55433:5432"
- "59090:9090"
prometheus:
image: prom/prometheus:v3.11.3@sha256:e4254400b85610324913f0dc4acf92603d9984e7519414c5a12811aa6146acc3
container_name: dba-prometheus
profiles: [observability]
depends_on: [pgcache, origin-exporter]
extra_hosts:
# Lets the in-container Prometheus reach the host-side driver via
# `host.docker.internal:9100` on Linux as well as Docker Desktop.
- "host.docker.internal:host-gateway"
volumes:
- ./observability/prometheus.yml:/etc/prometheus/prometheus.yml:ro
- prometheus-data:/prometheus
command:
- --config.file=/etc/prometheus/prometheus.yml
- --storage.tsdb.path=/prometheus
- --storage.tsdb.retention.time=2h
ports:
- "59091:9090"
# postgres-exporter scrapes pg_stat_* views off the origin and exposes them
# as Prometheus metrics. On macOS Docker Desktop cAdvisor only sees the
# root cgroup (no per-container CPU split) so this is the right way to
# show "origin under pressure" panels regardless of host OS.
origin-exporter:
image: prometheuscommunity/postgres-exporter:v0.19.1@sha256:e96064f876226d94bb6ce48a4c4b3dd76edba91168ec1ab024e5c4b959310b0f
container_name: dba-origin-exporter
profiles: [observability]
depends_on: [origin]
environment:
DATA_SOURCE_NAME: postgresql://pgcache:pgcache@origin:5432/dba_se?sslmode=disable
loader:
build: ./load
image: pgcache-bench-dba/loader:latest
profiles: [tools]
depends_on: [origin]
environment:
PGHOST: origin
PGPORT: 5432
PGUSER: pgcache
PGPASSWORD: pgcache
PGDATABASE: dba_se
volumes:
- ./data:/data
- ./load:/load
volumes:
origin-data:
prometheus-data: