ЛР 3 - БВТ2303 - Савин - на 5 #79
+10
-11
@@ -1,13 +1,12 @@
|
||||
# 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
|
||||
# scripts/bootstrap.sh creates a random local password without overwriting .env.
|
||||
POSTGRES_PASSWORD=choose_a_local_password
|
||||
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
|
||||
# Defaults; optional experiment/rollout parameters:
|
||||
API_IMAGE=mtusi-lab3-api:local
|
||||
API_REPLICAS=2
|
||||
IDEMPOTENCY_TTL_SECONDS=86400
|
||||
API_CPUS=2
|
||||
API_MEMORY=256m
|
||||
DB_POOL_MAX_SIZE=5
|
||||
DB_CPUS=1
|
||||
LB_CPUS=0.25
|
||||
CACHE_CLIENT_MODE=shared
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
## Лабораторная 3
|
||||
|
||||
Автор / группа: TODO
|
||||
Целевая оценка (3/4/5): TODO
|
||||
Трек 5, если заявлен: TODO
|
||||
Автор: Савин Александр, БВТ2303. Целевая оценка: **5, трек 1 — цена масштабирования**.
|
||||
|
||||
Что реализовано и что перенесено: TODO
|
||||
Команды запуска из чистого clone: TODO
|
||||
Результаты проверок и ссылка на REPORT.md: TODO
|
||||
Ограничения / известные ошибки: TODO
|
||||
Источники и использование ИИ: TODO
|
||||
Из lab2 перенесены FastAPI/PostgreSQL/Valkey, общие действующие сессии, Argon2id и пагинация. Добавлены HAProxy с Docker DNS и active readiness, две API-реплики, отдельный согласованный мигратор, транзакционная идемпотентность, CPU/RAM-лимиты, hooks отказа и полного рестарта, настоящая последовательная замена контейнеров новым образом под нагрузкой.
|
||||
|
||||
- [ ] Весь обязательный минимум текущей и предыдущих работ сохранён с объявленными переходами.
|
||||
- [ ] Контракт и публичные тесты не ослаблены.
|
||||
- [ ] make check и make test выполнены; приложен реальный вывод.
|
||||
- [ ] Сценарии отказов/безопасности своего уровня воспроизведены.
|
||||
- [ ] Все секреты и приватные ключи находятся вне Git; отчёт не содержит tokens.
|
||||
- [ ] README задания сохранён, REPORT.md содержит инструкцию именно моего решения.
|
||||
Исследование: 42 запуска с raw latency/ошибками и CPU/RAM, 1/2/4 API при фиксированном и растущем бюджете, насыщение по concurrency и вмешательство в CPU-квоту БД. Подтверждённое улучшение кода — общий пул Valkey: почти устранён churn соединений, средний throughput этого профиля вырос на 31.3% (разброс и ограничения описаны).
|
||||
|
||||
Запуск: `./scripts/bootstrap.sh`, `./scripts/compose.sh up -d --build`, дождаться `/health/ready`. Подробные команды/критерии: [REPORT.md](../REPORT.md). Методика, графики и выводы: [RESEARCH.md](../RESEARCH.md). Реальные результаты: evidence/. Локальный порт — 8083; lab2 на 8080 не менялась.
|
||||
|
||||
Ограничения: один Docker-host, LB/БД не реплицированы; нет защиты от потери volumes. Короткий closed-loop benchmark в VM не доказывает универсальную production-capacity. Несовместимые миграции требуют отдельного deployment-процесса. Первичные источники и библиотеки перечислены в REPORT.md; использовался Codex.
|
||||
|
||||
- [x] Контракт, README задания и публичные тесты сохранены.
|
||||
- [x] Параметры стенда, миграций, health, DNS и shutdown документированы.
|
||||
- [x] Исследование содержит гипотезы, raw data, повторы, графики и ограничения.
|
||||
- [x] Локальные секреты исключены из Git; доказательства не содержат токенов.
|
||||
|
||||
Проверки API, отказов, rolling и сохранности перечислены с файлами фактического вывода в REPORT.md.
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
FROM python:3.11.11-slim
|
||||
|
||||
ENV PYTHONDONTWRITEBYTECODE=1 \
|
||||
PYTHONUNBUFFERED=1 \
|
||||
APP_HOST=0.0.0.0 \
|
||||
APP_PORT=8080 \
|
||||
DATABASE_URL=postgresql://messenger:messenger@db:5432/messenger \
|
||||
SESSION_TTL_SECONDS=3600
|
||||
|
||||
WORKDIR /app
|
||||
COPY requirements.txt /app/requirements.txt
|
||||
RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
ARG APP_REVISION=lab3-v2
|
||||
ENV APP_REVISION=$APP_REVISION
|
||||
COPY app.py migrate.py /app/
|
||||
COPY migrations /app/migrations
|
||||
COPY scripts /app/scripts
|
||||
COPY tests/client.py /app/tests/client.py
|
||||
COPY contracts /app/contracts
|
||||
COPY lab.json /app/lab.json
|
||||
EXPOSE 8080
|
||||
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8080"]
|
||||
@@ -28,3 +28,34 @@ test-persistence:
|
||||
test-failover:
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
.PHONY: test-idempotency up down
|
||||
up:
|
||||
./scripts/bootstrap.sh
|
||||
./scripts/compose.sh up -d --build
|
||||
|
||||
down:
|
||||
./scripts/compose.sh down
|
||||
|
||||
test-idempotency:
|
||||
$(PYTHON) tests/idempotency_concurrent.py --base-url "$(BASE_URL)"
|
||||
|
||||
.PHONY: test-replicas test-rolling research-scaling plot-scaling
|
||||
# The target image must already be built; API_IMAGE selects it.
|
||||
test-rolling:
|
||||
$(PYTHON) tests/rolling_update.py --base-url "$(BASE_URL)"
|
||||
|
||||
test-replicas:
|
||||
$(PYTHON) tests/replica_matrix.py --base-url "$(BASE_URL)"
|
||||
|
||||
research-scaling:
|
||||
$(PYTHON) scripts/research_scaling.py --base-url "$(BASE_URL)"
|
||||
|
||||
plot-scaling:
|
||||
$(PYTHON) scripts/plot_scaling.py
|
||||
$(PYTHON) scripts/summarize_research.py
|
||||
|
||||
.PHONY: test-cache
|
||||
# Run inside the private Compose network; no DB/cache ports are exposed.
|
||||
test-cache:
|
||||
./scripts/compose.sh exec -T -e BASE_URL=http://lb:8080 -e CACHE_URL=redis://valkey:6379/0 api python - < tests/cache_consistency.py
|
||||
|
||||
@@ -1,37 +1,124 @@
|
||||
# Отчёт — лабораторная 3
|
||||
# Лабораторная работа 3 — балансировка и отказ API
|
||||
|
||||
- Автор, группа: TODO
|
||||
- Целевая оценка; выбранный трек 5, если нужен: TODO
|
||||
- Commit/PR: TODO после публикации
|
||||
- Использованные источники, библиотеки и помощь ИИ: TODO
|
||||
Автор: Савин Александр, БВТ2303. Целевая оценка: **5, трек 1 — цена масштабирования**
|
||||
|
||||
## Запуск из чистого clone
|
||||
|
||||
TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных.
|
||||
Нужны Docker Engine и Compose v2 (`docker compose` либо `docker-compose`), Python 3.9+ для проверок. scripts/compose.sh выбирает доступную форму Compose. Образы закреплены: Python 3.11.11-slim, PostgreSQL 16.6-alpine, Valkey 8.0.2-alpine, HAProxy 3.0.5-alpine. Зависимости API — requirements.txt, графиков — requirements-research.txt.
|
||||
|
||||
## Архитектура и решения
|
||||
```sh
|
||||
cd mtusi2026lab3
|
||||
./scripts/bootstrap.sh
|
||||
# Если 8080 занят, в .env установить APP_PORT=8083.
|
||||
./scripts/compose.sh config --quiet
|
||||
./scripts/compose.sh up -d --build
|
||||
# Дождаться HTTP 200 от /health/ready и двух healthy API:
|
||||
./scripts/compose.sh ps -a
|
||||
export BASE_URL=http://localhost:8083 # или свой APP_PORT
|
||||
make check
|
||||
make test
|
||||
make test-idempotency
|
||||
make test-cache
|
||||
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
./scripts/compose.sh start api
|
||||
# Дождаться возвращения двух реплик через LB.
|
||||
make test-replicas
|
||||
make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
```
|
||||
|
||||
TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab2, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации.
|
||||
Bootstrap создаёт случайный пароль в локальном .env с правами 600, существующий файл не перезаписывает. .env исключён из Git и Docker build context. Пароль передаётся контейнерам через environment — учебное упрощение: оператор Docker может его прочитать. Только LB публикует порт, API/БД/Valkey наружу не опубликованы. Данные соседней lab2 не подключаются и не меняются. На текущей машине lab3 работает на 8083, lab2 остаётся на 8080.
|
||||
|
||||
## Доказательства критериев
|
||||
Полная OpenAPI-валидация: установить requirements-dev.txt в venv, затем `make validate PYTHON=.venv/bin/python`. Остановка с сохранением данных: `./scripts/compose.sh down`; возврат: `./scripts/compose.sh up -d`. Намеренное удаление учебных данных lab3: `./scripts/compose.sh down -v`; для проверок это не нужно.
|
||||
|
||||
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
|
||||
| --- | --- | --- | --- |
|
||||
| Публичный smoke | make test | TODO | TODO |
|
||||
| Остальные пункты уровня 3 | TODO | TODO | TODO |
|
||||
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
|
||||
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
|
||||
## Архитектура и переход от lab2
|
||||
|
||||
TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены.
|
||||
Клиент → HAProxy → Compose service api ×2 → общие PostgreSQL и Valkey. PostgreSQL хранит пользователей, сессии, чаты, членство, сообщения и результаты идемпотентных запросов. Valkey — общий необязательный кэш сессий с AOF. Пагинация, Argon2id, проверки прав, expiry/revocation и сверка идентичности кэша с БД перенесены из lab2. Локальных сессий API нет; sticky sessions не используются.
|
||||
|
||||
## Эксперименты и отказы
|
||||
X-Instance-Id равен hostname контейнера и сопоставляется с docker inspect. X-App-Revision показывает сборочную ревизию образа. Секреты в заголовки не попадают. Здесь не заявляется требование lab7 скрывать hostname.
|
||||
|
||||
TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения.
|
||||
Новый Store создаёт один клиент Valkey с библиотечным пулом на процесс, закрывает при shutdown. Контрольный режим CACHE_CLIENT_MODE=per_request воспроизводит прежнее создание клиента на каждую операцию; обычный режим shared. Обязательный SELECT сессии и сравнение кэшированных данных с PostgreSQL остаются. Повреждённый/чужой/отозванный кэш не определяет личность пользователя.
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| TODO | TODO | TODO | TODO |
|
||||
## Readiness, DNS и завершение
|
||||
|
||||
## Ограничения и следующие шаги
|
||||
Docker-healthcheck использует лёгкий HTTP-probe на socket с сетевым timeout 1s и бюджетом процесса 4s (interval 2s, retries 2); это учитывает холодный запуск вспомогательного Python. HAProxy: roundrobin, активный GET /health/ready раз в секунду, fall=2, rise=1, timeout check=1s. Расчётное обнаружение отказа — около 4 секунд в худшем сочетании двух интервалов/timeout при нормальном планировании; это не SLA при перегрузке. Readiness проверяет PostgreSQL; live — процесс. Valkey не блокирует readiness, поскольку есть fallback в БД.
|
||||
|
||||
TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза.
|
||||
Docker DNS 127.0.0.11:53 обновляет backend-адреса: server-template допускает до 8 API, hold valid/obsolete=1s. Обновление IP реально проверяется поочерёдной заменой контейнеров с новыми ID/IP, новые hostname должны появиться через LB до остановки старого API.
|
||||
|
||||
Uvicorn при SIGTERM прекращает приём, ждёт выполняющиеся запросы до 8 секунд, затем закрывает пул. Compose stop_grace_period=12s. HAProxy: connect=1s, server=10s, client=15s, автоматические retry отключены. Краткие ошибки при обнаружении отказа измеряются; клиент повторяет неопределённый POST сообщения с прежним ключом. Создание чата/пользователя не получает прозрачных retry. stop-one.sh использует сокращённый бюджет 3 секунды, оставляя выбранный контейнер остановленным.
|
||||
|
||||
## Согласованные миграции и идемпотентность
|
||||
|
||||
Мигратор — отдельный one-shot service, API запускаются после его успеха и сами DDL не выполняют. Advisory lock сериализует миграторов; schema_migrations и SQL-версия фиксируются в той же транзакции. Повторный запуск процесса мигратора пропускает применённые версии. Миграция 002 добавляет таблицу/индекс, совместима с работающей схемой lab2; старое приложение, однако, ещё не предоставляет новый контракт идемпотентности.
|
||||
|
||||
Область ключа: sender_id + фиксированный POST/маршрут + канонический UUID чата + Idempotency-Key. ASCII-шаблон и длина проверяются. Advisory lock хэша области сериализует конкурирующие повторы между всеми API. Под блокировкой читается результат либо сообщение и JSON ответа записываются одной транзакцией. Побочный эффект и результат атомарны. Прежний body возвращает тот же Message и 201; иной body — 409. Ошибка/rollback не фиксируется. Сессия и членство проверяются заново перед replay.
|
||||
|
||||
JSON-порядок не влияет на сравнение, отсутствующий attachment_ids и [] равны. Текст не trim-ится, разные пробелы — разные body. Непустые вложения не входят в lab3. TTL результата — 24 часа с первой записи; истёкший ключ удаляется при следующем обращении к нему. Фоновая очистка не реализована: неиспользуемые истёкшие результаты занимают диск. Таймаут блокировки может дать временную 503, повтор с прежним ключом безопасен.
|
||||
|
||||
## Лимиты и область общего состояния
|
||||
|
||||
Обычный стенд: API по 2 CPU/256 MiB (лимит выбран с запасом для Argon2id и фиксированного 2s timeout публичного resilience-теста), PostgreSQL 1 CPU/512 MiB, Valkey 0.25 CPU/128 MiB, LB 0.25 CPU/64 MiB. CPU-лимиты являются верхними границами, не резервированием: сумма возможных квот превышает 4 vCPU VM, одновременная насыщенная работа всех компонентов не обещается. Пул API max_size=5, min_size=1; две реплики дают до 10 подключений, четыре — до 20 при обычном max_connections=100 PostgreSQL. Лимиты и отсутствие опубликованных API-портов подтверждены в evidence/final-containers.json. container_name в compose.yaml отсутствует.
|
||||
|
||||
API_IMAGE/API_REPLICAS/API_CPUS/API_MEMORY/DB_POOL_MAX_SIZE/DB_CPUS/LB_CPUS/CACHE_CLIENT_MODE соответствуют реальным параметрам Compose. Значения .env.example — рабочие defaults; экспериментальные ограничения передаются временно через environment. В исследовании БД намеренно ограничивается до 0.25 CPU, обычный стенд после эксперимента возвращается к 1 CPU.
|
||||
|
||||
## Rolling update под нагрузкой
|
||||
|
||||
```sh
|
||||
# Сначала подготовить новый образ, старый продолжает работать:
|
||||
API_IMAGE=mtusi-lab3-api:final-v5 ./scripts/compose.sh build --build-arg APP_REVISION=lab3-v5 api
|
||||
API_IMAGE=mtusi-lab3-api:final-v5 make test-rolling
|
||||
# Чтобы последующий обычный up использовал этот tag, записать API_IMAGE в .env.
|
||||
```
|
||||
|
||||
scripts/rolling_update.py работает с одной временной дополнительной репликой (surge=1): создаёт её выбранным образом без пересоздания работающих API, ждёт Docker health (probe на socket, бюджет 4s) и фактический hostname за LB, останавливает/удаляет одну старую реплику. Повторяет для каждой исходной. При ошибке готовности старую реплику не удаляет, оставляет состояние для диагностики. Число экземпляров в ходе нормального обновления — 2→3→2→3→2.
|
||||
|
||||
Проверяется смена реальных image IDs и удаление всех исходных container IDs. Новый образ имеет новую сборочную ревизию, API-контракт тот же, SQL-изменений в этом rollout нет. Миграции в ходе rolling не запускаются (--no-deps). Для будущих несовместимых SQL-изменений такой скрипт сам по себе недостаточен: нужен совместимый expand/migrate/contract либо остановка сервиса. Автоматический rollback не реализован.
|
||||
|
||||
Четыре клиентских потока одновременно пишут и читают через LB, повторяют неопределённые сообщения с прежними ключами. После обновления проверяется вся история, подтверждённые сообщения и отсутствие дублей. Реальные показатели — evidence/rolling-load.json, смена контейнеров/образов — evidence/rolling-containers.json.
|
||||
|
||||
## Доказательства
|
||||
|
||||
| Критерий | Команда | Доказательство |
|
||||
| --- | --- | --- |
|
||||
| Структура и схема | make check; make validate | evidence/check.txt; evidence/validate.txt |
|
||||
| Публичный API | make test | evidence/smoke.txt |
|
||||
| Общая сессия и ≥2 настоящих API | make test-idempotency | evidence/idempotency.txt; evidence/final-containers.json |
|
||||
| 16 конкурентных повторов через разные API | make test-idempotency | 1 сообщение; 409 при ином body; semantic replay; независимость пользователей |
|
||||
| Отказ с безопасным повтором | make test-failover ACTION_SCRIPT=scripts/stop-one.sh | evidence/failover.txt; evidence/after-public-failover.txt |
|
||||
| Отказ каждой реплики с восстановлением предыдущей | make test-replicas | evidence/replica-matrix.json: RPS, ошибки, восстановление и состояния контейнеров |
|
||||
| Сохранность после рестарта API и хранилищ | make test-persistence ACTION_SCRIPT=scripts/restart.sh | evidence/persistence.txt; evidence/before-persistence.txt; evidence/after-persistence.txt |
|
||||
| Сохранение правил кэша lab2 после оптимизации | make test-cache | evidence/cache-consistency.txt |
|
||||
| Readiness, timeouts, DNS, SIGTERM | конфигурация + отказ/rolling | infra/haproxy.cfg; compose.yaml; evidence/rolling-containers.json |
|
||||
| Лимиты, приватные API, отсутствие container_name | config/inspect | compose.yaml; evidence/final-containers.json |
|
||||
| Замена контейнеров новым образом под нагрузкой | API_IMAGE=… make test-rolling | evidence/rolling-load.json; evidence/rolling-containers.json |
|
||||
| Однократные согласованные версии миграций | migrate.py, schema_migrations | migrations/; evidence/migrations.txt |
|
||||
|
||||
### Фактические результаты проверок
|
||||
|
||||
Публичный smoke, OpenAPI и регрессии кэша — PASS. Конкурентная проверка: 16 запросов с одним ключом через два API, одно сообщение в истории, конфликтующий body — 409. Защита от подмены идентичности кэша проверена восемью параллельными чтениями; повреждённый кэш, восстановление после cache miss и повторное заполнение после logout не дают чужую/отозванную сессию.
|
||||
|
||||
Публичный failover обычного стенда: 65 успешных записей, 3 неудачные попытки, восстановление 3.042s. Скрипт действительно оставил один API остановленным; snapshot сохранён до его восстановления. Повтор с прежним ключом не создал дублей.
|
||||
|
||||
| Отказ API | Успешных пар POST+GET | Неудачных попыток | Успешных пар/с | Восстановление, с |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 228d36b4417c | 77 | 6 | 4.806 | 3.072 |
|
||||
| e0560ed00847 | 84 | 5 | 5.404 | 2.666 |
|
||||
|
||||
Полный restart — PASS: прежний токен прочитал прежние подтверждённые сообщения. У пяти контейнеров API×2/DB/Valkey/LB изменился StartedAt при сохранении ID и volumes. Финальная конфигурация содержит две healthy API с лимитом 2 CPU/256 MiB каждая; опубликован только LB:8083.
|
||||
|
||||
Зафиксированный rolling при четырёх клиентских потоках (API по 1 CPU, более тесный бюджет, чем обычные 2 CPU): 902 успешные пары, 56 неудачных попыток за 34.87s; 25.868 успешных пар/с. p50/p95/p99 успешной пары: 16.886 / 461.635 / 877.331 мс. Все исходные container IDs удалены, image IDs изменились, подтверждения сохранены, дублей 0. После выбора окончательного обычного CPU-лимита повторены smoke, идемпотентность, публичный failover, матрица каждого отказа и persistence.
|
||||
|
||||
Ошибки переходного периода измерены и не скрываются: LB исключает backend после обнаружения отказа, разрыв выполняющегося запроса возможен. Это локальная проверка под нагрузкой, не zero-downtime SLA. RPS матрицы/rolling считается по успешным парам POST+GET и фактическому времени сценария, включая финальную проверку истории; эти клиенты работают с хоста. Их значения не следует напрямую сравнивать с RPS одних POST генератора внутри Docker-сети.
|
||||
|
||||
## Уровень 5, трек 1
|
||||
|
||||
Законченная методика, гипотезы, таблицы и ограничения находятся в [RESEARCH.md](RESEARCH.md). Выполнены 42 запуска: 18 для сравнения 1/2/4 API, 18 для насыщения/CPU БД, 6 для улучшения пула Valkey. Каждый — 2 секунды прогрева и 10 секунд измерения, три повтора каждой конфигурации. Генератор работает в Docker-сети через LB. Сырые latencies/ошибки, CPU/RAM, лимиты, SHA образов, счётчики БД/Valkey и manifest параметров сохранены в evidence/scaling/.
|
||||
|
||||
При фиксированном API-бюджете 1 CPU/1024 MiB средний throughput для 1/2/4 реплик составил 639.5 / 470.3 / 349.8 POST/с. При растущем бюджете (каждой API 0.5 CPU/256 MiB) — 499.7 / 460.8 / 429.9 POST/с. Рост реплик сам по себе не дал улучшения. В серии growing БД занимала полную квоту 0.25 CPU; изменение только БД до 1 CPU подняло throughput при четырёх API с 448.3 до 952.9 POST/с в отдельной серии saturation. Наблюдаемая область насыщения исходной конфигурации — около 400–500 POST/с при c≈16; c=64 увеличило p95 до 425.2 мс без прироста throughput.
|
||||
|
||||
Подтверждённое изменение кода: общий пул Valkey вместо клиента на каждый запрос. При одинаковых ресурсах среднее число новых соединений сократилось с 5422.7 до 2.3 за запуск; throughput вырос с 445.0 до 584.0 POST/с (+31.3%), p95 снизился с 124.1 до 82.5 мс. Разброс исходного варианта большой, интервалы min–max перекрываются: этот прирост не является универсальной гарантией. Сокращение churn соединений подтверждено непосредственно счётчиком Valkey.
|
||||
|
||||
Графики: [scaling.png](evidence/scaling/scaling.png), [saturation.png](evidence/scaling/saturation.png), [cache-improvement.png](evidence/scaling/cache-improvement.png). Рядом находятся SVG, summary.csv, summary.json и исходные JSON каждого повтора. Скрипты research_scaling.py, benchmark.py, plot_scaling.py и summarize_research.py воспроизводят результаты и представление.
|
||||
|
||||
## Ограничения
|
||||
|
||||
Защищён отказ одного процесса API. LB, БД и Docker host не реплицированы; потеря узла или volumes не покрывается. Volume не является backup. Три коротких повтора в VM, синхронные SQL-операции в async-обработчиках, растущая БД и closed-loop генератор ограничивают выводы. Не заявляются универсальная производительность, выживание узла БД, доказанное исчерпание RAM, полноценный production deployment или точная локализация следующего bottleneck после увеличения CPU БД. Подробности — RESEARCH.md.
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
# Уровень 5, трек 1: цена масштабирования
|
||||
|
||||
## Гипотезы
|
||||
|
||||
1. При фиксированном общем CPU/RAM увеличение числа API само по себе не увеличивает пропускную способность: уменьшается ресурс одного процесса, добавляются healthchecks и соединения к зависимостям.
|
||||
2. При росте ресурсов API эффект ограничивается общей БД. Если причина — CPU-квота PostgreSQL, то дальнейшее увеличение конкурентности повысит задержки, а увеличение CPU БД при неизменных API повысит throughput.
|
||||
3. Общий клиент Valkey с пулом соединений уменьшит количество новых соединений и накладные расходы по сравнению с созданием клиента на каждый запрос. Авторитетная проверка сессии в PostgreSQL остаётся одинаковой.
|
||||
|
||||
## Среда и методика
|
||||
|
||||
macOS/arm64, Colima: Linux aarch64, Docker Engine 27.4.0, Compose 2.34.0, 4 vCPU, 8 308 158 464 байт RAM. Характеристики VM сохранены в evidence/research-environment.json. Установленные лимиты каждого контейнера и SHA образов находятся в каждом сыром JSON. Стенд lab2 продолжал существовать, но запросы к нему во время исследования не посылались. Это локальная VM, а не выделенный production-сервер.
|
||||
|
||||
Генератор scripts/benchmark.py работает в отдельном контейнере Compose-сети: load → HAProxy → API → PostgreSQL/Valkey. Он использует persistent HTTPConnection, по одному соединению на поток. Основная серия: 16 конкурентных клиентов, warmup 2 секунды, измерение 10 секунд, три повтора. Каждый POST отправляет одинаковую по структуре небольшую строку с уникальным ключом, проверяет HTTP 201, chat_id и точный текст ответа. Чат отдельный для каждого запуска, токены живут только в памяти. Неподтверждённые запросы здесь не повторяются; считаются HTTP-подтверждения, ошибки/timeout сохранены отдельно.
|
||||
|
||||
Запросы, начатые после warmup и до конца измерительного окна, дожидаются завершения. RPS = число подтверждений / фактическое время от начала окна до завершения последнего запроса, включая drain. Задержки каждого запроса, код и тип ошибки находятся в samples_ms_status_error. p50/p95/p99 относятся только к успешным запросам. Генератор closed-loop, поэтому имеет coordinated omission; это сравнение конкретных конфигураций, не измерение предельной open-loop мощности.
|
||||
|
||||
В серии fixed суммарный бюджет API всегда **1 CPU / 1024 MiB**: 1×(1 CPU/1024 MiB), 2×(0.5 CPU/512 MiB), 4×(0.25 CPU/256 MiB). В серии growing каждая реплика получает **0.5 CPU / 256 MiB**, общий бюджет растёт до 2 CPU / 1024 MiB. В обеих сериях PostgreSQL фиксирован на 0.25 CPU/512 MiB, LB на 0.25 CPU/64 MiB, Valkey на 0.25 CPU/128 MiB. Таким образом, fixed сохраняет и общий бюджет серверной части стенда.
|
||||
|
||||
Квота БД 0.25 CPU выбрана явно, чтобы получить повторяемое ограничение общей зависимости в небольшой VM. Это не утверждение, что реальный PostgreSQL всегда насыщается при таком RPS. Пул API max_size=5, min_size=1 на процесс; новый SQL/кэш-алгоритм одинаков в обеих сериях.
|
||||
|
||||
Порядок конфигураций случайно перемешивается в каждом повторе с seed=20261030+номер повтора. История растёт на протяжении эксперимента, volumes не очищаются: это ограничение контроля данных. POST не читает историю целиком, но размер индексов и состояние буферов могут влиять на результат. Снимки pg_stat_database и Valkey INFO до/после сохраняются, включая commits, tuple inserts, cache commands и новые соединения. Эти интервалы включают bootstrap и warmup, в отличие от основного RPS.
|
||||
|
||||
Docker stats собирается примерно раз в две секунды: CPU%, память/лимит, сетевой и блочный I/O. CPU%=100 соответствует одному занятому логическому CPU; при лимите БД 0.25 CPU насыщение означает около 25%, а не 100%. Для расчёта среднего CPU используются временные метки внутри измерительного окна. В первой серии из-за управляющего префикса CLI отсутствуют samples первого контейнера в каждом пакете; это не затрагивает RPS/latencies или приведённые значения DB/LB/client CPU. Сборщик исправлен для следующих серий. Полный набор per-container CPU первой серии не используется для вывода о насыщении API.
|
||||
|
||||
Во всех записанных нагрузочных сериях использовался прежний Docker-healthcheck на urllib. После исследования rolling-проверка выявила излишнюю стоимость холодного импорта urllib; обычный стенд теперь использует лёгкий socket HTTP-probe. Docker timeout обычного probe увеличен до 4 секунд, чтобы учитывать запуск вспомогательного процесса; собственный socket timeout и HTTP-проверка HAProxy остаются 1 секунда. Для точного воспроизведения условий исследовательский runner автоматически подключает compose.research.yaml со старым probe; эта конфигурация не применяется к обычному запуску и rolling update.
|
||||
|
||||
Серия saturation сохраняет четыре API по 0.5 CPU/256 MiB и БД 0.25 CPU, сравнивает concurrency 1/4/16/64. Затем при concurrency=16 меняется только CPU БД на 0.5 и 1. Это вмешательство проверяет предполагаемое ограничение. Отдельная серия cache сравнивает per_request/shared на двух API по 0.5 CPU/256 MiB с БД 1 CPU; меняется только способ владения клиентом Valkey.
|
||||
|
||||
## Повтор эксперимента
|
||||
|
||||
```sh
|
||||
./scripts/bootstrap.sh
|
||||
./scripts/compose.sh up -d --build
|
||||
export BASE_URL=http://localhost:8083 # либо свой опубликованный порт
|
||||
python3 scripts/research_scaling.py --suite scaling --duration 10 --warmup 2 --repeats 3
|
||||
python3 scripts/research_scaling.py --suite saturation --duration 10 --warmup 2 --repeats 3
|
||||
python3 scripts/research_scaling.py --suite improvement --duration 10 --warmup 2 --repeats 3
|
||||
python3 -m venv .venv
|
||||
.venv/bin/python -m pip install -r requirements-research.txt
|
||||
.venv/bin/python scripts/plot_scaling.py
|
||||
python3 scripts/summarize_research.py
|
||||
```
|
||||
|
||||
Сценарий меняет только текущий Compose-проект. Между конфигурациями он дожидается здоровых API и наблюдения ровно нужных hostname через LB. В finally восстанавливаются обычные две реплики, DB=1 CPU, API по 2 CPU/256 MiB, shared-клиент (если параметры .env не переопределены оператором). Volumes не удаляются. Точные параметры серий и список файлов записаны в manifest-*.json.
|
||||
|
||||
Сводные CSV/JSON и PNG/SVG строятся из исходных данных; графики показывают средние RPS и выборочное стандартное отклонение, а p95 — среднее p95 отдельных запусков, не объединённый percentile. Все исходные JSON сохранены в evidence/scaling/.
|
||||
|
||||
## Результаты
|
||||
|
||||
Каждая строка — три повтора. Ошибки во всех 42 запусках отсутствовали. RPS±s — среднее и выборочное стандартное отклонение.
|
||||
|
||||
| Серия | Реплик | RPS ± s | min–max RPS | p50 / p95 / p99, мс | CPU БД, % одного CPU |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| fixed | 1 | 639.5 ± 8.2 | 631.5–648.0 | 21.8 / 36.5 / 64.2 | 24.94 |
|
||||
| fixed | 2 | 470.2 ± 60.7 | 401.1–515.0 | 18.0 / 80.2 / 164.3 | 24.46 |
|
||||
| fixed | 4 | 349.8 ± 49.6 | 318.1–407.1 | 8.4 / 177.2 / 311.4 | 19.43 |
|
||||
| growing | 1 | 499.7 ± 15.4 | 482.2–511.1 | 22.2 / 83.5 / 99.4 | 19.89 |
|
||||
| growing | 2 | 460.8 ± 60.4 | 399.4–520.2 | 18.7 / 91.0 / 184.3 | 24.28 |
|
||||
| growing | 4 | 429.9 ± 75.4 | 343.1–478.9 | 10.3 / 117.1 / 268.3 | 25.23 |
|
||||
|
||||

