forked from mtusi2026/mtusi2026lab5
RabbitMQ (quorum queue, publisher confirms, manual ack, DLX) + отдельный worker: staging в S3 + вложение/job/outbox одной транзакцией -> 202 queued; relay outbox, lease с heartbeat и fencing (worker_id, attempt), retry с backoff+jitter, failed-реестр, безопасный replay с audit; thumbnail/crop/WebP в изолированном процессе с лимитами. Тесты окон отказа (fault injection), трек 1 «Очередь под перегрузкой» с backpressure. Перенесено исправление замечания lab3 PR #99 (U+0000 в тексте). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.6 KiB
Bash
69 lines
2.6 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:
|
|
# postgres - sessions only in PostgreSQL
|
|
# postgres+valkey - PostgreSQL is the source of truth, Valkey is a shared read-through session cache with TTL
|
|
SESSION_STORE=postgres+valkey
|
|
CACHE_URL_FILE=/run/secrets/cache_url
|
|
API_REPLICAS=2
|
|
IDEMPOTENCY_TTL_SECONDS=86400
|
|
S3_ENDPOINT=http://s3:9000
|
|
S3_REGION=us-east-1
|
|
S3_BUCKET=messenger-attachments
|
|
S3_ACCESS_KEY_ID_FILE=/run/secrets/s3_access_key_id
|
|
S3_SECRET_ACCESS_KEY_FILE=/run/secrets/s3_secret_access_key
|
|
MAX_UPLOAD_BYTES=10485760
|
|
MAX_IMAGE_PIXELS=40000000
|
|
BROKER_URL_FILE=/run/secrets/broker_url
|
|
WORKER_CONCURRENCY=2
|
|
JOB_MAX_ATTEMPTS=5
|
|
JOB_TIMEOUT_SECONDS=60
|
|
STAGING_RETENTION_SECONDS=86400
|
|
# --- solution-specific (lab3) ---
|
|
# Max lifetime of a cached session copy (also the cache-distrust window after a Valkey error)
|
|
SESSION_CACHE_TTL_SECONDS=60
|
|
# On SIGTERM a replica keeps serving but reports not-ready this long, so the LB drains it
|
|
SHUTDOWN_DRAIN_MS=3000
|
|
# Bounded pool and timeouts, per replica
|
|
DB_POOL_MAX=10
|
|
DB_STATEMENT_TIMEOUT_MS=5000
|
|
DB_ACQUIRE_TIMEOUT_MS=2000
|
|
CACHE_TIMEOUT_MS=300
|
|
# Parallel Argon2id computations per replica (each uses 64 MiB)
|
|
PASSWORD_HASH_WORKERS=2
|
|
# --- solution-specific (lab4) ---
|
|
# Deadline of one S3 operation (connect 2 s, no retries); after it the API answers 503
|
|
S3_TIMEOUT_MS=5000
|
|
# Parallel image validations per replica (CPU/RAM bound)
|
|
IMAGE_CHECK_WORKERS=2
|
|
# --- solution-specific (lab5) ---
|
|
# Unacked messages RabbitMQ hands to one worker (defaults to WORKER_CONCURRENCY)
|
|
WORKER_PREFETCH=2
|
|
# Processing lease, extended by worker heartbeat every lease/3; expired lease -> job re-queued by reaper
|
|
JOB_LEASE_SECONDS=15
|
|
# Retry backoff: min(RETRY_MAX_MS, RETRY_BASE_MS * 2^(attempt-1)), equal jitter
|
|
RETRY_BASE_MS=1000
|
|
RETRY_MAX_MS=60000
|
|
# Backpressure: uploads get 503 + Retry-After when queued+processing jobs reach this number
|
|
MAX_PENDING_JOBS=200
|
|
# Outbox relay poll interval (relay is also woken right after each upload COMMIT)
|
|
OUTBOX_POLL_MS=500
|
|
# Address-space limit of one image-processing child process
|
|
WORKER_TASK_MEMORY_MB=640
|
|
WORKER_REPLICAS=1
|
|
WORKER_CPUS=2.0
|
|
WORKER_MEMORY=1536M
|
|
# Per-replica limits
|
|
API_CPUS=1.0
|
|
API_MEMORY=384M
|
|
PG_CPUS=2.0
|
|
# Host ports bound to 127.0.0.1: LB entrypoint and LB stats page
|
|
LB_PUBLISHED_PORT=8080
|
|
LB_STATS_PORT=8404
|