Balance stateless replicas with shared idempotency and measured failover scaling
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
x-app: &app
|
||||
build: .
|
||||
image: mtusi-messenger:lab3
|
||||
env_file: .env
|
||||
cpus: 1.0
|
||||
mem_limit: 256m
|
||||
pids_limit: 64
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
stop_grace_period: 12s
|
||||
logging:
|
||||
driver: json-file
|
||||
options: {max-size: 5m, max-file: "2"}
|
||||
services:
|
||||
db:
|
||||
image: mirror.gcr.io/library/postgres@sha256:3645570cccdfa447589da9f57dd740faa29b30938e861289a5574b6ca6b03826
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run python scripts/bootstrap.py}
|
||||
command: [postgres, -c, shared_buffers=64MB, -c, max_connections=30]
|
||||
volumes: [pgdata:/var/lib/postgresql/data]
|
||||
cpus: 1.0
|
||||
mem_limit: 256m
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, "pg_isready -U messenger -d messenger"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 20
|
||||
cache:
|
||||
image: mirror.gcr.io/valkey/valkey@sha256:081c2f5cb575efc901aa80ff9cdbd1ec6a301682fd35e1ebb4b0990a4a4a8507
|
||||
command: [valkey-server, --maxmemory, 32mb, --maxmemory-policy, allkeys-lru, --save, "", --appendonly, "no"]
|
||||
cpus: 0.25
|
||||
mem_limit: 64m
|
||||
healthcheck:
|
||||
test: [CMD, valkey-cli, ping]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 20
|
||||
migrate:
|
||||
<<: *app
|
||||
command: [python, -m, src.migrate]
|
||||
healthcheck: {disable: true}
|
||||
depends_on:
|
||||
db: {condition: service_healthy}
|
||||
api:
|
||||
<<: *app
|
||||
deploy:
|
||||
replicas: 2
|
||||
cpus: 0.5
|
||||
mem_limit: 192m
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
cache: {condition: service_healthy}
|
||||
lb:
|
||||
image: mirror.gcr.io/library/haproxy@sha256:d84eb36e91830bcaa67b23cfde1909850b99f11eb60da3abd185bd0daf3f75bb
|
||||
ports: ["127.0.0.1:8080:8080"]
|
||||
volumes: ["./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro"]
|
||||
cpus: 0.5
|
||||
mem_limit: 64m
|
||||
read_only: true
|
||||
cap_drop: [ALL]
|
||||
security_opt: [no-new-privileges:true]
|
||||
depends_on:
|
||||
api: {condition: service_healthy}
|
||||
volumes:
|
||||
pgdata:
|
||||
Reference in New Issue
Block a user