forked from mtusi2026/mtusi2026lab3
The API service now names every timeout that the chain depends on: DRAIN_SECONDS, DB_ACQUIRE_TIMEOUT_SECONDS and DB_COMMAND_TIMEOUT_SECONDS join REQUEST_TIMEOUT_SECONDS and SHUTDOWN_TIMEOUT_SECONDS in compose, and the image gets the drain default. A unit test reads the compose defaults, the HAProxy check and timeout settings and the stop hook timeout, and checks that the chain shrinks inwards: LB server 10 s > request 8 s > pool wait plus statement 3 s, readiness 0.8 s < check 1 s, drain 2 s > worst detection 1.5 s, shutdown 5 s leaves 3 s for accepted requests, and shutdown < hook 6 s < stop_grace_period 8 s < 10 s. It also pins the declared detection maxima: 1.5 s for a 503 or a refused connection and 3.5 s for a hung replica. The k6 load generator joins the stand under the bench profile: pinned by digest, edge network only, 2 CPU and 512 MiB, no secrets. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
32 lines
1.1 KiB
Bash
32 lines
1.1 KiB
Bash
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
|
|
# These are logical interface suggestions; map actual framework names in REPORT.md.
|
|
APP_HOST=0.0.0.0
|
|
APP_PORT=8080
|
|
APP_ENV=lab
|
|
SESSION_TTL_SECONDS=3600
|
|
# Choose credentials locally. File paths contain no secret values.
|
|
DATABASE_URL_FILE=/run/secrets/database_url
|
|
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
|
|
SESSION_STORE=postgres
|
|
CACHE_URL_FILE=/run/secrets/cache_url
|
|
API_REPLICAS=2
|
|
IDEMPOTENCY_TTL_SECONDS=86400
|
|
# Solution-specific: published LB ports, replica limits, workers and pool per replica,
|
|
# LB queue per replica, drain window before closing the listener on SIGTERM, PostgreSQL
|
|
# limits, load generator limits (profile bench), cursor key file. API_PORT/SHORTTTL_PORT of lab2 are gone:
|
|
# only the load balancer is published.
|
|
LB_HTTP_PORT=8080
|
|
LB_STATS_PORT=8404
|
|
API_CPUS=1
|
|
API_MEMORY=512m
|
|
WEB_CONCURRENCY=2
|
|
DB_POOL_MAX_SIZE=8
|
|
API_SERVER_MAXCONN=64
|
|
DRAIN_SECONDS=2
|
|
PG_MAX_CONNECTIONS=200
|
|
PG_CPUS=2
|
|
PG_MEMORY=1g
|
|
K6_CPUS=2
|
|
K6_MEMORY=512m
|
|
CURSOR_SECRET_FILE=/run/secrets/cursor_secret
|