|
||||
|
||||
При фиксированном бюджете 1→4 реплики снизили throughput, а p95 вырос. Это опровергает ожидание «реплик больше — всегда быстрее». Разделение бюджета между процессами, независимые пулы/healthchecks, синхронный I/O и планирование дробных CPU-квот могут менять эффективность. Вклад каждого фактора здесь отдельно не измерялся, поэтому конкретная причина всей деградации fixed не доказана. При росте бюджета переход 2→4 также не дал устойчивого выигрыша: БД работала около своей полной квоты.
|
||||
|
||||
### Насыщение и вмешательство в ресурс БД
|
||||
|
||||
| Конфигурация: 4 API × 0.5 CPU | RPS ± s | p95, мс | CPU БД, % одного CPU | CPU LB / клиента, % |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| saturation-c1 | 335.5 ± 63.0 | 4.6 | 19.87 | 2.83 / 3.70 |
|
||||
| saturation-c4 | 353.6 ± 117.5 | 73.1 | 24.25 | 3.21 / 5.00 |
|
||||
| saturation-c16 | 448.3 ± 38.2 | 105.9 | 25.29 | 3.75 / 5.86 |
|
||||
| saturation-c64 | 388.6 ± 72.1 | 425.2 | 25.40 | 3.70 / 5.92 |
|
||||
| db-0.5 | 836.5 ± 33.9 | 62.3 | 44.41 | 6.77 / 10.39 |
|
||||
| db-1 | 952.9 ± 81.2 | 59.4 | 51.53 | 7.60 / 12.26 |
|
||||
|
||||
При c=4 БД уже близка к квоте 25%; максимум среднего throughput среди исследованных c находится при c=16 (448.3 POST/с). Рост c до 64 не дал прироста, p95 вырос до 425.2 мс. Это эмпирическая область насыщения около 400–500 POST/с для данной конфигурации, не точная универсальная граница. При увеличении квоты только БД до 1 CPU средний throughput вырос в 2.13 раза, до 952.9 POST/с. Это подтверждает ограничение общей зависимости в исходном стенде.
|
||||
|
||||
LB и генератор существенно ниже своих CPU-лимитов 25% и 100% соответственно; их CPU не объясняет исходное плато. При DB=1 CPU сама БД уже не достигает квоты; ограничение сдвигается. Точное новое узкое место (Python/I/O/планировщик/пул) этим экспериментом не локализовано. Один процесс API выполняет синхронные операции БД в async-обработчике, поэтому добавление размера пула не гарантирует параллелизм. Не заявляется, что достигнута предельная мощность PostgreSQL или устранены все bottleneck.
|
||||
|
||||

|
||||
|
||||
### Подтверждённое улучшение: переиспользование соединений Valkey
|
||||
|
||||
Объект Redis теперь создаётся один раз на Store/процесс и использует библиотечный connection pool; закрывается при shutdown. Для контрольного эксперимента CACHE_CLIENT_MODE=per_request воспроизводит прежнее создание клиента на каждую операцию. По умолчанию выбран shared. Проверка идентичности/expiry/revocation в PostgreSQL не меняется.
|
||||
|
||||
| Вариант | RPS ± s | min–max RPS | p95, мс | Новых соединений Valkey за весь запуск, среднее |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| cache-per_request | 445.0 ± 104.8 | 347.5–555.9 | 124.1 | 5422.667 |
|
||||
| cache-shared | 584.0 ± 36.2 | 543.5–612.8 | 82.5 | 2.333 |
|
||||
|
||||
В этих трёх повторах средний throughput вырос на 31.3%, средний p95 снизился на 33.5%. Число новых соединений снизилось на 99.957%. Интервалы min–max throughput перекрываются, статистическая значимость не проверялась; гарантировать прирост 31% для иной нагрузки нельзя. Устойчиво подтверждено устранение почти всех повторных подключений.
|
||||
|
||||

