Files
mtusi2026lab2/.env.example
vest1ter ac1317d22e ЛР2 на 5: Redis-кэш сессий, отказоустойчивость, трек 2 (индексы и восстановление)
Уровень 4:
- Redis как кэш сессий (cache-aside, источник истины — PostgreSQL): TTL <= остатка сессии,
  метка revoked при logout + SET NX против гонки, при отказе Redis — работа через базу
  и фоновая проверка доступности
- тесты: гонка регистрации, откат посреди транзакции, недоступность БД и Redis (44 теста)
- EXPLAIN (ANALYZE, BUFFERS) на 22 000 сообщений, history_query общий для API и скрипта
- эксперименты отказа Redis/PostgreSQL под нагрузкой; dns_opt у API, чтобы отказ БД
  давал быстрый 503, а не зависание на поиске имени остановленного контейнера

Уровень 5, трек 2:
- 105 000 сообщений в неравномерных чатах, 4 варианта индекса + OFFSET против keyset,
  стоимость записи (время, WAL), два независимых прогона
- pg_dump -> pg_restore в новый контейнер -> сверка md5 всех таблиц и выборки сообщений,
  RTO 14 с, демонстрация RPO
2026-10-29 15:42:37 +03:00

33 lines
1.7 KiB
Bash

# Copy to .env for your LOCAL synthetic test environment; never commit .env.
# Names follow pydantic-settings: prefix APP_CONFIG__, nesting via "__" (see app/core/config.py).
# Mapping to the skeleton's logical names: APP_HOST -> APP_CONFIG__RUN__HOST, APP_PORT -> APP_CONFIG__RUN__PORT,
# DATABASE_URL_FILE -> APP_CONFIG__DB__* (host/port/name/user + password file),
# SESSION_TTL_SECONDS -> APP_CONFIG__JWT__SESSION_TTL_SECONDS, SESSION_STORE=postgres (sessions table),
# CACHE_URL_FILE -> APP_CONFIG__REDIS__HOST/PORT + APP_CONFIG__REDIS__PASSWORD_FILE (Redis = session cache).
APP_CONFIG__RUN__HOST=0.0.0.0
APP_CONFIG__RUN__PORT=8080
APP_CONFIG__LOGGING__LEVEL=INFO
# PostgreSQL. Values below are for running the API from the venv on the host;
# inside Compose the defaults (host=postgres, /run/secrets/postgres_password) are used.
APP_CONFIG__DB__HOST=127.0.0.1
APP_CONFIG__DB__PORT=5432
APP_CONFIG__DB__NAME=messenger
APP_CONFIG__DB__USER=messenger
# Path only, never the password itself. Relative paths are resolved from the project root.
APP_CONFIG__DB__PASSWORD_FILE=secrets/postgres_password
# Sessions: JWT signed with a key from a secret file + server-side session row in PostgreSQL.
APP_CONFIG__JWT__SECRET_FILE=secrets/jwt_secret
APP_CONFIG__JWT__SESSION_TTL_SECONDS=3600
# Redis: cache of sessions (source of truth stays in PostgreSQL). Values for running from the venv;
# inside Compose the defaults (host=redis, /run/secrets/redis_password) are used.
APP_CONFIG__REDIS__HOST=127.0.0.1
APP_CONFIG__REDIS__PORT=6379
APP_CONFIG__REDIS__PASSWORD_FILE=secrets/redis_password
# Used by compose.yaml: host ports for PostgreSQL and Redis (bound to 127.0.0.1 only).
POSTGRES_HOST_PORT=5432
REDIS_HOST_PORT=6379