|
||||
|
||||
## Ограничения и практический вывод
|
||||
|
||||
Три коротких повтора по десять секунд, короткий прогрев, растущие данные и VM дают заметный разброс. Не контролировались page cache, фазы CFS-квот, частота CPU и фоновая активность ОС. Стандартное отклонение не является доверительным интервалом. Измеряется одна короткая POST-нагрузка с действующими сессиями, а не смесь логинов, чтения больших историй и файлов. Нет open-loop arrival rate, длинного soak-теста, статистического теста значимости или доказательства исчерпания RAM. Raw summaries содержат memory usage/limits, а не профили heap.
|
||||
|
||||
До увеличения числа API нужно измерять общую зависимость: в этом стенде DB CPU объясняет плато growing, а дробление фиксированного CPU не помогает. Подтверждены два практических эффекта: снятие искусственно тесной квоты БД увеличивает пропускную способность; общий пул Valkey устраняет churn соединений и улучшает средние показатели этого профиля. При этом в обычной конфигурации сохранены две API для отказоустойчивости процесса, а не выбрана единственная реплика ради лучшего числа в fixed-серии.
|
||||
@@ -0,0 +1,861 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import secrets
|
||||
import socket
|
||||
import re
|
||||
import uuid
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import psycopg
|
||||
from psycopg_pool import ConnectionPool
|
||||
import redis
|
||||
from argon2 import PasswordHasher
|
||||
from fastapi import FastAPI, Header, HTTPException, Request
|
||||
from fastapi.exceptions import RequestValidationError
|
||||
from fastapi.responses import JSONResponse, Response
|
||||
from pydantic import BaseModel, ConfigDict, StringConstraints, ValidationError
|
||||
from typing_extensions import Annotated
|
||||
|
||||
|
||||
APP_HOST = os.getenv("APP_HOST", "0.0.0.0")
|
||||
APP_PORT = int(os.getenv("APP_PORT", "8080"))
|
||||
SESSION_TTL_SECONDS = int(os.getenv("SESSION_TTL_SECONDS", "3600"))
|
||||
INSTANCE_ID = os.getenv("INSTANCE_ID", socket.gethostname())
|
||||
|
||||
USERNAME_RE = r"^[a-z0-9_]{3,32}$"
|
||||
|
||||
|
||||
class ApiError(Exception):
|
||||
def __init__(self, status_code: int, code: str, message: str, *, headers: Optional[Dict[str, str]] = None):
|
||||
self.status_code = status_code
|
||||
self.code = code
|
||||
self.message = message
|
||||
self.headers = headers or {}
|
||||
|
||||
|
||||
class UserOut(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
id: str
|
||||
username: str
|
||||
display_name: str
|
||||
created_at: str
|
||||
|
||||
|
||||
class SessionOut(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
token: str
|
||||
token_type: str
|
||||
expires_at: str
|
||||
user: UserOut
|
||||
|
||||
|
||||
class ChatOut(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
id: str
|
||||
title: str
|
||||
member_ids: List[str]
|
||||
created_at: str
|
||||
|
||||
|
||||
class MessageOut(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
id: str
|
||||
chat_id: str
|
||||
sender_id: str
|
||||
text: str
|
||||
created_at: str
|
||||
|
||||
|
||||
class CreateUserIn(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
username: Annotated[str, StringConstraints(pattern=USERNAME_RE, min_length=3, max_length=32)]
|
||||
display_name: Annotated[str, StringConstraints(min_length=1, max_length=100)]
|
||||
password: Annotated[str, StringConstraints(min_length=12, max_length=128)]
|
||||
|
||||
|
||||
class CreateChatIn(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
title: Annotated[str, StringConstraints(min_length=1, max_length=100)]
|
||||
member_ids: List[str]
|
||||
|
||||
|
||||
class CreateMessageIn(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
attachment_ids: List[str] = []
|
||||
text: Annotated[str, StringConstraints(min_length=1, max_length=4000)]
|
||||
|
||||
|
||||
class Store:
|
||||
def __init__(self) -> None:
|
||||
self.connection_url = self._resolve_database_url()
|
||||
self.cache_url = self._resolve_cache_url()
|
||||
self.shared_cache = redis.Redis.from_url(self.cache_url, decode_responses=True, socket_connect_timeout=2, socket_timeout=2)
|
||||
self.session_store = os.getenv("SESSION_STORE", "valkey")
|
||||
self.password_hasher = PasswordHasher(time_cost=3, memory_cost=65536, parallelism=2, hash_len=32, salt_len=16)
|
||||
self.pool = ConnectionPool(
|
||||
self.connection_url, min_size=1,
|
||||
max_size=int(os.getenv("DB_POOL_MAX_SIZE", "10")),
|
||||
timeout=5, max_waiting=20, open=False,
|
||||
kwargs={"connect_timeout": 5, "autocommit": False,
|
||||
"options": "-c statement_timeout=5000 -c lock_timeout=500"},
|
||||
)
|
||||
|
||||
def _resolve_database_url(self) -> str:
|
||||
value = os.getenv("DATABASE_URL")
|
||||
if value:
|
||||
return value
|
||||
secret_path = os.getenv("DATABASE_URL_FILE")
|
||||
if secret_path and os.path.exists(secret_path):
|
||||
with open(secret_path, "r", encoding="utf-8") as handle:
|
||||
return handle.read().strip()
|
||||
return os.getenv("DEFAULT_DATABASE_URL", "postgresql://messenger:messenger@localhost:5432/messenger")
|
||||
|
||||
def _resolve_cache_url(self) -> str:
|
||||
value = os.getenv("CACHE_URL")
|
||||
if value:
|
||||
return value
|
||||
secret_path = os.getenv("CACHE_URL_FILE")
|
||||
if secret_path and os.path.exists(secret_path):
|
||||
with open(secret_path, "r", encoding="utf-8") as handle:
|
||||
return handle.read().strip()
|
||||
return os.getenv("DEFAULT_CACHE_URL", "redis://localhost:6379/0")
|
||||
|
||||
def connect(self):
|
||||
return self.pool.connection()
|
||||
|
||||
def cache_client(self):
|
||||
if os.getenv("CACHE_CLIENT_MODE", "shared") == "shared":
|
||||
return self.shared_cache
|
||||
return redis.Redis.from_url(self.cache_url, decode_responses=True, socket_connect_timeout=2, socket_timeout=2)
|
||||
|
||||
def cache_session(self, session: Dict[str, Any]) -> None:
|
||||
if self.session_store != "valkey":
|
||||
return
|
||||
try:
|
||||
client = self.cache_client()
|
||||
ttl_seconds = max(1, int((self.parse_session_expiry(session["expires_at"]) - self.utc_now()).total_seconds()))
|
||||
payload = json.dumps({
|
||||
"token": session["token"],
|
||||
"user_id": session["user_id"],
|
||||
"expires_at": session["expires_at"],
|
||||
"revoked_at": session.get("revoked_at"),
|
||||
"user": session["user"],
|
||||
}, separators=(",", ":"), ensure_ascii=False)
|
||||
client.setex(f"session:{session['token']}", ttl_seconds, payload)
|
||||
except redis.RedisError:
|
||||
return
|
||||
|
||||
def get_cached_session(self, token: str, *, db_session) -> Optional[Dict[str, Any]]:
|
||||
if self.session_store != "valkey":
|
||||
return None
|
||||
try:
|
||||
client = self.cache_client()
|
||||
payload = client.get(f"session:{token}")
|
||||
if not payload:
|
||||
return None
|
||||
data = json.loads(payload)
|
||||
session = {
|
||||
"token": data["token"],
|
||||
"user_id": data["user_id"],
|
||||
"expires_at": data["expires_at"],
|
||||
"revoked_at": data.get("revoked_at"),
|
||||
"user": data["user"],
|
||||
}
|
||||
if not self.is_session_valid(session):
|
||||
client.delete(f"session:{token}")
|
||||
return None
|
||||
if session != db_session:
|
||||
client.delete(f"session:{token}")
|
||||
return None
|
||||
return db_session
|
||||
except (redis.RedisError, KeyError, TypeError, ValueError):
|
||||
return None
|
||||
|
||||
def delete_cached_session(self, token: str) -> None:
|
||||
if self.session_store != "valkey":
|
||||
return
|
||||
try:
|
||||
self.cache_client().delete(f"session:{token}")
|
||||
except redis.RedisError:
|
||||
return
|
||||
|
||||
@staticmethod
|
||||
def parse_session_expiry(value: Any) -> datetime:
|
||||
if isinstance(value, datetime):
|
||||
return value.astimezone(timezone.utc)
|
||||
if isinstance(value, str):
|
||||
return datetime.fromisoformat(value.replace("Z", "+00:00")).astimezone(timezone.utc)
|
||||
raise ValueError("invalid session expiry")
|
||||
|
||||
def init(self) -> None:
|
||||
migration_dir = Path(__file__).resolve().parent / "migrations"
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT pg_advisory_xact_lock(202603)")
|
||||
cur.execute(
|
||||
"""
|
||||
CREATE TABLE IF NOT EXISTS schema_migrations (
|
||||
version TEXT PRIMARY KEY,
|
||||
applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
||||
applied = set()
|
||||
cur.execute("SELECT version FROM schema_migrations")
|
||||
for (version,) in cur.fetchall():
|
||||
applied.add(version)
|
||||
|
||||
for migration_path in sorted(migration_dir.glob("*.sql")):
|
||||
version = migration_path.stem
|
||||
if version in applied:
|
||||
continue
|
||||
sql = migration_path.read_text(encoding="utf-8")
|
||||
cur.execute(sql)
|
||||
cur.execute(
|
||||
"INSERT INTO schema_migrations(version, applied_at) VALUES (%s, %s)",
|
||||
(version, self.utc_now()),
|
||||
)
|
||||
conn.commit()
|
||||
|
||||
def utc_now(self) -> datetime:
|
||||
return datetime.now(timezone.utc)
|
||||
|
||||
def isoformat_utc(self, value: datetime) -> str:
|
||||
return value.astimezone(timezone.utc).isoformat(timespec="microseconds").replace("+00:00", "Z")
|
||||
|
||||
def hash_password(self, password: str) -> str:
|
||||
return self.password_hasher.hash(password)
|
||||
|
||||
def verify_password(self, password_hash: str, password: str) -> bool:
|
||||
try:
|
||||
self.password_hasher.verify(password_hash, password)
|
||||
return True
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def require_user_by_username(self, username: str, conn):
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT id, username, display_name, created_at, password_hash FROM users WHERE username = %s", (username,))
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return {
|
||||
"id": str(row[0]),
|
||||
"username": row[1],
|
||||
"display_name": row[2],
|
||||
"created_at": self.isoformat_utc(row[3]),
|
||||
"password_hash": row[4],
|
||||
}
|
||||
|
||||
def fetch_user(self, user_id: str, conn):
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT id, username, display_name, created_at FROM users WHERE id = %s", (user_id,))
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return {
|
||||
"id": str(row[0]),
|
||||
"username": row[1],
|
||||
"display_name": row[2],
|
||||
"created_at": self.isoformat_utc(row[3]),
|
||||
}
|
||||
|
||||
def fetch_session_by_token(self, token: str, conn):
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"SELECT s.token, s.user_id, s.expires_at, s.revoked_at, u.id, u.username, u.display_name, u.created_at FROM sessions s JOIN users u ON u.id = s.user_id WHERE s.token = %s",
|
||||
(token,),
|
||||
)
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return {
|
||||
"token": row[0],
|
||||
"user_id": str(row[1]),
|
||||
"expires_at": self.isoformat_utc(row[2]),
|
||||
"revoked_at": row[3],
|
||||
"user": {
|
||||
"id": str(row[4]),
|
||||
"username": row[5],
|
||||
"display_name": row[6],
|
||||
"created_at": self.isoformat_utc(row[7]),
|
||||
},
|
||||
}
|
||||
|
||||
def list_member_ids(self, chat_id: str, conn) -> List[str]:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT user_id FROM chat_members WHERE chat_id = %s ORDER BY user_id", (chat_id,))
|
||||
rows = cur.fetchall()
|
||||
return [str(row[0]) for row in rows]
|
||||
|
||||
def fetch_chat(self, chat_id: str, conn):
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT id, title, created_at FROM chats WHERE id = %s", (chat_id,))
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return {
|
||||
"id": str(row[0]),
|
||||
"title": row[1],
|
||||
"created_at": self.isoformat_utc(row[2]),
|
||||
"member_ids": self.list_member_ids(str(row[0]), conn),
|
||||
}
|
||||
|
||||
def fetch_message(self, message_id: str, conn):
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE id = %s", (message_id,))
|
||||
row = cur.fetchone()
|
||||
if row is None:
|
||||
return None
|
||||
return {
|
||||
"id": str(row[0]),
|
||||
"chat_id": str(row[1]),
|
||||
"sender_id": str(row[2]),
|
||||
"text": row[3],
|
||||
"created_at": self.isoformat_utc(row[4]),
|
||||
}
|
||||
|
||||
def fetch_chat_membership(self, chat_id: str, user_id: str, conn) -> bool:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT 1 FROM chat_members WHERE chat_id = %s AND user_id = %s", (chat_id, user_id))
|
||||
return cur.fetchone() is not None
|
||||
|
||||
def insert_user(self, username: str, display_name: str, password: str):
|
||||
now = self.utc_now()
|
||||
user_id = uuid.uuid4()
|
||||
password_hash = self.hash_password(password)
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"INSERT INTO users(id, username, display_name, password_hash, created_at) VALUES (%s,%s,%s,%s,%s)",
|
||||
(user_id, username, display_name, password_hash, now),
|
||||
)
|
||||
conn.commit()
|
||||
return {
|
||||
"id": str(user_id),
|
||||
"username": username,
|
||||
"display_name": display_name,
|
||||
"created_at": self.isoformat_utc(now),
|
||||
}
|
||||
|
||||
def insert_chat(self, title: str, member_ids: List[str], actor_id: str):
|
||||
now = self.utc_now()
|
||||
chat_id = uuid.uuid4()
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("INSERT INTO chats(id,title,created_at) VALUES (%s,%s,%s)", (chat_id, title, now))
|
||||
for member_id in sorted(set(member_ids)):
|
||||
cur.execute("INSERT INTO chat_members(chat_id,user_id) VALUES (%s,%s)", (chat_id, member_id))
|
||||
conn.commit()
|
||||
return {
|
||||
"id": str(chat_id),
|
||||
"title": title,
|
||||
"member_ids": sorted(set(member_ids)),
|
||||
"created_at": self.isoformat_utc(now),
|
||||
}
|
||||
|
||||
def insert_message(self, chat_id: str, sender_id: str, text: str, key: str):
|
||||
# Transaction-level lock serializes the same scope across all replicas.
|
||||
scope = json.dumps([sender_id, "POST", chat_id, key])
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT pg_advisory_xact_lock(hashtextextended(%s, 0))", (scope,))
|
||||
cur.execute("DELETE FROM message_requests WHERE sender_id=%s AND chat_id=%s AND key=%s AND expires_at <= NOW()", (sender_id, chat_id, key))
|
||||
cur.execute("SELECT body, response FROM message_requests WHERE sender_id=%s AND chat_id=%s AND key=%s", (sender_id, chat_id, key))
|
||||
previous = cur.fetchone()
|
||||
if previous:
|
||||
if previous[0] != text:
|
||||
raise ApiError(409, "conflict", "idempotency key reused with different body")
|
||||
return previous[1]
|
||||
now = self.utc_now()
|
||||
message_id = str(uuid.uuid4())
|
||||
message = {"id": message_id, "chat_id": chat_id, "sender_id": sender_id,
|
||||
"text": text, "created_at": self.isoformat_utc(now)}
|
||||
cur.execute("INSERT INTO messages(id,chat_id,sender_id,text,created_at) VALUES (%s,%s,%s,%s,%s)",
|
||||
(message_id, chat_id, sender_id, text, now))
|
||||
cur.execute("INSERT INTO message_requests(sender_id,chat_id,key,body,response,expires_at) VALUES (%s,%s,%s,%s,%s::jsonb,%s)",
|
||||
(sender_id, chat_id, key, text, json.dumps(message), now + timedelta(hours=24)))
|
||||
conn.commit()
|
||||
return message
|
||||
|
||||
@staticmethod
|
||||
def cursor_uuid_key(value: str) -> int:
|
||||
try:
|
||||
return uuid.UUID(value).int
|
||||
except (ValueError, TypeError):
|
||||
return 0
|
||||
|
||||
def list_chats_for_user(self, user_id: str, limit: int, cursor: Optional[str]):
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
query = """
|
||||
SELECT c.id, c.title, c.created_at
|
||||
FROM chats c
|
||||
JOIN chat_members cm ON cm.chat_id = c.id
|
||||
WHERE cm.user_id = %s
|
||||
"""
|
||||
params: List[Any] = [user_id]
|
||||
if cursor:
|
||||
prefix = f"user:{user_id}|"
|
||||
if not cursor.startswith(prefix):
|
||||
raise ApiError(400, "invalid_request", "cursor does not match user chat list")
|
||||
remainder = cursor[len(prefix):]
|
||||
if not remainder:
|
||||
raise ApiError(400, "invalid_request", "invalid cursor")
|
||||
try:
|
||||
cursor_ts_raw, cursor_id = remainder.split("|", 1)
|
||||
cursor_dt = datetime.fromisoformat(cursor_ts_raw.replace("Z", "+00:00")).astimezone(timezone.utc)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid cursor") from exc
|
||||
query += " AND (c.created_at > %s OR (c.created_at = %s AND c.id > %s::uuid))"
|
||||
params.extend([cursor_dt, cursor_dt, cursor_id])
|
||||
query += " ORDER BY c.created_at ASC, c.id ASC LIMIT %s"
|
||||
params.append(limit + 1)
|
||||
cur.execute(query, tuple(params))
|
||||
rows = cur.fetchall()
|
||||
items = [
|
||||
{
|
||||
"id": str(row[0]),
|
||||
"title": row[1],
|
||||
"created_at": self.isoformat_utc(row[2]),
|
||||
"member_ids": self.list_member_ids(str(row[0]), conn),
|
||||
}
|
||||
for row in rows
|
||||
]
|
||||
|
||||
next_cursor = None
|
||||
if len(items) > limit:
|
||||
last_item = items[limit - 1]
|
||||
next_cursor = f"user:{user_id}|{last_item['created_at']}|{last_item['id']}"
|
||||
items = items[:limit]
|
||||
|
||||
return {"items": items, "next_cursor": next_cursor}
|
||||
|
||||
def list_messages_for_chat(self, chat_id: str, limit: int, cursor: Optional[str]):
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
query = "SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = %s"
|
||||
params: List[Any] = [chat_id]
|
||||
if cursor:
|
||||
prefix = f"chat:{chat_id}|"
|
||||
if not cursor.startswith(prefix):
|
||||
raise ApiError(400, "invalid_request", "cursor does not match chat")
|
||||
remainder = cursor[len(prefix):]
|
||||
if not remainder:
|
||||
raise ApiError(400, "invalid_request", "invalid cursor")
|
||||
try:
|
||||
cursor_ts_raw, cursor_id = remainder.split("|", 1)
|
||||
cursor_dt = datetime.fromisoformat(cursor_ts_raw.replace("Z", "+00:00")).astimezone(timezone.utc)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid cursor") from exc
|
||||
query += " AND (created_at, id) > (%s, %s::uuid)"
|
||||
params.extend([cursor_dt, cursor_id])
|
||||
query += " ORDER BY created_at ASC, id ASC LIMIT %s"
|
||||
params.append(limit + 1)
|
||||
cur.execute(query, tuple(params))
|
||||
rows = cur.fetchall()
|
||||
|
||||
items = [{
|
||||
"id": str(row[0]),
|
||||
"chat_id": str(row[1]),
|
||||
"sender_id": str(row[2]),
|
||||
"text": row[3],
|
||||
"created_at": self.isoformat_utc(row[4]),
|
||||
} for row in rows]
|
||||
|
||||
next_cursor = None
|
||||
if len(items) > limit:
|
||||
last_item = items[limit - 1]
|
||||
next_cursor = f"chat:{chat_id}|{last_item['created_at']}|{last_item['id']}"
|
||||
items = items[:limit]
|
||||
|
||||
return {"items": items, "next_cursor": next_cursor}
|
||||
|
||||
def create_session(self, user_id: str, username: str):
|
||||
token = secrets.token_urlsafe(32)
|
||||
expires_at = self.utc_now() + timedelta(seconds=SESSION_TTL_SECONDS)
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute(
|
||||
"INSERT INTO sessions(id, token, user_id, expires_at, created_at) VALUES (%s,%s,%s,%s,%s)",
|
||||
(uuid.uuid4(), token, user_id, expires_at, self.utc_now()),
|
||||
)
|
||||
conn.commit()
|
||||
with self.connect() as conn:
|
||||
user = self.fetch_user(user_id, conn)
|
||||
if user is None:
|
||||
raise ApiError(500, "internal_error", "session user missing")
|
||||
session = {
|
||||
"token": token,
|
||||
"user_id": user_id,
|
||||
"expires_at": self.isoformat_utc(expires_at),
|
||||
"revoked_at": None,
|
||||
"user": user,
|
||||
}
|
||||
self.cache_session(session)
|
||||
return {
|
||||
"token": token,
|
||||
"token_type": "Bearer",
|
||||
"expires_at": self.isoformat_utc(expires_at),
|
||||
"user": user,
|
||||
}
|
||||
|
||||
def get_session_by_token(self, token: str, conn=None):
|
||||
if conn is None:
|
||||
with self.connect() as db_conn:
|
||||
return self.get_session_by_token(token, db_conn)
|
||||
db_session = self.fetch_session_by_token(token, conn)
|
||||
if db_session is None or not self.is_session_valid(db_session):
|
||||
self.delete_cached_session(token)
|
||||
return None
|
||||
cached = self.get_cached_session(token, db_session=db_session)
|
||||
if cached is None:
|
||||
self.cache_session(db_session)
|
||||
return db_session
|
||||
|
||||
def revoke_current_session(self, token: str):
|
||||
with self.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("UPDATE sessions SET revoked_at = %s WHERE token = %s AND revoked_at IS NULL", (self.utc_now(), token))
|
||||
conn.commit()
|
||||
self.delete_cached_session(token)
|
||||
|
||||
def is_session_valid(self, session) -> bool:
|
||||
if session is None:
|
||||
return False
|
||||
if session.get("revoked_at") is not None:
|
||||
return False
|
||||
try:
|
||||
expiry = self.parse_session_expiry(session["expires_at"])
|
||||
except ValueError:
|
||||
return False
|
||||
if expiry <= self.utc_now():
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
store = Store()
|
||||
app = FastAPI(title="MTUSI Messenger")
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
def startup_event() -> None:
|
||||
store.pool.open(wait=True, timeout=10)
|
||||
|
||||
|
||||
|
||||
@app.on_event("shutdown")
|
||||
def shutdown_event() -> None:
|
||||
store.pool.close()
|
||||
store.shared_cache.close()
|
||||
|
||||
|
||||
@app.exception_handler(psycopg.OperationalError)
|
||||
async def database_error_handler(request: Request, exc):
|
||||
return await api_error_handler(request, ApiError(503, "unavailable", "database unavailable"))
|
||||
|
||||
|
||||
@app.middleware("http")
|
||||
async def request_id_middleware(request: Request, call_next):
|
||||
request_id = uuid.uuid4().hex
|
||||
request.state.request_id = request_id
|
||||
response = await call_next(request)
|
||||
response.headers["X-Request-Id"] = request_id
|
||||
response.headers["X-Instance-Id"] = INSTANCE_ID
|
||||
response.headers["X-App-Revision"] = os.getenv("APP_REVISION", "lab3-v2")
|
||||
return response
|
||||
|
||||
|
||||
@app.exception_handler(ApiError)
|
||||
async def api_error_handler(request: Request, exc: ApiError):
|
||||
body = {"error": {"code": exc.code, "message": exc.message, "request_id": getattr(request.state, "request_id", "")}}
|
||||
return JSONResponse(status_code=exc.status_code, headers={**exc.headers, "X-Request-Id": getattr(request.state, "request_id", ""), "X-Instance-Id": INSTANCE_ID}, content=body)
|
||||
|
||||
|
||||
@app.exception_handler(RequestValidationError)
|
||||
async def validation_error_handler(request: Request, exc: RequestValidationError):
|
||||
request_id = getattr(request.state, "request_id", "")
|
||||
return JSONResponse(
|
||||
status_code=400,
|
||||
headers={"X-Request-Id": request_id, "X-Instance-Id": INSTANCE_ID},
|
||||
content={"error": {"code": "invalid_request", "message": "invalid request", "request_id": request_id}},
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(Exception)
|
||||
async def generic_error_handler(request: Request, exc: Exception):
|
||||
request_id = getattr(request.state, "request_id", "")
|
||||
return JSONResponse(
|
||||
status_code=500,
|
||||
headers={"X-Request-Id": request_id, "X-Instance-Id": INSTANCE_ID},
|
||||
content={"error": {"code": "internal_error", "message": "internal error", "request_id": request_id}},
|
||||
)
|
||||
|
||||
|
||||
def get_auth_header(request: Request):
|
||||
auth = request.headers.get("Authorization")
|
||||
if not auth:
|
||||
raise ApiError(401, "unauthorized", "missing authorization", headers={"WWW-Authenticate": 'Bearer realm="messenger"'})
|
||||
scheme, _, token = auth.partition(" ")
|
||||
if scheme.lower() != "bearer" or not token:
|
||||
raise ApiError(401, "unauthorized", "invalid bearer token", headers={"WWW-Authenticate": 'Bearer realm="messenger"'})
|
||||
return token.strip()
|
||||
|
||||
|
||||
def require_bearer_session(request: Request):
|
||||
token = get_auth_header(request)
|
||||
with store.connect() as conn:
|
||||
session = store.get_session_by_token(token, conn)
|
||||
if session is None or not store.is_session_valid(session):
|
||||
raise ApiError(401, "unauthorized", "invalid or expired session", headers={"WWW-Authenticate": 'Bearer realm="messenger"'})
|
||||
return session
|
||||
|
||||
|
||||
async def parse_json_body(request: Request) -> Dict[str, Any]:
|
||||
try:
|
||||
raw = await request.body()
|
||||
if not raw:
|
||||
return {}
|
||||
return __import__("json").loads(raw)
|
||||
except Exception as exc:
|
||||
raise ApiError(400, "invalid_request", "malformed JSON") from exc
|
||||
|
||||
|
||||
@app.get("/health/live")
|
||||
def health_live():
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
@app.get("/health/ready")
|
||||
def health_ready():
|
||||
try:
|
||||
with store.connect() as conn:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT 1")
|
||||
return {"status": "ok"}
|
||||
except Exception as exc:
|
||||
raise ApiError(503, "unavailable", "database unavailable") from exc
|
||||
|
||||
|
||||
@app.post("/api/v1/users", status_code=201)
|
||||
async def create_user_endpoint(request: Request):
|
||||
try:
|
||||
body = await request.json()
|
||||
except Exception as exc:
|
||||
raise ApiError(400, "invalid_request", "malformed JSON") from exc
|
||||
if not isinstance(body, dict):
|
||||
raise ApiError(400, "invalid_request", "invalid user payload")
|
||||
try:
|
||||
payload = CreateUserIn.model_validate(body)
|
||||
except ValidationError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid user payload") from exc
|
||||
if not payload.username or not payload.display_name.strip():
|
||||
raise ApiError(400, "invalid_request", "invalid request")
|
||||
payload.display_name = payload.display_name.strip()
|
||||
try:
|
||||
user = store.insert_user(payload.username, payload.display_name, payload.password)
|
||||
return UserOut.model_validate(user)
|
||||
except Exception as exc:
|
||||
if "duplicate key" in str(exc).lower() or "unique" in str(exc).lower():
|
||||
raise ApiError(409, "conflict", "username already exists") from exc
|
||||
raise ApiError(503, "unavailable", "database unavailable") from exc
|
||||
|
||||
|
||||
@app.get("/api/v1/users/me")
|
||||
async def current_user(request: Request):
|
||||
session = require_bearer_session(request)
|
||||
user = session["user"]
|
||||
return UserOut.model_validate(user)
|
||||
|
||||
|
||||
@app.post("/api/v1/auth/sessions", status_code=201)
|
||||
async def create_session(request: Request):
|
||||
auth = request.headers.get("Authorization", "")
|
||||
if not auth.lower().startswith("basic "):
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
encoded = auth.split(" ", 1)[1].strip()
|
||||
try:
|
||||
decoded = base64.b64decode(encoded.encode("ascii"), validate=True)
|
||||
raw = decoded.decode("utf-8")
|
||||
except Exception:
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
if ":" not in raw:
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
username, password = raw.split(":", 1)
|
||||
if not re_match(username):
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
if not (12 <= len(password) <= 128):
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
try:
|
||||
with store.connect() as conn:
|
||||
user = store.require_user_by_username(username, conn)
|
||||
if user is None or not store.verify_password(user["password_hash"], password):
|
||||
raise ApiError(401, "unauthorized", "invalid credentials", headers={"WWW-Authenticate": 'Basic realm="messenger", charset="UTF-8"'})
|
||||
session = store.create_session(user["id"], username)
|
||||
return SessionOut.model_validate(session)
|
||||
except ApiError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
raise ApiError(503, "unavailable", "database unavailable") from exc
|
||||
|
||||
|
||||
@app.delete("/api/v1/auth/sessions/current", status_code=204)
|
||||
async def revoke_session(request: Request):
|
||||
session = require_bearer_session(request)
|
||||
token = session["token"]
|
||||
store.revoke_current_session(token)
|
||||
return Response(status_code=204)
|
||||
|
||||
|
||||
@app.post("/api/v1/chats", status_code=201)
|
||||
async def create_chat_endpoint(request: Request):
|
||||
session = require_bearer_session(request)
|
||||
try:
|
||||
body = await request.json()
|
||||
except Exception as exc:
|
||||
raise ApiError(400, "invalid_request", "malformed JSON") from exc
|
||||
if not isinstance(body, dict):
|
||||
raise ApiError(400, "invalid_request", "invalid chat payload")
|
||||
try:
|
||||
payload = CreateChatIn.model_validate(body)
|
||||
except ValidationError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid chat payload") from exc
|
||||
if len(payload.member_ids) < 1 or len(payload.member_ids) > 100:
|
||||
raise ApiError(400, "invalid_request", "invalid member_ids")
|
||||
title = payload.title.strip()
|
||||
if not title:
|
||||
raise ApiError(400, "invalid_request", "invalid title")
|
||||
normalized = []
|
||||
seen = set()
|
||||
for member_id in payload.member_ids:
|
||||
try:
|
||||
member_id = str(uuid.UUID(member_id))
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid member_ids") from exc
|
||||
if member_id in seen:
|
||||
raise ApiError(400, "invalid_request", "duplicate member_ids")
|
||||
seen.add(member_id)
|
||||
normalized.append(member_id)
|
||||
if session["user_id"] not in normalized:
|
||||
raise ApiError(400, "invalid_request", "current user must be a member")
|
||||
try:
|
||||
with store.connect() as conn:
|
||||
for member_id in normalized:
|
||||
with conn.cursor() as cur:
|
||||
cur.execute("SELECT id FROM users WHERE id = %s", (member_id,))
|
||||
if cur.fetchone() is None:
|
||||
raise ApiError(400, "invalid_request", "unknown member")
|
||||
chat = store.insert_chat(title, normalized, session["user_id"])
|
||||
return ChatOut.model_validate(chat)
|
||||
except ApiError:
|
||||
raise
|
||||
except Exception as exc:
|
||||
raise ApiError(503, "unavailable", "database unavailable") from exc
|
||||
|
||||
|
||||
@app.get("/api/v1/chats")
|
||||
async def list_chats(request: Request):
|
||||
session = require_bearer_session(request)
|
||||
limit = request.query_params.get("limit", "50")
|
||||
cursor = request.query_params.get("cursor")
|
||||
try:
|
||||
limit_int = int(limit)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid limit") from exc
|
||||
if not (1 <= limit_int <= 100):
|
||||
raise ApiError(400, "invalid_request", "invalid limit")
|
||||
result = store.list_chats_for_user(session["user_id"], limit_int, cursor)
|
||||
return {"items": [ChatOut.model_validate(item) for item in result["items"]], "next_cursor": result["next_cursor"]}
|
||||
|
||||
|
||||
@app.get("/api/v1/chats/{chat_id}")
|
||||
async def get_chat(request: Request, chat_id: str):
|
||||
session = require_bearer_session(request)
|
||||
try:
|
||||
uuid.UUID(chat_id)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid chat_id") from exc
|
||||
with store.connect() as conn:
|
||||
chat = store.fetch_chat(chat_id, conn)
|
||||
if chat is None or not store.fetch_chat_membership(chat_id, session["user_id"], conn):
|
||||
raise ApiError(404, "not_found", "chat not found")
|
||||
return ChatOut.model_validate(chat)
|
||||
|
||||
|
||||
@app.post("/api/v1/chats/{chat_id}/messages", status_code=201)
|
||||
async def create_message(request: Request, chat_id: str):
|
||||
session = require_bearer_session(request)
|
||||
try:
|
||||
uuid.UUID(chat_id)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid chat_id") from exc
|
||||
try:
|
||||
body = await request.json()
|
||||
except Exception as exc:
|
||||
raise ApiError(400, "invalid_request", "malformed JSON") from exc
|
||||
if not isinstance(body, dict):
|
||||
raise ApiError(400, "invalid_request", "invalid message payload")
|
||||
try:
|
||||
payload = CreateMessageIn.model_validate(body)
|
||||
except ValidationError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid message payload") from exc
|
||||
if payload.attachment_ids:
|
||||
raise ApiError(400, "invalid_request", "attachments are not supported in lab3")
|
||||
if not payload.text.strip():
|
||||
raise ApiError(400, "invalid_request", "invalid text")
|
||||
key = request.headers.get("Idempotency-Key", "")
|
||||
if not re.fullmatch(r"[A-Za-z0-9._:-]{1,128}", key):
|
||||
raise ApiError(400, "invalid_request", "invalid Idempotency-Key")
|
||||
with store.connect() as conn:
|
||||
chat = store.fetch_chat(chat_id, conn)
|
||||
if chat is None or not store.fetch_chat_membership(chat_id, session["user_id"], conn):
|
||||
raise ApiError(404, "not_found", "chat not found")
|
||||
message = store.insert_message(str(uuid.UUID(chat_id)), session["user_id"], payload.text, key)
|
||||
return MessageOut.model_validate(message)
|
||||
|
||||
|
||||
@app.get("/api/v1/chats/{chat_id}/messages")
|
||||
async def list_messages(request: Request, chat_id: str):
|
||||
session = require_bearer_session(request)
|
||||
try:
|
||||
uuid.UUID(chat_id)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid chat_id") from exc
|
||||
limit = request.query_params.get("limit", "50")
|
||||
cursor = request.query_params.get("cursor")
|
||||
try:
|
||||
limit_int = int(limit)
|
||||
except ValueError as exc:
|
||||
raise ApiError(400, "invalid_request", "invalid limit") from exc
|
||||
if not (1 <= limit_int <= 100):
|
||||
raise ApiError(400, "invalid_request", "invalid limit")
|
||||
with store.connect() as conn:
|
||||
if not store.fetch_chat_membership(chat_id, session["user_id"], conn):
|
||||
raise ApiError(404, "not_found", "chat not found")
|
||||
result = store.list_messages_for_chat(chat_id, limit_int, cursor)
|
||||
return {"items": [MessageOut.model_validate(item) for item in result["items"]], "next_cursor": result["next_cursor"]}
|
||||
|
||||
|
||||
def re_match(value: str) -> bool:
|
||||
import re
|
||||
|
||||
return bool(re.fullmatch(USERNAME_RE, value))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
|
||||
uvicorn.run("app:app", host=APP_HOST, port=APP_PORT, reload=False)
|
||||
@@ -0,0 +1,9 @@
|
||||
# Preserve the healthcheck used in the recorded research series.
|
||||
# Production/normal compose.yaml uses a cheaper socket-based HTTP probe.
|
||||
services:
|
||||
api:
|
||||
healthcheck:
|
||||
test: [CMD, python, -c, "import urllib.request; urllib.request.urlopen('http://localhost:8080/health/ready', timeout=1)"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 2
|
||||
@@ -0,0 +1,71 @@
|
||||
name: mtusi-lab3
|
||||
x-api: &api
|
||||
build: .
|
||||
image: ${API_IMAGE:-mtusi-lab3-api:local}
|
||||
environment: &environment
|
||||
DATABASE_URL: postgresql://messenger:${POSTGRES_PASSWORD:?Run scripts/bootstrap.sh}@db:5432/messenger
|
||||
CACHE_URL: redis://valkey:6379/0
|
||||
SESSION_STORE: valkey
|
||||
SESSION_TTL_SECONDS: 3600
|
||||
DB_POOL_MAX_SIZE: ${DB_POOL_MAX_SIZE:-5}
|
||||
CACHE_CLIENT_MODE: ${CACHE_CLIENT_MODE:-shared}
|
||||
cpus: ${API_CPUS:-2}
|
||||
mem_limit: ${API_MEMORY:-256m}
|
||||
stop_grace_period: 12s
|
||||
services:
|
||||
db:
|
||||
image: postgres:16.6-alpine
|
||||
environment:
|
||||
POSTGRES_DB: messenger
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run scripts/bootstrap.sh}
|
||||
volumes: [postgres_data:/var/lib/postgresql/data]
|
||||
cpus: ${DB_CPUS:-1}
|
||||
mem_limit: 512m
|
||||
healthcheck:
|
||||
test: [CMD-SHELL, pg_isready -U messenger -d messenger]
|
||||
interval: 2s
|
||||
timeout: 1s
|
||||
retries: 30
|
||||
valkey:
|
||||
image: valkey/valkey:8.0.2-alpine
|
||||
command: [valkey-server, --appendonly, 'yes']
|
||||
volumes: [valkey_data:/data]
|
||||
cpus: 0.25
|
||||
mem_limit: 128m
|
||||
migrate:
|
||||
<<: *api
|
||||
command: [python, migrate.py]
|
||||
depends_on:
|
||||
db: {condition: service_healthy}
|
||||
api:
|
||||
<<: *api
|
||||
command: [uvicorn, 'app:app', --host, 0.0.0.0, --port, '8080', --timeout-graceful-shutdown, '8']
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
depends_on:
|
||||
migrate: {condition: service_completed_successfully}
|
||||
valkey: {condition: service_started}
|
||||
healthcheck:
|
||||
test: [CMD, python, -c, "import socket; s=socket.create_connection(('127.0.0.1',8080),1); s.sendall(b'GET /health/ready HTTP/1.0\\r\\nHost: localhost\\r\\n\\r\\n'); assert s.makefile('rb').readline().split()[1]==b'200'"]
|
||||
interval: 2s
|
||||
timeout: 4s
|
||||
retries: 2
|
||||
lb:
|
||||
image: haproxy:3.0.5-alpine
|
||||
ports: ['${APP_PORT:-8080}:8080']
|
||||
volumes: ['./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro']
|
||||
depends_on: [api]
|
||||
cpus: ${LB_CPUS:-0.25}
|
||||
mem_limit: 64m
|
||||
load:
|
||||
image: ${API_IMAGE:-mtusi-lab3-api:local}
|
||||
profiles: [research]
|
||||
entrypoint: [python, scripts/benchmark.py]
|
||||
environment:
|
||||
BASE_URL: http://lb:8080
|
||||
cpus: 1
|
||||
mem_limit: 256m
|
||||
volumes:
|
||||
postgres_data:
|
||||
valkey_data:
|
||||
+18
-3
@@ -1,5 +1,20 @@
|
||||
# Доказательства
|
||||
# Доказательства локального запуска уровней 3/4/5
|
||||
|
||||
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
|
||||
Дата: 30 октября 2026 года. Стенд из compose.yaml, macOS/Colima, HAProxy на localhost:8083. Lab2 на порту 8080 не изменялась.
|
||||
|
||||
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
|
||||
- check.txt, validate.txt — статические проверки структуры и OpenAPI.
|
||||
- smoke.txt — публичный сквозной API-сценарий.
|
||||
- idempotency.txt — 16 конкурентных повторов через разные реальные API.
|
||||
- cache-consistency.txt — сохранённые регрессии lab2 после изменения клиента Valkey.
|
||||
- failover.txt, after-public-failover.txt — публичный сценарий отказа и реально остановленный контейнер.
|
||||
- replica-matrix.json/.txt — последовательный отказ каждой реплики, RPS, ошибки, восстановление, снимки Compose.
|
||||
- persistence.txt, before-persistence.txt, after-persistence.txt — данные и прежняя сессия после перезапуска API, PostgreSQL, Valkey и LB, реальные ID/StartedAt/volumes.
|
||||
- rolling-load.json/.txt, rolling-containers.json, rolling-build.txt, rolling-compose.txt — настоящий переход между разными image/container IDs под четырьмя потоками чтения/записи. Ошибки учитываются, подтверждения и отсутствие дублей проверяются по истории.
|
||||
- final-containers.json — итоговые процессы, лимиты CPU/RAM, опубликованные порты и volumes, без environment.
|
||||
- migrations.txt — ровно одна запись на каждую SQL-версию.
|
||||
- research-environment.json — ресурсы/версии Docker VM.
|
||||
- scaling/ — 42 исходных запуска с индивидуальными latencies/status/errors, Docker stats, SHA/лимитами контейнеров, PostgreSQL/Valkey counters. manifest-*.json содержит параметры и список запусков.
|
||||
- scaling/summary.csv и summary.json — агрегаты всех запусков; PNG/SVG — воспроизводимые графики.
|
||||
- *-progress.txt, *-compose.txt — ход серий исследования без credentials.
|
||||
|
||||
Методика, интерпретация и ограничения: ../RESEARCH.md. Команды запуска и соответствие рубрике: ../REPORT.md. Локальные пароли и токены в доказательства не сохраняются. Синтетические сообщения остаются в отдельном volume lab3.
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
[
|
||||
{
|
||||
"name": "/mtusi-lab3-api-15",
|
||||
"id": "e0560ed008477cb595331f352b877f83f2ce5ab0a5ddc9fa0c1cef79f706d798",
|
||||
"hostname": "e0560ed00847",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.631533753Z",
|
||||
"health": "starting",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-api-16",
|
||||
"id": "228d36b4417c72cd3d3f93e9dba182c7cfd4f1cd7ca7c9434c5abd1bbbf1db64",
|
||||
"hostname": "228d36b4417c",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.520706734Z",
|
||||
"health": "starting",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-db-1",
|
||||
"id": "f5348db3d08aab1ef4fb9f88be6eaef25aad39178a72f099db6809ae14830ce1",
|
||||
"hostname": "f5348db3d08a",
|
||||
"service": "db",
|
||||
"image_id": "sha256:b4fc54c57484e6077fad42c66fc44a6f5e7f5892b1a92fa48e910938bf5ce0ad",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.05414114Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 1000000000,
|
||||
"memory_bytes": 536870912,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_postgres_data",
|
||||
"destination": "/var/lib/postgresql/data"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-lb-1",
|
||||
"id": "a9f385b20235476d7f265edf338ee3b680bd3a7cedc6ac7a42826243ac93f7e1",
|
||||
"hostname": "a9f385b20235",
|
||||
"service": "lb",
|
||||
"image_id": "sha256:6a7f903d19e76bd3fa7fb5225e33d6acd5eb7f52407eece4858b58831c3e256a",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.93110174Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 67108864,
|
||||
"published_ports": {
|
||||
"8080/tcp": [
|
||||
{
|
||||
"HostIp": "",
|
||||
"HostPort": "8083"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-migrate-1",
|
||||
"id": "51fd48e4680b9dbc1152c41238fc4a816561ebe87e0f6fa22a56233ddd78e9b6",
|
||||
"hostname": "51fd48e4680b",
|
||||
"service": "migrate",
|
||||
"image_id": "sha256:48edb000b5c32d6e6868f7872036dd5146a65efd40b72896d38dbab4ffac2e35",
|
||||
"status": "exited",
|
||||
"started_at": "2026-10-30T17:33:52.031040227Z",
|
||||
"health": null,
|
||||
"nano_cpus": 500000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-valkey-1",
|
||||
"id": "dd58f60ad23028ca6c990d761afce2b7df0a9f5444e7589b6fc5457bfa1be6ac",
|
||||
"hostname": "dd58f60ad230",
|
||||
"service": "valkey",
|
||||
"image_id": "sha256:7b2072cf1b86d58fee110f4da8dc3b0e1444b22ab64f58d7f61e822e0761f866",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:10.963602376Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 134217728,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_valkey_data",
|
||||
"destination": "/data"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,103 @@
|
||||
[
|
||||
{
|
||||
"name": "/mtusi-lab3-api-15",
|
||||
"id": "e0560ed008477cb595331f352b877f83f2ce5ab0a5ddc9fa0c1cef79f706d798",
|
||||
"hostname": "e0560ed00847",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "exited",
|
||||
"started_at": "2026-10-30T17:31:25.279512606Z",
|
||||
"health": "unhealthy",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-api-16",
|
||||
"id": "228d36b4417c72cd3d3f93e9dba182c7cfd4f1cd7ca7c9434c5abd1bbbf1db64",
|
||||
"hostname": "228d36b4417c",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:31:24.575662323Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-db-1",
|
||||
"id": "f5348db3d08aab1ef4fb9f88be6eaef25aad39178a72f099db6809ae14830ce1",
|
||||
"hostname": "f5348db3d08a",
|
||||
"service": "db",
|
||||
"image_id": "sha256:b4fc54c57484e6077fad42c66fc44a6f5e7f5892b1a92fa48e910938bf5ce0ad",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T16:17:05.446631465Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 1000000000,
|
||||
"memory_bytes": 536870912,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_postgres_data",
|
||||
"destination": "/var/lib/postgresql/data"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-lb-1",
|
||||
"id": "a9f385b20235476d7f265edf338ee3b680bd3a7cedc6ac7a42826243ac93f7e1",
|
||||
"hostname": "a9f385b20235",
|
||||
"service": "lb",
|
||||
"image_id": "sha256:6a7f903d19e76bd3fa7fb5225e33d6acd5eb7f52407eece4858b58831c3e256a",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T16:21:21.580632155Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 67108864,
|
||||
"published_ports": {
|
||||
"8080/tcp": [
|
||||
{
|
||||
"HostIp": "",
|
||||
"HostPort": "8083"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-migrate-1",
|
||||
"id": "51fd48e4680b9dbc1152c41238fc4a816561ebe87e0f6fa22a56233ddd78e9b6",
|
||||
"hostname": "51fd48e4680b",
|
||||
"service": "migrate",
|
||||
"image_id": "sha256:48edb000b5c32d6e6868f7872036dd5146a65efd40b72896d38dbab4ffac2e35",
|
||||
"status": "exited",
|
||||
"started_at": "2026-10-30T17:29:05.638614601Z",
|
||||
"health": null,
|
||||
"nano_cpus": 500000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-valkey-1",
|
||||
"id": "dd58f60ad23028ca6c990d761afce2b7df0a9f5444e7589b6fc5457bfa1be6ac",
|
||||
"hostname": "dd58f60ad230",
|
||||
"service": "valkey",
|
||||
"image_id": "sha256:7b2072cf1b86d58fee110f4da8dc3b0e1444b22ab64f58d7f61e822e0761f866",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T15:51:48.520671507Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 134217728,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_valkey_data",
|
||||
"destination": "/data"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,103 @@
|
||||
[
|
||||
{
|
||||
"name": "/mtusi-lab3-api-15",
|
||||
"id": "e0560ed008477cb595331f352b877f83f2ce5ab0a5ddc9fa0c1cef79f706d798",
|
||||
"hostname": "e0560ed00847",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:02.015559912Z",
|
||||
"health": "starting",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-api-16",
|
||||
"id": "228d36b4417c72cd3d3f93e9dba182c7cfd4f1cd7ca7c9434c5abd1bbbf1db64",
|
||||
"hostname": "228d36b4417c",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:33:29.484786554Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-db-1",
|
||||
"id": "f5348db3d08aab1ef4fb9f88be6eaef25aad39178a72f099db6809ae14830ce1",
|
||||
"hostname": "f5348db3d08a",
|
||||
"service": "db",
|
||||
"image_id": "sha256:b4fc54c57484e6077fad42c66fc44a6f5e7f5892b1a92fa48e910938bf5ce0ad",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T16:17:05.446631465Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 1000000000,
|
||||
"memory_bytes": 536870912,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_postgres_data",
|
||||
"destination": "/var/lib/postgresql/data"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-lb-1",
|
||||
"id": "a9f385b20235476d7f265edf338ee3b680bd3a7cedc6ac7a42826243ac93f7e1",
|
||||
"hostname": "a9f385b20235",
|
||||
"service": "lb",
|
||||
"image_id": "sha256:6a7f903d19e76bd3fa7fb5225e33d6acd5eb7f52407eece4858b58831c3e256a",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T16:21:21.580632155Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 67108864,
|
||||
"published_ports": {
|
||||
"8080/tcp": [
|
||||
{
|
||||
"HostIp": "",
|
||||
"HostPort": "8083"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-migrate-1",
|
||||
"id": "51fd48e4680b9dbc1152c41238fc4a816561ebe87e0f6fa22a56233ddd78e9b6",
|
||||
"hostname": "51fd48e4680b",
|
||||
"service": "migrate",
|
||||
"image_id": "sha256:48edb000b5c32d6e6868f7872036dd5146a65efd40b72896d38dbab4ffac2e35",
|
||||
"status": "exited",
|
||||
"started_at": "2026-10-30T17:33:52.031040227Z",
|
||||
"health": null,
|
||||
"nano_cpus": 500000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-valkey-1",
|
||||
"id": "dd58f60ad23028ca6c990d761afce2b7df0a9f5444e7589b6fc5457bfa1be6ac",
|
||||
"hostname": "dd58f60ad230",
|
||||
"service": "valkey",
|
||||
"image_id": "sha256:7b2072cf1b86d58fee110f4da8dc3b0e1444b22ab64f58d7f61e822e0761f866",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T15:51:48.520671507Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 134217728,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_valkey_data",
|
||||
"destination": "/data"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,12 @@
|
||||
./scripts/compose.sh exec -T -e BASE_URL=http://lb:8080 -e CACHE_URL=redis://valkey:6379/0 api python - < tests/cache_consistency.py
|
||||
cache_key_exists=True
|
||||
ttl_seconds=3599
|
||||
avg_latency_ms=22.18
|
||||
p95_latency_ms=56.93
|
||||
stale_cache_rejected=True
|
||||
forged_identity_rejected=True
|
||||
concurrent_identity_checks=8/8
|
||||
malformed_cache_recovers=True
|
||||
repopulated_revoked_cache_rejected=True
|
||||
short_ttl_recovers_from_db=True
|
||||
logout_revokes_cache=True
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 scripts/check_contract.py
|
||||
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
|
||||
@@ -0,0 +1,4 @@
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8083"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 65, "failed_attempts": 3, "first_recovery_seconds": 3.042}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,103 @@
|
||||
[
|
||||
{
|
||||
"name": "/mtusi-lab3-api-15",
|
||||
"id": "e0560ed008477cb595331f352b877f83f2ce5ab0a5ddc9fa0c1cef79f706d798",
|
||||
"hostname": "e0560ed00847",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.631533753Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-api-16",
|
||||
"id": "228d36b4417c72cd3d3f93e9dba182c7cfd4f1cd7ca7c9434c5abd1bbbf1db64",
|
||||
"hostname": "228d36b4417c",
|
||||
"service": "api",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.520706734Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 2000000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-db-1",
|
||||
"id": "f5348db3d08aab1ef4fb9f88be6eaef25aad39178a72f099db6809ae14830ce1",
|
||||
"hostname": "f5348db3d08a",
|
||||
"service": "db",
|
||||
"image_id": "sha256:b4fc54c57484e6077fad42c66fc44a6f5e7f5892b1a92fa48e910938bf5ce0ad",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.05414114Z",
|
||||
"health": "healthy",
|
||||
"nano_cpus": 1000000000,
|
||||
"memory_bytes": 536870912,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_postgres_data",
|
||||
"destination": "/var/lib/postgresql/data"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-lb-1",
|
||||
"id": "a9f385b20235476d7f265edf338ee3b680bd3a7cedc6ac7a42826243ac93f7e1",
|
||||
"hostname": "a9f385b20235",
|
||||
"service": "lb",
|
||||
"image_id": "sha256:6a7f903d19e76bd3fa7fb5225e33d6acd5eb7f52407eece4858b58831c3e256a",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:11.93110174Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 67108864,
|
||||
"published_ports": {
|
||||
"8080/tcp": [
|
||||
{
|
||||
"HostIp": "",
|
||||
"HostPort": "8083"
|
||||
}
|
||||
]
|
||||
},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-migrate-1",
|
||||
"id": "51fd48e4680b9dbc1152c41238fc4a816561ebe87e0f6fa22a56233ddd78e9b6",
|
||||
"hostname": "51fd48e4680b",
|
||||
"service": "migrate",
|
||||
"image_id": "sha256:48edb000b5c32d6e6868f7872036dd5146a65efd40b72896d38dbab4ffac2e35",
|
||||
"status": "exited",
|
||||
"started_at": "2026-10-30T17:33:52.031040227Z",
|
||||
"health": null,
|
||||
"nano_cpus": 500000000,
|
||||
"memory_bytes": 268435456,
|
||||
"published_ports": {},
|
||||
"volumes": []
|
||||
},
|
||||
{
|
||||
"name": "/mtusi-lab3-valkey-1",
|
||||
"id": "dd58f60ad23028ca6c990d761afce2b7df0a9f5444e7589b6fc5457bfa1be6ac",
|
||||
"hostname": "dd58f60ad230",
|
||||
"service": "valkey",
|
||||
"image_id": "sha256:7b2072cf1b86d58fee110f4da8dc3b0e1444b22ab64f58d7f61e822e0761f866",
|
||||
"status": "running",
|
||||
"started_at": "2026-10-30T17:34:10.963602376Z",
|
||||
"health": null,
|
||||
"nano_cpus": 250000000,
|
||||
"memory_bytes": 134217728,
|
||||
"published_ports": {},
|
||||
"volumes": [
|
||||
{
|
||||
"name": "mtusi-lab3_valkey_data",
|
||||
"destination": "/data"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 tests/idempotency_concurrent.py --base-url "http://localhost:8083"
|
||||
{"parallel_requests": 16, "observed_instances": ["228d36b4417c", "e0560ed00847"], "unique_messages": 1, "conflict": 409, "semantic_replay": true, "user_scope": true}
|
||||
@@ -0,0 +1,76 @@
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
@@ -0,0 +1,6 @@
|
||||
{"file": "cache-per_request-1.json", "rps": 555.873, "p95_ms": 85.994, "errors": {}, "cpu": {"mtusi-lab3-api-7": 50.97, "mtusi-lab3-api-8": 51.427, "mtusi-lab3-db-1": 30.737, "mtusi-lab3-lb-1": 4.983, "mtusi-lab3-valkey-1": 5.208, "mtusi-lab3-research-load": 7.702}}
|
||||
{"file": "cache-shared-1.json", "rps": 543.451, "p95_ms": 99.888, "errors": {}, "cpu": {"mtusi-lab3-api-8": 46.535, "mtusi-lab3-api-7": 45.95, "mtusi-lab3-db-1": 32.153, "mtusi-lab3-lb-1": 5.159, "mtusi-lab3-valkey-1": 1.539, "mtusi-lab3-research-load": 7.855}}
|
||||
{"file": "cache-shared-2.json", "rps": 595.86, "p95_ms": 77.552, "errors": {}, "cpu": {"mtusi-lab3-api-8": 50.449, "mtusi-lab3-api-7": 50.21, "mtusi-lab3-db-1": 35.392, "mtusi-lab3-lb-1": 5.814, "mtusi-lab3-valkey-1": 1.683, "mtusi-lab3-research-load": 9.11}}
|
||||
{"file": "cache-per_request-2.json", "rps": 347.541, "p95_ms": 169.369, "errors": {}, "cpu": {"mtusi-lab3-api-8": 44.938, "mtusi-lab3-api-7": 44.924, "mtusi-lab3-db-1": 27.415, "mtusi-lab3-lb-1": 4.165, "mtusi-lab3-valkey-1": 4.385, "mtusi-lab3-research-load": 6.373}}
|
||||
{"file": "cache-per_request-3.json", "rps": 431.499, "p95_ms": 117.025, "errors": {}, "cpu": {"mtusi-lab3-api-8": 44.956, "mtusi-lab3-api-7": 45.074, "mtusi-lab3-db-1": 25.942, "mtusi-lab3-lb-1": 4.225, "mtusi-lab3-valkey-1": 4.377, "mtusi-lab3-research-load": 6.61}}
|
||||
{"file": "cache-shared-3.json", "rps": 612.79, "p95_ms": 70.037, "errors": {}, "cpu": {"mtusi-lab3-api-8": 49.832, "mtusi-lab3-api-7": 50.005, "mtusi-lab3-db-1": 35.306, "mtusi-lab3-lb-1": 5.731, "mtusi-lab3-valkey-1": 1.657, "mtusi-lab3-research-load": 8.948}}
|
||||
@@ -0,0 +1,6 @@
|
||||
version | applied_at
|
||||
--------------------+-------------------------------
|
||||
001_initial_schema | 2026-10-30 15:49:18.782934+00
|
||||
002_idempotency | 2026-10-30 15:49:18.787793+00
|
||||
(2 rows)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8083"
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"ServerVersion": "27.4.0",
|
||||
"NCPU": 4,
|
||||
"MemTotal": 8308158464,
|
||||
"Architecture": "aarch64",
|
||||
"OperatingSystem": "Ubuntu 24.04.1 LTS",
|
||||
"KernelVersion": "6.8.0-50-generic"
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
Compose can now delegate builds to bake for better performance.
|
||||
To do so, set COMPOSE_BAKE=true.
|
||||
#0 building with "colima" instance using docker driver
|
||||
|
||||
#1 [api internal] load build definition from Dockerfile
|
||||
#1 transferring dockerfile: 736B 0.0s done
|
||||
#1 DONE 0.0s
|
||||
|
||||
#2 [api auth] library/python:pull token for registry-1.docker.io
|
||||
#2 DONE 0.0s
|
||||
|
||||
#3 [api internal] load metadata for docker.io/library/python:3.11.11-slim
|
||||
#3 DONE 1.4s
|
||||
|
||||
#4 [api internal] load .dockerignore
|
||||
#4 transferring context: 233B 0.1s done
|
||||
#4 DONE 0.1s
|
||||
|
||||
#5 [api 1/10] FROM docker.io/library/python:3.11.11-slim@sha256:081075da77b2b55c23c088251026fb69a7b2bf92471e491ff5fd75c192fd38e5
|
||||
#5 DONE 0.0s
|
||||
|
||||
#6 [api internal] load build context
|
||||
#6 transferring context: 52.66kB 0.1s done
|
||||
#6 DONE 0.1s
|
||||
|
||||
#7 [api 5/10] COPY app.py migrate.py /app/
|
||||
#7 CACHED
|
||||
|
||||
#8 [api 2/10] WORKDIR /app
|
||||
#8 CACHED
|
||||
|
||||
#9 [api 3/10] COPY requirements.txt /app/requirements.txt
|
||||
#9 CACHED
|
||||
|
||||
#10 [api 4/10] RUN pip install --no-cache-dir -r /app/requirements.txt
|
||||
#10 CACHED
|
||||
|
||||
#11 [api 6/10] COPY migrations /app/migrations
|
||||
#11 CACHED
|
||||
|
||||
#12 [api 7/10] COPY scripts /app/scripts
|
||||
#12 DONE 0.2s
|
||||
|
||||
#13 [api 8/10] COPY tests/client.py /app/tests/client.py
|
||||
#13 DONE 0.1s
|
||||
|
||||
#14 [api 9/10] COPY contracts /app/contracts
|
||||
#14 DONE 0.1s
|
||||
|
||||
#15 [api 10/10] COPY lab.json /app/lab.json
|
||||
#15 DONE 0.1s
|
||||
|
||||
#16 [api] exporting to image
|
||||
#16 exporting layers
|
||||
#16 exporting layers 0.2s done
|
||||
#16 writing image sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b
|
||||
#16 writing image sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b done
|
||||
#16 naming to docker.io/library/mtusi-lab3-api:final-v5 done
|
||||
#16 DONE 0.2s
|
||||
|
||||
#17 [api] resolving provenance for metadata file
|
||||
#17 DONE 0.1s
|
||||
api Built
|
||||
@@ -0,0 +1,12 @@
|
||||
Container mtusi-lab3-api-13 Running
|
||||
Container mtusi-lab3-api-14 Running
|
||||
Container mtusi-lab3-api-15 Creating
|
||||
Container mtusi-lab3-api-15 Created
|
||||
Container mtusi-lab3-api-15 Starting
|
||||
Container mtusi-lab3-api-15 Started
|
||||
Container mtusi-lab3-api-14 Running
|
||||
Container mtusi-lab3-api-15 Running
|
||||
Container mtusi-lab3-api-16 Creating
|
||||
Container mtusi-lab3-api-16 Created
|
||||
Container mtusi-lab3-api-16 Starting
|
||||
Container mtusi-lab3-api-16 Started
|
||||
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"before": [
|
||||
{
|
||||
"id": "910c9c583e436f4be644a485f2e308f6202a0a6061dd0b906efac22a6f414863",
|
||||
"hostname": "910c9c583e43",
|
||||
"image_id": "sha256:2c5f327bf0cb839e5877e8a6c87354592750b6af60ef1b79e13c36898b68ba19",
|
||||
"image": "mtusi-lab3-api:final-v4",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
},
|
||||
{
|
||||
"id": "eaea004f9ee20031bc5c55bfc3663bb5305adbf19638336db1b78a1b9080a07b",
|
||||
"hostname": "eaea004f9ee2",
|
||||
"image_id": "sha256:2c5f327bf0cb839e5877e8a6c87354592750b6af60ef1b79e13c36898b68ba19",
|
||||
"image": "mtusi-lab3-api:final-v4",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
}
|
||||
],
|
||||
"steps": [
|
||||
{
|
||||
"removed": {
|
||||
"id": "910c9c583e436f4be644a485f2e308f6202a0a6061dd0b906efac22a6f414863",
|
||||
"hostname": "910c9c583e43",
|
||||
"image_id": "sha256:2c5f327bf0cb839e5877e8a6c87354592750b6af60ef1b79e13c36898b68ba19",
|
||||
"image": "mtusi-lab3-api:final-v4",
|
||||
"status": "exited",
|
||||
"health": "unhealthy"
|
||||
},
|
||||
"replacement": {
|
||||
"id": "aaf06527a3b8c8ca6d9cb715cf1534f765b4c24bbfa1822c1d8a44b67ee2106f",
|
||||
"hostname": "aaf06527a3b8",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"image": "mtusi-lab3-api:final-v5",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
}
|
||||
},
|
||||
{
|
||||
"removed": {
|
||||
"id": "eaea004f9ee20031bc5c55bfc3663bb5305adbf19638336db1b78a1b9080a07b",
|
||||
"hostname": "eaea004f9ee2",
|
||||
"image_id": "sha256:2c5f327bf0cb839e5877e8a6c87354592750b6af60ef1b79e13c36898b68ba19",
|
||||
"image": "mtusi-lab3-api:final-v4",
|
||||
"status": "exited",
|
||||
"health": "unhealthy"
|
||||
},
|
||||
"replacement": {
|
||||
"id": "34a5cb2ea921733541106ca0961b32ff6ffc853c8446d0bb4a3bb3c65d9db9af",
|
||||
"hostname": "34a5cb2ea921",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"image": "mtusi-lab3-api:final-v5",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
}
|
||||
}
|
||||
],
|
||||
"after": [
|
||||
{
|
||||
"id": "aaf06527a3b8c8ca6d9cb715cf1534f765b4c24bbfa1822c1d8a44b67ee2106f",
|
||||
"hostname": "aaf06527a3b8",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"image": "mtusi-lab3-api:final-v5",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
},
|
||||
{
|
||||
"id": "34a5cb2ea921733541106ca0961b32ff6ffc853c8446d0bb4a3bb3c65d9db9af",
|
||||
"hostname": "34a5cb2ea921",
|
||||
"image_id": "sha256:70cfcdb0f3a22ed6cbe096b96574392892096503370156d7427bb231f325e79b",
|
||||
"image": "mtusi-lab3-api:final-v5",
|
||||
"status": "running",
|
||||
"health": "healthy"
|
||||
}
|
||||
],
|
||||
"status": "PASS"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"status": "PASS",
|
||||
"concurrency": 4,
|
||||
"elapsed_seconds": 34.87,
|
||||
"successful_read_write_pairs": 902,
|
||||
"failed_attempts": 56,
|
||||
"successful_pairs_rps": 25.868,
|
||||
"successful_pair_latency_ms": {
|
||||
"p50": 16.886,
|
||||
"p95": 461.635,
|
||||
"p99": 877.331
|
||||
},
|
||||
"observed_instances": [
|
||||
"34a5cb2ea921",
|
||||
"910c9c583e43",
|
||||
"aaf06527a3b8",
|
||||
"eaea004f9ee2"
|
||||
],
|
||||
"confirmed_data_preserved": true,
|
||||
"duplicates": 0
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
PASS: all original API containers replaced; evidence/rolling-containers.json
|
||||
{
|
||||
"status": "PASS",
|
||||
"concurrency": 4,
|
||||
"elapsed_seconds": 34.87,
|
||||
"successful_read_write_pairs": 902,
|
||||
"failed_attempts": 56,
|
||||
"successful_pairs_rps": 25.868,
|
||||
"successful_pair_latency_ms": {
|
||||
"p50": 16.886,
|
||||
"p95": 461.635,
|
||||
"p99": 877.331
|
||||
},
|
||||
"observed_instances": [
|
||||
"34a5cb2ea921",
|
||||
"910c9c583e43",
|
||||
"aaf06527a3b8",
|
||||
"eaea004f9ee2"
|
||||
],
|
||||
"confirmed_data_preserved": true,
|
||||
"duplicates": 0
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-10 Creating
|
||||
Container mtusi-lab3-api-9 Creating
|
||||
Container mtusi-lab3-api-9 Created
|
||||
Container mtusi-lab3-api-10 Created
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-api-10 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-api-10 Started
|
||||
Container mtusi-lab3-api-9 Starting
|
||||
Container mtusi-lab3-api-9 Started
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-9 Running
|
||||
Container mtusi-lab3-api-10 Running
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-10 Stopping
|
||||
Container mtusi-lab3-api-9 Stopping
|
||||
Container mtusi-lab3-api-10 Stopped
|
||||
Container mtusi-lab3-api-10 Removing
|
||||
Container mtusi-lab3-api-10 Removed
|
||||
Container mtusi-lab3-api-9 Stopped
|
||||
Container mtusi-lab3-api-9 Removing
|
||||
Container mtusi-lab3-api-9 Removed
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
@@ -0,0 +1,18 @@
|
||||
{"file": "db-0.5-1.json", "rps": 803.987, "p95_ms": 54.876, "errors": {}, "cpu": {"mtusi-lab3-db-1": 46.873, "mtusi-lab3-api-10": 35.932, "mtusi-lab3-api-9": 36.152, "mtusi-lab3-api-8": 36.725, "mtusi-lab3-api-7": 36.49, "mtusi-lab3-lb-1": 7.289, "mtusi-lab3-valkey-1": 1.915, "mtusi-lab3-research-load": 10.482}}
|
||||
{"file": "db-1-1.json", "rps": 999.561, "p95_ms": 47.365, "errors": {}, "cpu": {"mtusi-lab3-db-1": 57.3, "mtusi-lab3-api-10": 44.505, "mtusi-lab3-api-9": 44.937, "mtusi-lab3-api-8": 44.425, "mtusi-lab3-api-7": 44.66, "mtusi-lab3-lb-1": 8.399, "mtusi-lab3-valkey-1": 2.213, "mtusi-lab3-research-load": 13.487}}
|
||||
{"file": "saturation-c1-1.json", "rps": 387.964, "p95_ms": 4.231, "errors": {}, "cpu": {"mtusi-lab3-db-1": 19.916, "mtusi-lab3-api-10": 20.009, "mtusi-lab3-api-9": 21.0, "mtusi-lab3-api-8": 20.102, "mtusi-lab3-api-7": 19.707, "mtusi-lab3-lb-1": 3.116, "mtusi-lab3-valkey-1": 0.999, "mtusi-lab3-research-load": 4.165}}
|
||||
{"file": "saturation-c64-1.json", "rps": 444.725, "p95_ms": 313.12, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.309, "mtusi-lab3-api-10": 22.66, "mtusi-lab3-api-9": 22.76, "mtusi-lab3-api-8": 23.204, "mtusi-lab3-api-7": 23.629, "mtusi-lab3-lb-1": 3.921, "mtusi-lab3-valkey-1": 1.09, "mtusi-lab3-research-load": 6.187}}
|
||||
{"file": "saturation-c4-1.json", "rps": 225.289, "p95_ms": 90.266, "errors": {}, "cpu": {"mtusi-lab3-db-1": 24.79, "mtusi-lab3-api-10": 20.345, "mtusi-lab3-api-9": 20.187, "mtusi-lab3-api-8": 20.111, "mtusi-lab3-api-7": 20.163, "mtusi-lab3-lb-1": 2.737, "mtusi-lab3-valkey-1": 0.936, "mtusi-lab3-research-load": 4.188}}
|
||||
{"file": "saturation-c16-1.json", "rps": 410.25, "p95_ms": 99.332, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.327, "mtusi-lab3-api-10": 23.271, "mtusi-lab3-api-9": 24.827, "mtusi-lab3-api-8": 24.503, "mtusi-lab3-api-7": 24.12, "mtusi-lab3-lb-1": 3.856, "mtusi-lab3-valkey-1": 1.131, "mtusi-lab3-research-load": 5.692}}
|
||||
{"file": "db-0.5-2.json", "rps": 871.602, "p95_ms": 53.622, "errors": {}, "cpu": {"mtusi-lab3-db-1": 45.628, "mtusi-lab3-api-10": 39.278, "mtusi-lab3-api-9": 39.897, "mtusi-lab3-api-8": 38.071, "mtusi-lab3-api-7": 39.146, "mtusi-lab3-lb-1": 6.948, "mtusi-lab3-valkey-1": 2.207, "mtusi-lab3-research-load": 10.96}}
|
||||
{"file": "saturation-c16-2.json", "rps": 448.065, "p95_ms": 103.235, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.267, "mtusi-lab3-api-10": 22.506, "mtusi-lab3-api-9": 23.171, "mtusi-lab3-api-8": 22.994, "mtusi-lab3-api-7": 23.03, "mtusi-lab3-lb-1": 3.735, "mtusi-lab3-valkey-1": 1.106, "mtusi-lab3-research-load": 5.978}}
|
||||
{"file": "saturation-c64-2.json", "rps": 413.697, "p95_ms": 359.185, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.442, "mtusi-lab3-api-10": 23.398, "mtusi-lab3-api-9": 23.784, "mtusi-lab3-api-8": 23.44, "mtusi-lab3-api-7": 22.692, "mtusi-lab3-lb-1": 4.001, "mtusi-lab3-valkey-1": 1.123, "mtusi-lab3-research-load": 6.384}}
|
||||
{"file": "saturation-c1-2.json", "rps": 265.665, "p95_ms": 4.887, "errors": {}, "cpu": {"mtusi-lab3-db-1": 20.126, "mtusi-lab3-api-10": 16.922, "mtusi-lab3-api-9": 16.79, "mtusi-lab3-api-8": 16.219, "mtusi-lab3-api-7": 16.479, "mtusi-lab3-lb-1": 2.282, "mtusi-lab3-valkey-1": 0.812, "mtusi-lab3-research-load": 2.782}}
|
||||
{"file": "saturation-c4-2.json", "rps": 379.734, "p95_ms": 65.419, "errors": {}, "cpu": {"mtusi-lab3-db-1": 23.726, "mtusi-lab3-api-10": 22.646, "mtusi-lab3-api-9": 22.443, "mtusi-lab3-api-8": 23.562, "mtusi-lab3-api-7": 23.071, "mtusi-lab3-lb-1": 3.369, "mtusi-lab3-valkey-1": 1.058, "mtusi-lab3-research-load": 5.179}}
|
||||
{"file": "db-1-2.json", "rps": 859.146, "p95_ms": 77.356, "errors": {}, "cpu": {"mtusi-lab3-db-1": 47.204, "mtusi-lab3-api-10": 38.29, "mtusi-lab3-api-9": 39.07, "mtusi-lab3-api-8": 39.662, "mtusi-lab3-api-7": 39.992, "mtusi-lab3-lb-1": 6.983, "mtusi-lab3-valkey-1": 1.911, "mtusi-lab3-research-load": 11.249}}
|
||||
{"file": "saturation-c1-3.json", "rps": 352.833, "p95_ms": 4.731, "errors": {}, "cpu": {"mtusi-lab3-db-1": 19.556, "mtusi-lab3-api-10": 18.905, "mtusi-lab3-api-9": 18.968, "mtusi-lab3-api-8": 19.774, "mtusi-lab3-api-7": 20.643, "mtusi-lab3-lb-1": 3.094, "mtusi-lab3-valkey-1": 0.99, "mtusi-lab3-research-load": 4.147}}
|
||||
{"file": "saturation-c4-3.json", "rps": 455.926, "p95_ms": 63.513, "errors": {}, "cpu": {"mtusi-lab3-db-1": 24.236, "mtusi-lab3-api-10": 23.191, "mtusi-lab3-api-9": 22.791, "mtusi-lab3-api-8": 22.828, "mtusi-lab3-api-7": 22.412, "mtusi-lab3-lb-1": 3.516, "mtusi-lab3-valkey-1": 1.044, "mtusi-lab3-research-load": 5.635}}
|
||||
{"file": "saturation-c64-3.json", "rps": 307.264, "p95_ms": 603.239, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.456, "mtusi-lab3-api-10": 19.507, "mtusi-lab3-api-9": 18.786, "mtusi-lab3-api-8": 19.431, "mtusi-lab3-api-7": 19.393, "mtusi-lab3-lb-1": 3.169, "mtusi-lab3-valkey-1": 0.943, "mtusi-lab3-research-load": 5.197}}
|
||||
{"file": "saturation-c16-3.json", "rps": 486.645, "p95_ms": 115.049, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.27, "mtusi-lab3-api-10": 23.275, "mtusi-lab3-api-9": 23.233, "mtusi-lab3-api-8": 22.634, "mtusi-lab3-api-7": 22.358, "mtusi-lab3-lb-1": 3.645, "mtusi-lab3-valkey-1": 1.071, "mtusi-lab3-research-load": 5.895}}
|
||||
{"file": "db-0.5-3.json", "rps": 833.766, "p95_ms": 78.461, "errors": {}, "cpu": {"mtusi-lab3-db-1": 40.723, "mtusi-lab3-api-10": 34.286, "mtusi-lab3-api-9": 33.529, "mtusi-lab3-api-8": 34.348, "mtusi-lab3-api-7": 34.241, "mtusi-lab3-lb-1": 6.064, "mtusi-lab3-valkey-1": 1.623, "mtusi-lab3-research-load": 9.721}}
|
||||
{"file": "db-1-3.json", "rps": 999.988, "p95_ms": 53.436, "errors": {}, "cpu": {"mtusi-lab3-db-1": 50.073, "mtusi-lab3-api-10": 39.893, "mtusi-lab3-api-9": 40.221, "mtusi-lab3-api-8": 40.009, "mtusi-lab3-api-7": 39.824, "mtusi-lab3-lb-1": 7.411, "mtusi-lab3-valkey-1": 1.954, "mtusi-lab3-research-load": 12.029}}
|
||||
@@ -0,0 +1,337 @@
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Creating
|
||||
Container mtusi-lab3-api-4 Creating
|
||||
Container mtusi-lab3-api-1 Recreate
|
||||
Container mtusi-lab3-api-4 Created
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-api-5 Created
|
||||
Container mtusi-lab3-api-1 Recreated
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-api-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
Container mtusi-lab3-api-1 Started
|
||||
Container mtusi-lab3-api-4 Starting
|
||||
Container mtusi-lab3-api-4 Started
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-1 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-4 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-api-4 Recreated
|
||||
Container mtusi-lab3-api-1 Recreated
|
||||
Container mtusi-lab3-api-5 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-api-4 Starting
|
||||
Container mtusi-lab3-api-4 Started
|
||||
Container mtusi-lab3-api-1 Starting
|
||||
Container mtusi-lab3-api-1 Started
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Stopping
|
||||
Container mtusi-lab3-api-1 Stopping
|
||||
Container mtusi-lab3-api-4 Stopping
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-5 Stopped
|
||||
Container mtusi-lab3-api-5 Removing
|
||||
Container mtusi-lab3-api-5 Removed
|
||||
Container mtusi-lab3-api-1 Stopped
|
||||
Container mtusi-lab3-api-1 Removing
|
||||
Container mtusi-lab3-api-1 Removed
|
||||
Container mtusi-lab3-api-4 Stopped
|
||||
Container mtusi-lab3-api-4 Removing
|
||||
Container mtusi-lab3-api-4 Removed
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-4 Creating
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-4 Created
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-api-4 Starting
|
||||
Container mtusi-lab3-api-4 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-3 Running
|
||||
Container mtusi-lab3-api-4 Stopping
|
||||
Container mtusi-lab3-api-4 Stopped
|
||||
Container mtusi-lab3-api-4 Removing
|
||||
Container mtusi-lab3-api-4 Removed
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-4 Creating
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-4 Created
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-4 Starting
|
||||
Container mtusi-lab3-api-4 Started
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-4 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-6 Creating
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-5 Creating
|
||||
Container mtusi-lab3-api-5 Created
|
||||
Container mtusi-lab3-api-6 Created
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-api-4 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-api-6 Starting
|
||||
Container mtusi-lab3-api-6 Started
|
||||
Container mtusi-lab3-api-4 Starting
|
||||
Container mtusi-lab3-api-4 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-4 Stopping
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-6 Stopping
|
||||
Container mtusi-lab3-api-5 Recreated
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-api-6 Stopped
|
||||
Container mtusi-lab3-api-6 Removing
|
||||
Container mtusi-lab3-api-6 Removed
|
||||
Container mtusi-lab3-api-4 Stopped
|
||||
Container mtusi-lab3-api-4 Removing
|
||||
Container mtusi-lab3-api-4 Removed
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-3 Recreate
|
||||
Container mtusi-lab3-api-5 Recreated
|
||||
Container mtusi-lab3-api-3 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-api-3 Starting
|
||||
Container mtusi-lab3-api-3 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-3 Stopping
|
||||
Container mtusi-lab3-api-5 Recreate
|
||||
Container mtusi-lab3-api-5 Recreated
|
||||
Container mtusi-lab3-api-3 Stopped
|
||||
Container mtusi-lab3-api-3 Removing
|
||||
Container mtusi-lab3-api-3 Removed
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-5 Recreate
|
||||
Container mtusi-lab3-api-5 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-5 Starting
|
||||
Container mtusi-lab3-api-5 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-5 Running
|
||||
Container mtusi-lab3-api-8 Creating
|
||||
Container mtusi-lab3-api-6 Creating
|
||||
Container mtusi-lab3-api-7 Creating
|
||||
Container mtusi-lab3-api-6 Created
|
||||
Container mtusi-lab3-api-7 Created
|
||||
Container mtusi-lab3-api-8 Created
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-api-6 Starting
|
||||
Container mtusi-lab3-api-6 Started
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-5 Stopping
|
||||
Container mtusi-lab3-api-6 Stopping
|
||||
Container mtusi-lab3-api-8 Stopping
|
||||
Container mtusi-lab3-api-6 Stopped
|
||||
Container mtusi-lab3-api-6 Removing
|
||||
Container mtusi-lab3-api-6 Removed
|
||||
Container mtusi-lab3-api-8 Stopped
|
||||
Container mtusi-lab3-api-8 Removing
|
||||
Container mtusi-lab3-api-8 Removed
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-api-5 Stopped
|
||||
Container mtusi-lab3-api-5 Removing
|
||||
Container mtusi-lab3-api-5 Removed
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-api-8 Creating
|
||||
Container mtusi-lab3-api-8 Created
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-10 Creating
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-api-9 Creating
|
||||
Container mtusi-lab3-api-9 Created
|
||||
Container mtusi-lab3-api-10 Created
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-api-9 Starting
|
||||
Container mtusi-lab3-api-9 Started
|
||||
Container mtusi-lab3-api-10 Starting
|
||||
Container mtusi-lab3-api-10 Started
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Running
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-7 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-9 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-10 Recreate
|
||||
Container mtusi-lab3-lb-1 Stopping
|
||||
Container mtusi-lab3-lb-1 Stopped
|
||||
Container mtusi-lab3-api-8 Recreate
|
||||
Container mtusi-lab3-api-8 Recreated
|
||||
Container mtusi-lab3-api-9 Recreated
|
||||
Container mtusi-lab3-api-10 Recreated
|
||||
Container mtusi-lab3-api-7 Recreated
|
||||
Container mtusi-lab3-lb-1 Created
|
||||
Container mtusi-lab3-api-8 Starting
|
||||
Container mtusi-lab3-api-8 Started
|
||||
Container mtusi-lab3-api-10 Starting
|
||||
Container mtusi-lab3-api-10 Started
|
||||
Container mtusi-lab3-api-9 Starting
|
||||
Container mtusi-lab3-api-9 Started
|
||||
Container mtusi-lab3-api-7 Starting
|
||||
Container mtusi-lab3-api-7 Started
|
||||
Container mtusi-lab3-lb-1 Starting
|
||||
Container mtusi-lab3-lb-1 Started
|
||||
Container mtusi-lab3-db-1 Recreate
|
||||
Container mtusi-lab3-api-7 Running
|
||||
Container mtusi-lab3-api-8 Running
|
||||
Container mtusi-lab3-api-10 Stopping
|
||||
Container mtusi-lab3-api-9 Stopping
|
||||
Container mtusi-lab3-api-10 Stopped
|
||||
Container mtusi-lab3-api-10 Removing
|
||||
Container mtusi-lab3-api-10 Removed
|
||||
Container mtusi-lab3-api-9 Stopped
|
||||
Container mtusi-lab3-api-9 Removing
|
||||
Container mtusi-lab3-api-9 Removed
|
||||
Container mtusi-lab3-lb-1 Running
|
||||
Container mtusi-lab3-db-1 Recreated
|
||||
Container mtusi-lab3-db-1 Starting
|
||||
Container mtusi-lab3-db-1 Started
|
||||
@@ -0,0 +1,18 @@
|
||||
{"file": "fixed-4-1.json", "rps": 318.135, "p95_ms": 219.313, "errors": {}, "cpu": {"mtusi-lab3-api-1": 17.406, "mtusi-lab3-api-4": 16.723, "mtusi-lab3-api-3": 17.327, "mtusi-lab3-db-1": 18.252, "mtusi-lab3-lb-1": 2.742, "mtusi-lab3-valkey-1": 0.876, "mtusi-lab3-research-load": 4.26}}
|
||||
{"file": "growing-4-1.json", "rps": 478.863, "p95_ms": 98.486, "errors": {}, "cpu": {"mtusi-lab3-api-4": 22.485, "mtusi-lab3-api-1": 22.762, "mtusi-lab3-api-5": 22.588, "mtusi-lab3-db-1": 25.217, "mtusi-lab3-lb-1": 3.653, "mtusi-lab3-valkey-1": 1.074, "mtusi-lab3-research-load": 5.845}}
|
||||
{"file": "fixed-1-1.json", "rps": 647.958, "p95_ms": 35.342, "errors": {}, "cpu": {"mtusi-lab3-db-1": 25.001, "mtusi-lab3-lb-1": 4.264, "mtusi-lab3-valkey-1": 1.194, "mtusi-lab3-research-load": 8.165}}
|
||||
{"file": "growing-2-1.json", "rps": 520.157, "p95_ms": 82.649, "errors": {}, "cpu": {"mtusi-lab3-api-4": 35.145, "mtusi-lab3-db-1": 24.73, "mtusi-lab3-lb-1": 3.513, "mtusi-lab3-valkey-1": 1.128, "mtusi-lab3-research-load": 5.836}}
|
||||
{"file": "growing-1-1.json", "rps": 505.723, "p95_ms": 90.09, "errors": {}, "cpu": {"mtusi-lab3-db-1": 19.95, "mtusi-lab3-lb-1": 3.162, "mtusi-lab3-valkey-1": 0.991, "mtusi-lab3-research-load": 5.736}}
|
||||
{"file": "fixed-2-1.json", "rps": 401.125, "p95_ms": 82.732, "errors": {}, "cpu": {"mtusi-lab3-api-3": 29.169, "mtusi-lab3-db-1": 24.746, "mtusi-lab3-lb-1": 2.756, "mtusi-lab3-valkey-1": 0.992, "mtusi-lab3-research-load": 4.539}}
|
||||
{"file": "fixed-4-2.json", "rps": 324.321, "p95_ms": 191.768, "errors": {}, "cpu": {"mtusi-lab3-api-3": 17.242, "mtusi-lab3-api-6": 17.188, "mtusi-lab3-api-4": 18.436, "mtusi-lab3-db-1": 18.696, "mtusi-lab3-lb-1": 2.752, "mtusi-lab3-valkey-1": 0.955, "mtusi-lab3-research-load": 4.273}}
|
||||
{"file": "fixed-2-2.json", "rps": 515.006, "p95_ms": 76.266, "errors": {}, "cpu": {"mtusi-lab3-api-3": 34.945, "mtusi-lab3-db-1": 24.474, "mtusi-lab3-lb-1": 3.442, "mtusi-lab3-valkey-1": 1.111, "mtusi-lab3-research-load": 5.768}}
|
||||
{"file": "growing-2-2.json", "rps": 399.351, "p95_ms": 94.176, "errors": {}, "cpu": {"mtusi-lab3-api-3": 29.585, "mtusi-lab3-db-1": 24.648, "mtusi-lab3-lb-1": 2.82, "mtusi-lab3-valkey-1": 0.999, "mtusi-lab3-research-load": 4.655}}
|
||||
{"file": "fixed-1-2.json", "rps": 631.518, "p95_ms": 37.266, "errors": {}, "cpu": {"mtusi-lab3-db-1": 24.862, "mtusi-lab3-lb-1": 4.171, "mtusi-lab3-valkey-1": 1.195, "mtusi-lab3-research-load": 6.712}}
|
||||
{"file": "growing-1-2.json", "rps": 482.186, "p95_ms": 81.803, "errors": {}, "cpu": {"mtusi-lab3-db-1": 19.987, "mtusi-lab3-lb-1": 3.357, "mtusi-lab3-valkey-1": 0.973, "mtusi-lab3-research-load": 6.349}}
|
||||
{"file": "growing-4-2.json", "rps": 343.057, "p95_ms": 152.977, "errors": {}, "cpu": {"mtusi-lab3-api-6": 18.412, "mtusi-lab3-api-8": 18.331, "mtusi-lab3-api-5": 18.883, "mtusi-lab3-db-1": 25.35, "mtusi-lab3-lb-1": 3.042, "mtusi-lab3-valkey-1": 0.926, "mtusi-lab3-research-load": 4.391}}
|
||||
{"file": "fixed-1-3.json", "rps": 638.99, "p95_ms": 36.865, "errors": {}, "cpu": {"mtusi-lab3-db-1": 24.968, "mtusi-lab3-lb-1": 4.207, "mtusi-lab3-valkey-1": 1.187, "mtusi-lab3-research-load": 7.499}}
|
||||
{"file": "growing-1-3.json", "rps": 511.119, "p95_ms": 78.577, "errors": {}, "cpu": {"mtusi-lab3-db-1": 19.734, "mtusi-lab3-lb-1": 3.202, "mtusi-lab3-valkey-1": 0.981, "mtusi-lab3-research-load": 5.959}}
|
||||
{"file": "growing-2-3.json", "rps": 462.92, "p95_ms": 96.178, "errors": {}, "cpu": {"mtusi-lab3-api-7": 34.073, "mtusi-lab3-db-1": 23.457, "mtusi-lab3-lb-1": 3.305, "mtusi-lab3-valkey-1": 1.068, "mtusi-lab3-research-load": 5.506}}
|
||||
{"file": "fixed-2-3.json", "rps": 494.619, "p95_ms": 81.704, "errors": {}, "cpu": {"mtusi-lab3-api-7": 34.133, "mtusi-lab3-db-1": 24.152, "mtusi-lab3-lb-1": 3.502, "mtusi-lab3-valkey-1": 1.091, "mtusi-lab3-research-load": 5.549}}
|
||||
{"file": "fixed-4-3.json", "rps": 407.053, "p95_ms": 120.384, "errors": {}, "cpu": {"mtusi-lab3-api-9": 19.051, "mtusi-lab3-api-10": 19.483, "mtusi-lab3-api-8": 19.201, "mtusi-lab3-db-1": 21.351, "mtusi-lab3-lb-1": 3.043, "mtusi-lab3-valkey-1": 0.94, "mtusi-lab3-research-load": 5.01}}
|
||||
{"file": "growing-4-3.json", "rps": 467.649, "p95_ms": 99.836, "errors": {}, "cpu": {"mtusi-lab3-api-10": 22.684, "mtusi-lab3-api-9": 23.239, "mtusi-lab3-api-7": 22.89, "mtusi-lab3-db-1": 25.109, "mtusi-lab3-lb-1": 3.604, "mtusi-lab3-valkey-1": 1.061, "mtusi-lab3-research-load": 5.757}}
|
||||
@@ -0,0 +1,268 @@
|
||||
[
|
||||
{
|
||||
"case": "cache-per_request",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 444.971,
|
||||
"rps_min": 347.541,
|
||||
"rps_max": 555.873,
|
||||
"rps_stdev": 104.817,
|
||||
"p50_ms_mean": 26.979,
|
||||
"p95_ms_mean": 124.129,
|
||||
"p99_ms_mean": 226.961,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 28.031,
|
||||
"lb_cpu_percent_mean": 4.458,
|
||||
"client_cpu_percent_mean": 6.895,
|
||||
"api_memory_peak_mib": 121.2,
|
||||
"db_memory_peak_mib": 75.9,
|
||||
"cache_new_connections_mean": 5422.667
|
||||
},
|
||||
{
|
||||
"case": "cache-shared",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 584.034,
|
||||
"rps_min": 543.451,
|
||||
"rps_max": 612.79,
|
||||
"rps_stdev": 36.151,
|
||||
"p50_ms_mean": 20.15,
|
||||
"p95_ms_mean": 82.492,
|
||||
"p99_ms_mean": 148.197,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 34.284,
|
||||
"lb_cpu_percent_mean": 5.568,
|
||||
"client_cpu_percent_mean": 8.638,
|
||||
"api_memory_peak_mib": 110.9,
|
||||
"db_memory_peak_mib": 82.33,
|
||||
"cache_new_connections_mean": 2.333
|
||||
},
|
||||
{
|
||||
"case": "db-0.5",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 836.452,
|
||||
"rps_min": 803.987,
|
||||
"rps_max": 871.602,
|
||||
"rps_stdev": 33.887,
|
||||
"p50_ms_mean": 9.837,
|
||||
"p95_ms_mean": 62.32,
|
||||
"p99_ms_mean": 110.954,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 44.408,
|
||||
"lb_cpu_percent_mean": 6.767,
|
||||
"client_cpu_percent_mean": 10.388,
|
||||
"api_memory_peak_mib": 109.3,
|
||||
"db_memory_peak_mib": 62.39,
|
||||
"cache_new_connections_mean": 1.667
|
||||
},
|
||||
{
|
||||
"case": "db-1",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 952.898,
|
||||
"rps_min": 859.146,
|
||||
"rps_max": 999.988,
|
||||
"rps_stdev": 81.192,
|
||||
"p50_ms_mean": 8.824,
|
||||
"p95_ms_mean": 59.386,
|
||||
"p99_ms_mean": 116.851,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 51.526,
|
||||
"lb_cpu_percent_mean": 7.598,
|
||||
"client_cpu_percent_mean": 12.255,
|
||||
"api_memory_peak_mib": 109.9,
|
||||
"db_memory_peak_mib": 63.95,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "fixed-1",
|
||||
"repeats": 3,
|
||||
"replicas": 1,
|
||||
"rps_mean": 639.489,
|
||||
"rps_min": 631.518,
|
||||
"rps_max": 647.958,
|
||||
"rps_stdev": 8.231,
|
||||
"p50_ms_mean": 21.817,
|
||||
"p95_ms_mean": 36.491,
|
||||
"p99_ms_mean": 64.198,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.944,
|
||||
"lb_cpu_percent_mean": 4.214,
|
||||
"client_cpu_percent_mean": 7.459,
|
||||
"api_memory_peak_mib": null,
|
||||
"db_memory_peak_mib": 94.06,
|
||||
"cache_new_connections_mean": 2
|
||||
},
|
||||
{
|
||||
"case": "fixed-2",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 470.25,
|
||||
"rps_min": 401.125,
|
||||
"rps_max": 515.006,
|
||||
"rps_stdev": 60.726,
|
||||
"p50_ms_mean": 17.989,
|
||||
"p95_ms_mean": 80.234,
|
||||
"p99_ms_mean": 164.256,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.457,
|
||||
"lb_cpu_percent_mean": 3.233,
|
||||
"client_cpu_percent_mean": 5.285,
|
||||
"api_memory_peak_mib": 106.5,
|
||||
"db_memory_peak_mib": 116.1,
|
||||
"cache_new_connections_mean": 3
|
||||
},
|
||||
{
|
||||
"case": "fixed-4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 349.836,
|
||||
"rps_min": 318.135,
|
||||
"rps_max": 407.053,
|
||||
"rps_stdev": 49.648,
|
||||
"p50_ms_mean": 8.392,
|
||||
"p95_ms_mean": 177.155,
|
||||
"p99_ms_mean": 311.404,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.433,
|
||||
"lb_cpu_percent_mean": 2.846,
|
||||
"client_cpu_percent_mean": 4.514,
|
||||
"api_memory_peak_mib": 119.2,
|
||||
"db_memory_peak_mib": 133.6,
|
||||
"cache_new_connections_mean": 5
|
||||
},
|
||||
{
|
||||
"case": "growing-1",
|
||||
"repeats": 3,
|
||||
"replicas": 1,
|
||||
"rps_mean": 499.676,
|
||||
"rps_min": 482.186,
|
||||
"rps_max": 511.119,
|
||||
"rps_stdev": 15.385,
|
||||
"p50_ms_mean": 22.18,
|
||||
"p95_ms_mean": 83.49,
|
||||
"p99_ms_mean": 99.364,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.89,
|
||||
"lb_cpu_percent_mean": 3.24,
|
||||
"client_cpu_percent_mean": 6.015,
|
||||
"api_memory_peak_mib": null,
|
||||
"db_memory_peak_mib": 100.2,
|
||||
"cache_new_connections_mean": 1.667
|
||||
},
|
||||
{
|
||||
"case": "growing-2",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 460.809,
|
||||
"rps_min": 399.351,
|
||||
"rps_max": 520.157,
|
||||
"rps_stdev": 60.431,
|
||||
"p50_ms_mean": 18.676,
|
||||
"p95_ms_mean": 91.001,
|
||||
"p99_ms_mean": 184.321,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.278,
|
||||
"lb_cpu_percent_mean": 3.213,
|
||||
"client_cpu_percent_mean": 5.332,
|
||||
"api_memory_peak_mib": 60.21,
|
||||
"db_memory_peak_mib": 112.9,
|
||||
"cache_new_connections_mean": 2.667
|
||||
},
|
||||
{
|
||||
"case": "growing-4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 429.856,
|
||||
"rps_min": 343.057,
|
||||
"rps_max": 478.863,
|
||||
"rps_stdev": 75.379,
|
||||
"p50_ms_mean": 10.296,
|
||||
"p95_ms_mean": 117.1,
|
||||
"p99_ms_mean": 268.256,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.225,
|
||||
"lb_cpu_percent_mean": 3.433,
|
||||
"client_cpu_percent_mean": 5.331,
|
||||
"api_memory_peak_mib": 106.4,
|
||||
"db_memory_peak_mib": 136.4,
|
||||
"cache_new_connections_mean": 4.667
|
||||
},
|
||||
{
|
||||
"case": "saturation-c1",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 335.487,
|
||||
"rps_min": 265.665,
|
||||
"rps_max": 387.964,
|
||||
"rps_stdev": 62.968,
|
||||
"p50_ms_mean": 1.871,
|
||||
"p95_ms_mean": 4.616,
|
||||
"p99_ms_mean": 39.666,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.866,
|
||||
"lb_cpu_percent_mean": 2.831,
|
||||
"client_cpu_percent_mean": 3.698,
|
||||
"api_memory_peak_mib": 119.2,
|
||||
"db_memory_peak_mib": 82.22,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c16",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 448.32,
|
||||
"rps_min": 410.25,
|
||||
"rps_max": 486.645,
|
||||
"rps_stdev": 38.198,
|
||||
"p50_ms_mean": 11.681,
|
||||
"p95_ms_mean": 105.872,
|
||||
"p99_ms_mean": 171.931,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.288,
|
||||
"lb_cpu_percent_mean": 3.745,
|
||||
"client_cpu_percent_mean": 5.855,
|
||||
"api_memory_peak_mib": 109.3,
|
||||
"db_memory_peak_mib": 72.93,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 353.65,
|
||||
"rps_min": 225.289,
|
||||
"rps_max": 455.926,
|
||||
"rps_stdev": 117.51,
|
||||
"p50_ms_mean": 3.434,
|
||||
"p95_ms_mean": 73.066,
|
||||
"p99_ms_mean": 88.685,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.251,
|
||||
"lb_cpu_percent_mean": 3.207,
|
||||
"client_cpu_percent_mean": 5.001,
|
||||
"api_memory_peak_mib": 109.9,
|
||||
"db_memory_peak_mib": 78.28,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c64",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 388.562,
|
||||
"rps_min": 307.264,
|
||||
"rps_max": 444.725,
|
||||
"rps_stdev": 72.095,
|
||||
"p50_ms_mean": 122.244,
|
||||
"p95_ms_mean": 425.181,
|
||||
"p99_ms_mean": 674.453,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.402,
|
||||
"lb_cpu_percent_mean": 3.697,
|
||||
"client_cpu_percent_mean": 5.923,
|
||||
"api_memory_peak_mib": 120.7,
|
||||
"db_memory_peak_mib": 84.29,
|
||||
"cache_new_connections_mean": 1
|
||||
}
|
||||
]
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 58 KiB |
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 46 KiB |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"suite": "improvement",
|
||||
"parameters": {
|
||||
"base_url": "http://localhost:8083",
|
||||
"duration": 10.0,
|
||||
"warmup": 2.0,
|
||||
"repeats": 3,
|
||||
"concurrency": 16,
|
||||
"suite": "improvement"
|
||||
},
|
||||
"files": [
|
||||
"cache-per_request-1.json",
|
||||
"cache-shared-1.json",
|
||||
"cache-shared-2.json",
|
||||
"cache-per_request-2.json",
|
||||
"cache-per_request-3.json",
|
||||
"cache-shared-3.json"
|
||||
],
|
||||
"seed_base": 20261030
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"suite": "saturation",
|
||||
"parameters": {
|
||||
"base_url": "http://localhost:8083",
|
||||
"duration": 10.0,
|
||||
"warmup": 2.0,
|
||||
"repeats": 3,
|
||||
"concurrency": 16,
|
||||
"suite": "saturation"
|
||||
},
|
||||
"files": [
|
||||
"db-0.5-1.json",
|
||||
"db-1-1.json",
|
||||
"saturation-c1-1.json",
|
||||
"saturation-c64-1.json",
|
||||
"saturation-c4-1.json",
|
||||
"saturation-c16-1.json",
|
||||
"db-0.5-2.json",
|
||||
"saturation-c16-2.json",
|
||||
"saturation-c64-2.json",
|
||||
"saturation-c1-2.json",
|
||||
"saturation-c4-2.json",
|
||||
"db-1-2.json",
|
||||
"saturation-c1-3.json",
|
||||
"saturation-c4-3.json",
|
||||
"saturation-c64-3.json",
|
||||
"saturation-c16-3.json",
|
||||
"db-0.5-3.json",
|
||||
"db-1-3.json"
|
||||
],
|
||||
"seed_base": 20261030
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"suite": "scaling",
|
||||
"parameters": {
|
||||
"base_url": "http://localhost:8083",
|
||||
"duration": 10.0,
|
||||
"warmup": 2.0,
|
||||
"repeats": 3,
|
||||
"concurrency": 16,
|
||||
"suite": "scaling"
|
||||
},
|
||||
"files": [
|
||||
"fixed-4-1.json",
|
||||
"growing-4-1.json",
|
||||
"fixed-1-1.json",
|
||||
"growing-2-1.json",
|
||||
"growing-1-1.json",
|
||||
"fixed-2-1.json",
|
||||
"fixed-4-2.json",
|
||||
"fixed-2-2.json",
|
||||
"growing-2-2.json",
|
||||
"fixed-1-2.json",
|
||||
"growing-1-2.json",
|
||||
"growing-4-2.json",
|
||||
"fixed-1-3.json",
|
||||
"growing-1-3.json",
|
||||
"growing-2-3.json",
|
||||
"fixed-2-3.json",
|
||||
"fixed-4-3.json",
|
||||
"growing-4-3.json"
|
||||
],
|
||||
"seed_base": 20261030
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 122 KiB |
File diff suppressed because it is too large
Load Diff
|
After Width: | Height: | Size: 65 KiB |
@@ -0,0 +1,15 @@
|
||||
case,repeats,replicas,rps_mean,rps_min,rps_max,rps_stdev,p50_ms_mean,p95_ms_mean,p99_ms_mean,errors,db_cpu_percent_mean,lb_cpu_percent_mean,client_cpu_percent_mean,api_memory_peak_mib,db_memory_peak_mib,cache_new_connections_mean
|
||||
cache-per_request,3,2,444.971,347.541,555.873,104.817,26.979,124.129,226.961,0,28.031,4.458,6.895,121.2,75.9,5422.667
|
||||
cache-shared,3,2,584.034,543.451,612.79,36.151,20.15,82.492,148.197,0,34.284,5.568,8.638,110.9,82.33,2.333
|
||||
db-0.5,3,4,836.452,803.987,871.602,33.887,9.837,62.32,110.954,0,44.408,6.767,10.388,109.3,62.39,1.667
|
||||
db-1,3,4,952.898,859.146,999.988,81.192,8.824,59.386,116.851,0,51.526,7.598,12.255,109.9,63.95,1
|
||||
fixed-1,3,1,639.489,631.518,647.958,8.231,21.817,36.491,64.198,0,24.944,4.214,7.459,,94.06,2
|
||||
fixed-2,3,2,470.25,401.125,515.006,60.726,17.989,80.234,164.256,0,24.457,3.233,5.285,106.5,116.1,3
|
||||
fixed-4,3,4,349.836,318.135,407.053,49.648,8.392,177.155,311.404,0,19.433,2.846,4.514,119.2,133.6,5
|
||||
growing-1,3,1,499.676,482.186,511.119,15.385,22.18,83.49,99.364,0,19.89,3.24,6.015,,100.2,1.667
|
||||
growing-2,3,2,460.809,399.351,520.157,60.431,18.676,91.001,184.321,0,24.278,3.213,5.332,60.21,112.9,2.667
|
||||
growing-4,3,4,429.856,343.057,478.863,75.379,10.296,117.1,268.256,0,25.225,3.433,5.331,106.4,136.4,4.667
|
||||
saturation-c1,3,4,335.487,265.665,387.964,62.968,1.871,4.616,39.666,0,19.866,2.831,3.698,119.2,82.22,1
|
||||
saturation-c16,3,4,448.32,410.25,486.645,38.198,11.681,105.872,171.931,0,25.288,3.745,5.855,109.3,72.93,1
|
||||
saturation-c4,3,4,353.65,225.289,455.926,117.51,3.434,73.066,88.685,0,24.251,3.207,5.001,109.9,78.28,1
|
||||
saturation-c64,3,4,388.562,307.264,444.725,72.095,122.244,425.181,674.453,0,25.402,3.697,5.923,120.7,84.29,1
|
||||
|
@@ -0,0 +1,268 @@
|
||||
[
|
||||
{
|
||||
"case": "cache-per_request",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 444.971,
|
||||
"rps_min": 347.541,
|
||||
"rps_max": 555.873,
|
||||
"rps_stdev": 104.817,
|
||||
"p50_ms_mean": 26.979,
|
||||
"p95_ms_mean": 124.129,
|
||||
"p99_ms_mean": 226.961,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 28.031,
|
||||
"lb_cpu_percent_mean": 4.458,
|
||||
"client_cpu_percent_mean": 6.895,
|
||||
"api_memory_peak_mib": 121.2,
|
||||
"db_memory_peak_mib": 75.9,
|
||||
"cache_new_connections_mean": 5422.667
|
||||
},
|
||||
{
|
||||
"case": "cache-shared",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 584.034,
|
||||
"rps_min": 543.451,
|
||||
"rps_max": 612.79,
|
||||
"rps_stdev": 36.151,
|
||||
"p50_ms_mean": 20.15,
|
||||
"p95_ms_mean": 82.492,
|
||||
"p99_ms_mean": 148.197,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 34.284,
|
||||
"lb_cpu_percent_mean": 5.568,
|
||||
"client_cpu_percent_mean": 8.638,
|
||||
"api_memory_peak_mib": 110.9,
|
||||
"db_memory_peak_mib": 82.33,
|
||||
"cache_new_connections_mean": 2.333
|
||||
},
|
||||
{
|
||||
"case": "db-0.5",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 836.452,
|
||||
"rps_min": 803.987,
|
||||
"rps_max": 871.602,
|
||||
"rps_stdev": 33.887,
|
||||
"p50_ms_mean": 9.837,
|
||||
"p95_ms_mean": 62.32,
|
||||
"p99_ms_mean": 110.954,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 44.408,
|
||||
"lb_cpu_percent_mean": 6.767,
|
||||
"client_cpu_percent_mean": 10.388,
|
||||
"api_memory_peak_mib": 109.3,
|
||||
"db_memory_peak_mib": 62.39,
|
||||
"cache_new_connections_mean": 1.667
|
||||
},
|
||||
{
|
||||
"case": "db-1",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 952.898,
|
||||
"rps_min": 859.146,
|
||||
"rps_max": 999.988,
|
||||
"rps_stdev": 81.192,
|
||||
"p50_ms_mean": 8.824,
|
||||
"p95_ms_mean": 59.386,
|
||||
"p99_ms_mean": 116.851,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 51.526,
|
||||
"lb_cpu_percent_mean": 7.598,
|
||||
"client_cpu_percent_mean": 12.255,
|
||||
"api_memory_peak_mib": 109.9,
|
||||
"db_memory_peak_mib": 63.95,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "fixed-1",
|
||||
"repeats": 3,
|
||||
"replicas": 1,
|
||||
"rps_mean": 639.489,
|
||||
"rps_min": 631.518,
|
||||
"rps_max": 647.958,
|
||||
"rps_stdev": 8.231,
|
||||
"p50_ms_mean": 21.817,
|
||||
"p95_ms_mean": 36.491,
|
||||
"p99_ms_mean": 64.198,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.944,
|
||||
"lb_cpu_percent_mean": 4.214,
|
||||
"client_cpu_percent_mean": 7.459,
|
||||
"api_memory_peak_mib": null,
|
||||
"db_memory_peak_mib": 94.06,
|
||||
"cache_new_connections_mean": 2
|
||||
},
|
||||
{
|
||||
"case": "fixed-2",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 470.25,
|
||||
"rps_min": 401.125,
|
||||
"rps_max": 515.006,
|
||||
"rps_stdev": 60.726,
|
||||
"p50_ms_mean": 17.989,
|
||||
"p95_ms_mean": 80.234,
|
||||
"p99_ms_mean": 164.256,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.457,
|
||||
"lb_cpu_percent_mean": 3.233,
|
||||
"client_cpu_percent_mean": 5.285,
|
||||
"api_memory_peak_mib": 106.5,
|
||||
"db_memory_peak_mib": 116.1,
|
||||
"cache_new_connections_mean": 3
|
||||
},
|
||||
{
|
||||
"case": "fixed-4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 349.836,
|
||||
"rps_min": 318.135,
|
||||
"rps_max": 407.053,
|
||||
"rps_stdev": 49.648,
|
||||
"p50_ms_mean": 8.392,
|
||||
"p95_ms_mean": 177.155,
|
||||
"p99_ms_mean": 311.404,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.433,
|
||||
"lb_cpu_percent_mean": 2.846,
|
||||
"client_cpu_percent_mean": 4.514,
|
||||
"api_memory_peak_mib": 119.2,
|
||||
"db_memory_peak_mib": 133.6,
|
||||
"cache_new_connections_mean": 5
|
||||
},
|
||||
{
|
||||
"case": "growing-1",
|
||||
"repeats": 3,
|
||||
"replicas": 1,
|
||||
"rps_mean": 499.676,
|
||||
"rps_min": 482.186,
|
||||
"rps_max": 511.119,
|
||||
"rps_stdev": 15.385,
|
||||
"p50_ms_mean": 22.18,
|
||||
"p95_ms_mean": 83.49,
|
||||
"p99_ms_mean": 99.364,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.89,
|
||||
"lb_cpu_percent_mean": 3.24,
|
||||
"client_cpu_percent_mean": 6.015,
|
||||
"api_memory_peak_mib": null,
|
||||
"db_memory_peak_mib": 100.2,
|
||||
"cache_new_connections_mean": 1.667
|
||||
},
|
||||
{
|
||||
"case": "growing-2",
|
||||
"repeats": 3,
|
||||
"replicas": 2,
|
||||
"rps_mean": 460.809,
|
||||
"rps_min": 399.351,
|
||||
"rps_max": 520.157,
|
||||
"rps_stdev": 60.431,
|
||||
"p50_ms_mean": 18.676,
|
||||
"p95_ms_mean": 91.001,
|
||||
"p99_ms_mean": 184.321,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.278,
|
||||
"lb_cpu_percent_mean": 3.213,
|
||||
"client_cpu_percent_mean": 5.332,
|
||||
"api_memory_peak_mib": 60.21,
|
||||
"db_memory_peak_mib": 112.9,
|
||||
"cache_new_connections_mean": 2.667
|
||||
},
|
||||
{
|
||||
"case": "growing-4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 429.856,
|
||||
"rps_min": 343.057,
|
||||
"rps_max": 478.863,
|
||||
"rps_stdev": 75.379,
|
||||
"p50_ms_mean": 10.296,
|
||||
"p95_ms_mean": 117.1,
|
||||
"p99_ms_mean": 268.256,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.225,
|
||||
"lb_cpu_percent_mean": 3.433,
|
||||
"client_cpu_percent_mean": 5.331,
|
||||
"api_memory_peak_mib": 106.4,
|
||||
"db_memory_peak_mib": 136.4,
|
||||
"cache_new_connections_mean": 4.667
|
||||
},
|
||||
{
|
||||
"case": "saturation-c1",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 335.487,
|
||||
"rps_min": 265.665,
|
||||
"rps_max": 387.964,
|
||||
"rps_stdev": 62.968,
|
||||
"p50_ms_mean": 1.871,
|
||||
"p95_ms_mean": 4.616,
|
||||
"p99_ms_mean": 39.666,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 19.866,
|
||||
"lb_cpu_percent_mean": 2.831,
|
||||
"client_cpu_percent_mean": 3.698,
|
||||
"api_memory_peak_mib": 119.2,
|
||||
"db_memory_peak_mib": 82.22,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c16",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 448.32,
|
||||
"rps_min": 410.25,
|
||||
"rps_max": 486.645,
|
||||
"rps_stdev": 38.198,
|
||||
"p50_ms_mean": 11.681,
|
||||
"p95_ms_mean": 105.872,
|
||||
"p99_ms_mean": 171.931,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.288,
|
||||
"lb_cpu_percent_mean": 3.745,
|
||||
"client_cpu_percent_mean": 5.855,
|
||||
"api_memory_peak_mib": 109.3,
|
||||
"db_memory_peak_mib": 72.93,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c4",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 353.65,
|
||||
"rps_min": 225.289,
|
||||
"rps_max": 455.926,
|
||||
"rps_stdev": 117.51,
|
||||
"p50_ms_mean": 3.434,
|
||||
"p95_ms_mean": 73.066,
|
||||
"p99_ms_mean": 88.685,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 24.251,
|
||||
"lb_cpu_percent_mean": 3.207,
|
||||
"client_cpu_percent_mean": 5.001,
|
||||
"api_memory_peak_mib": 109.9,
|
||||
"db_memory_peak_mib": 78.28,
|
||||
"cache_new_connections_mean": 1
|
||||
},
|
||||
{
|
||||
"case": "saturation-c64",
|
||||
"repeats": 3,
|
||||
"replicas": 4,
|
||||
"rps_mean": 388.562,
|
||||
"rps_min": 307.264,
|
||||
"rps_max": 444.725,
|
||||
"rps_stdev": 72.095,
|
||||
"p50_ms_mean": 122.244,
|
||||
"p95_ms_mean": 425.181,
|
||||
"p99_ms_mean": 674.453,
|
||||
"errors": 0,
|
||||
"db_cpu_percent_mean": 25.402,
|
||||
"lb_cpu_percent_mean": 3.697,
|
||||
"client_cpu_percent_mean": 5.923,
|
||||
"api_memory_peak_mib": 120.7,
|
||||
"db_memory_peak_mib": 84.29,
|
||||
"cache_new_connections_mean": 1
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,2 @@
|
||||
python3 tests/smoke.py --base-url "http://localhost:8083"
|
||||
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
|
||||
@@ -0,0 +1,2 @@
|
||||
../.venv/bin/python scripts/validate_openapi.py
|
||||
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
|
||||
+6
-4
@@ -1,7 +1,9 @@
|
||||
# Инфраструктура студента
|
||||
# Инфраструктура lab3
|
||||
|
||||
Здесь разместите конфигурации выбранных сервисов; основную топологию — в корневом compose.yaml/stack.yaml. `compose.example.yaml` — только worksheet ролей и намеренно не запускается. `contracts/infrastructure.json` задаёт минимальные роли, не готовые образы/пароли.
|
||||
compose.yaml описывает отдельный проект mtusi-lab3. HAProxy использует infra/haproxy.cfg: roundrobin, active readiness checks, server-template и Docker DNS. Опубликован только порт LB. API ×2, PostgreSQL и Valkey находятся в приватной Compose-сети. Sticky sessions нет.
|
||||
|
||||
В REPORT.md сопоставьте роль → service name → версия/digest → health/readiness → volume → сеть/порт → способ передачи credentials. Приведите bootstrap (schema, bucket, broker topology, а с lab6 provisioning) и безопасное повторение этих команд.
|
||||
Мигратор — отдельный one-shot service; API зависят от его успешного завершения. SQL-версии сериализуются advisory lock и записываются в schema_migrations в той же транзакции. Параметры API_IMAGE/API_REPLICAS/API_CPUS/API_MEMORY/DB_POOL_MAX_SIZE/DB_CPUS/LB_CPUS/CACHE_CLIENT_MODE настраиваются через окружение или .env. Для учебного пароля применяется scripts/bootstrap.sh; .env не попадает в Git/образ.
|
||||
|
||||
Приложение строится из исходников. Не используйте заранее существующий образ преподавательского сервера вместо своей реализации. Restart hook перезапускает все соответствующие stores с volumes; failover hook останавливает только заданную API-реплику.
|
||||
scripts/rolling-update.sh выполняет настоящую поочерёдную замену контейнеров: временная дополнительная реплика с выбранным API_IMAGE → readiness и появление за LB → SIGTERM старому контейнеру → его удаление. Старые volumes не затрагиваются. При неготовой новой реплике старую скрипт не удаляет, возвращает ошибку и оставляет состояние для диагностики. Для восстановления после такого сбоя выполнить обычный compose up -d --scale api=2 с заведомо исправным API_IMAGE.
|
||||
|
||||
Команды запуска, ограничения миграций и доказательства — в REPORT.md; методика исследования — в RESEARCH.md.
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 512
|
||||
|
||||
defaults
|
||||
log global
|
||||
mode http
|
||||
timeout connect 1s
|
||||
timeout client 15s
|
||||
timeout server 10s
|
||||
timeout check 1s
|
||||
retries 0
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 2
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 1s
|
||||
hold obsolete 1s
|
||||
|
||||
frontend public
|
||||
bind :8080
|
||||
default_backend replicas
|
||||
|
||||
backend replicas
|
||||
balance roundrobin
|
||||
option httpchk GET /health/ready
|
||||
http-check expect status 200
|
||||
default-server inter 1s fall 2 rise 1 resolvers docker init-addr libc,none
|
||||
server-template api 8 api:8080 check
|
||||
@@ -0,0 +1,8 @@
|
||||
from app import store
|
||||
|
||||
if __name__ == '__main__':
|
||||
store.pool.open(wait=True, timeout=30)
|
||||
try:
|
||||
store.init()
|
||||
finally:
|
||||
store.pool.close()
|
||||
@@ -0,0 +1,41 @@
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id UUID PRIMARY KEY,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
display_name TEXT NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS chats (
|
||||
id UUID PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS chat_members (
|
||||
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (chat_id, user_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS messages (
|
||||
id UUID PRIMARY KEY,
|
||||
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
||||
sender_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
text TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS sessions (
|
||||
id UUID PRIMARY KEY,
|
||||
token TEXT NOT NULL UNIQUE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
revoked_at TIMESTAMPTZ,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS idx_messages_chat_created ON messages(chat_id, created_at, id);
|
||||
CREATE INDEX IF NOT EXISTS idx_chat_members_user ON chat_members(user_id, chat_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_chats_created ON chats(created_at, id);
|
||||
CREATE INDEX IF NOT EXISTS idx_sessions_user ON sessions(user_id, expires_at);
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE message_requests (
|
||||
sender_id UUID NOT NULL REFERENCES users(id),
|
||||
chat_id UUID NOT NULL REFERENCES chats(id),
|
||||
key VARCHAR(128) NOT NULL,
|
||||
body TEXT NOT NULL,
|
||||
response JSONB NOT NULL,
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
PRIMARY KEY(sender_id, chat_id, key)
|
||||
);
|
||||
CREATE INDEX message_requests_expiry ON message_requests(expires_at);
|
||||
@@ -0,0 +1,2 @@
|
||||
# Only needed to regenerate the research figures; workloads use stdlib.
|
||||
matplotlib==3.10.0
|
||||
@@ -0,0 +1,7 @@
|
||||
fastapi==0.115.0
|
||||
uvicorn==0.30.6
|
||||
psycopg[binary]==3.3.6
|
||||
psycopg-pool==3.2.6
|
||||
argon2-cffi==23.1.0
|
||||
python-dotenv==1.0.1
|
||||
redis==5.1.0
|
||||
@@ -0,0 +1,108 @@
|
||||
"""Persistent HTTP closed-loop benchmark, executed INSIDE the Compose network.
|
||||
|
||||
No retries: measures HTTP confirmations, with separate error/timeout counts.
|
||||
Warmup is excluded. Individual latencies are retained, including failed requests.
|
||||
"""
|
||||
import argparse
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import http.client
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
from client import Client
|
||||
|
||||
|
||||
def benchmark(base, concurrency, duration, warmup):
|
||||
c = Client(base)
|
||||
alice, bob, eve, chat = c.bootstrap()
|
||||
endpoint = '/api/v1/chats/' + chat['id'] + '/messages'
|
||||
parsed = urlsplit(base)
|
||||
barrier = threading.Barrier(concurrency + 1)
|
||||
run_id = uuid.uuid4().hex
|
||||
timing = {}
|
||||
|
||||
def worker(index):
|
||||
conn = http.client.HTTPConnection(parsed.hostname, parsed.port or 80, timeout=5)
|
||||
samples = []
|
||||
observed = set()
|
||||
counter = 0
|
||||
barrier.wait()
|
||||
while time.monotonic() < timing['end']:
|
||||
start = time.monotonic()
|
||||
measured = start >= timing['measure']
|
||||
key = f'{run_id}-{index}-{counter}'
|
||||
text = 'bench-' + key
|
||||
status = 0
|
||||
error = None
|
||||
try:
|
||||
conn.request('POST', endpoint, json.dumps({'text': text}), {
|
||||
'Authorization': 'Bearer ' + alice['token'],
|
||||
'Content-Type': 'application/json', 'Idempotency-Key': key})
|
||||
response = conn.getresponse()
|
||||
status = response.status
|
||||
payload = response.read()
|
||||
if status == 201:
|
||||
data = json.loads(payload)
|
||||
if data['text'] != text or data['chat_id'] != chat['id']:
|
||||
error = 'invalid_payload'
|
||||
if measured:
|
||||
observed.add(response.getheader('X-Instance-Id'))
|
||||
else:
|
||||
error = 'http_' + str(status)
|
||||
except (OSError, http.client.HTTPException, ValueError, KeyError) as exc:
|
||||
error = type(exc).__name__
|
||||
conn.close()
|
||||
conn = http.client.HTTPConnection(parsed.hostname, parsed.port or 80, timeout=5)
|
||||
elapsed = 1000 * (time.monotonic() - start)
|
||||
if measured:
|
||||
samples.append([round(elapsed, 3), status, error])
|
||||
counter += 1
|
||||
conn.close()
|
||||
return samples, observed
|
||||
|
||||
with ThreadPoolExecutor(max_workers=concurrency) as pool:
|
||||
futures = [pool.submit(worker, i) for i in range(concurrency)]
|
||||
begin = time.monotonic()
|
||||
timing.update(measure=begin + warmup, end=begin + warmup + duration)
|
||||
barrier.wait()
|
||||
results = [f.result() for f in futures]
|
||||
end = time.monotonic()
|
||||
samples = [s for values, _ in results for s in values]
|
||||
successful = sorted(s[0] for s in samples if s[1] == 201 and s[2] is None)
|
||||
errors = {}
|
||||
for _, _, error in samples:
|
||||
if error:
|
||||
errors[error] = errors.get(error, 0) + 1
|
||||
def percentile(p):
|
||||
return successful[max(0, math.ceil(p * len(successful))-1)] if successful else None
|
||||
return {'workload': 'closed-loop persistent POST via LB, unique keys, no retries',
|
||||
'concurrency': concurrency, 'warmup_seconds': warmup,
|
||||
'requested_duration_seconds': duration,
|
||||
'measure_started_unix': time.time() - (time.monotonic() - timing['measure']),
|
||||
'finished_unix': time.time(),
|
||||
'elapsed_seconds': round(end - timing['measure'], 3),
|
||||
'successful_requests': len(successful), 'errors': errors,
|
||||
'successful_rps': round(len(successful) / (end-timing['measure']), 3),
|
||||
'successful_latency_ms': {f'p{p}': percentile(p/100) for p in (50,95,99)},
|
||||
'observed_instances': sorted({i for _, ids in results for i in ids if i}),
|
||||
'samples_ms_status_error': samples}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument('--base-url', default=os.getenv('BASE_URL', 'http://localhost:8083'))
|
||||
parser.add_argument('--concurrency', type=int, default=16)
|
||||
parser.add_argument('--duration', type=float, default=12)
|
||||
parser.add_argument('--warmup', type=float, default=3)
|
||||
args = parser.parse_args()
|
||||
if not 1 <= args.concurrency <= 128 or not 1 <= args.duration <= 3600 or not 0 <= args.warmup <= 60:
|
||||
parser.error('invalid load parameters')
|
||||
print(json.dumps(benchmark(args.base_url, args.concurrency, args.duration, args.warmup)))
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
if [ ! -f .env ]; then
|
||||
umask 077
|
||||
python3 -c 'import secrets; print("POSTGRES_PASSWORD="+secrets.token_hex(24)); print("APP_PORT=8080")' > .env
|
||||
fi
|
||||
Executable
+7
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
if docker compose version >/dev/null 2>&1; then
|
||||
exec docker compose "$@"
|
||||
fi
|
||||
exec docker-compose "$@"
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user