Author SHA1 Message Date
Матвей 4aba163f7a fix 2026-10-16 11:48:49 +03:00
Матвей f2c4395693 add level 5 2026-10-14 15:53:07 +03:00
Матвей 516bb095ac add code for level 4 2026-10-14 15:25:51 +03:00
29 changed files with 2658 additions and 30 deletions
+8 -2
View File
@@ -4,10 +4,10 @@ CA_FILE ?=
ACTION_SCRIPT ?= ACTION_SCRIPT ?=
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",) TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
.PHONY: help check validate test load test-persistence test-failover .PHONY: help check validate test load test-persistence test-failover test-rolling track1
help: help:
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes" @echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes; test-rolling: sequential API replacement; track1: Level 5 benchmark on isolated port 8081"
check: check:
$(PYTHON) scripts/check_contract.py $(PYTHON) scripts/check_contract.py
@@ -28,3 +28,9 @@ test-persistence:
test-failover: test-failover:
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2) @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) $(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
test-rolling:
$(PYTHON) student-tests/rolling_update.py --base-url "$(BASE_URL)" $(TLS_ARGS)
track1:
scripts/run-track1.sh
+115 -21
View File
@@ -1,13 +1,13 @@
# Отчёт — лабораторная 3 # Отчёт — лабораторная 3
- Автор, группа: Матвей Козырев, БВТ2301 - Автор, группа: Матвей Козырев, БВТ2301
- Целевая оценка; выбранный трек 5, если нужен: 3 - Целевая оценка: 5; трек 1 «Цена масштабирования»
- Commit/PR: TODO после публикации - Commit/PR: TODO после публикации
- Использованные источники, библиотеки и помощь ИИ: FastAPI 0.141.1, Uvicorn 0.40.0, asyncpg 0.31.0, argon2-cffi 25.1.0; Docker Compose и Nginx. Код перенесён из собственной Lab2 и адаптирован для Lab3. - Использованные библиотеки: FastAPI, Uvicorn, asyncpg, argon2-cffi, Docker Compose, HAProxy. До исправления замечаний 16.10.2026 использовался Nginx.
## Запуск из чистого clone ## Запуск из чистого clone
Нужны Docker Engine с Docker Compose v2 и OpenSSL. Создайте локальные секреты, которые исключены из Git: Нужны Docker Engine с Docker Compose v2 и OpenSSL. Секреты создаются локально и не попадают в Git.
```sh ```sh
mkdir -p secrets mkdir -p secrets
@@ -21,37 +21,131 @@ docker compose --env-file .env.example up -d --build --wait
make test make test
``` ```
Точка входа — `http://localhost:8080`; порты API и PostgreSQL на host не публикуются. Миграции выполняет одноразовый сервис `migrate` до запуска обеих API-реплик. Обычная остановка — `docker compose down`; она сохраняет volumes. Удаление учебных данных требует отдельной намеренной команды `docker compose down -v` и не выполняется restart/failover hooks. Точка входа — `http://localhost:8080`; API и PostgreSQL не публикуют порты на host. Обычная остановка `docker compose down` сохраняет volume. Удаление учебных данных — отдельная команда `docker compose down -v`.
Для rolling update:
```sh
make test-rolling
```
Для эксперимента уровня 5:
```sh
make track1
```
Последняя команда использует отдельный Compose project `mtusi2026lab3bench`, отдельный PostgreSQL volume и порт `8081`; основной стенд на `8080` она не меняет.
## Архитектура и решения ## Архитектура и решения
```text ```text
Клиент → Nginx load_balancer → api-a / api-b → PostgreSQL Клиент → HAProxy load_balancer → api-a / api-b → PostgreSQL
``` ```
PostgreSQL — общий источник истины для пользователей, сессий, чатов, сообщений и idempotency records. API не имеет локального состояния, определяющего корректность. `X-Instance-Id` берётся из hostname контейнера и стабилен до остановки процесса. Общий Docker secret задаёт ключ подписи курсоров, поэтому курсор, созданный одной репликой, проверяется другой. `Idempotency-Key` хранится в PostgreSQL в области user + method + path + key; создание сообщения и запись результата выполняются одной транзакцией. Nginx 1.27.5 повторно разрешает имена обеих реплик через Docker DNS каждые две секунды, а passive failure detection исключает backend после одной ошибки на две секунды. PostgreSQL — общий источник истины для пользователей, сессий, чатов, сообщений и idempotency records. API не хранит локального состояния, от которого зависит корректность. `X-Instance-Id` берётся из hostname контейнера. Общий Docker secret задаёт ключ подписи курсоров, поэтому курсор одной реплики проверяется другой. `Idempotency-Key` хранится в PostgreSQL в области user + method + path + key; создание сообщения и запись результата происходят в одной транзакции.
## Доказательства критериев HAProxy проверяет каждую API-реплику через `GET /health/ready` каждые 2 с: только статус 200 считается успехом. Одна неуспешная проверка исключает backend (`fall=1`), две успешные возвращают его (`rise=2`). Timeout проверки — 2 с, соединения — 1 с. Ожидаемое обнаружение отказа — следующий интервал плюс время проверки (около 4–5 с с учётом соединения, без гарантии времени планирования ОС). Проверки работают независимо от Docker health status и клиентского трафика. DNS обновляется через Docker resolver. Конфигурация: [haproxy.cfg](infra/haproxy.cfg); механизм: [HAProxy health checks](https://www.haproxy.com/documentation/haproxy-configuration-tutorials/reliability/health-checks/).
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства | API healthcheck выполняется каждые 5 с, имеет timeout 3 с, `retries=12` и `start_period=10 с`. Uvicorn получает до 8 с на graceful shutdown; контейнеру задан `stop_grace_period=10 с`. В HAProxy не включён повтор уже отправленных POST по HTTP-ошибкам: это защищает регистрации от неявного повторения.
Лимиты основной конфигурации: API — по 0,5 CPU / 256 MiB; PostgreSQL — 0,75 CPU / 512 MiB; LB — 0,25 CPU / 128 MiB. [Замер docker inspect от 14.10](evidence/resource-limits-2026-10-14.txt) относится к прежнему Nginx; лимиты сохранены в [compose.yaml](compose.yaml).
Миграции выполняет отдельный одноразовый сервис `migrate` до API. Миграции `001`, `002` и `003` additive: предыдущая версия API не зависит от добавленной таблицы идемпотентности, а новая стартует после завершения migrate.
## Проверка уровня 3 и 4
Следующая таблица содержит исторические результаты 14.10.2026 для Nginx. Регрессии после замены LB описаны в разделе «Исправления по ревью».
| Проверка | Команда | Результат | Доказательство |
| --- | --- | --- | --- | | --- | --- | --- | --- |
| Публичный smoke | `make test` | PASS: lab3 public API scenario | `evidence/smoke-2026-10-14.txt` | | Публичный API-сценарий | `make test` | PASS | [smoke](evidence/smoke-2026-10-14.txt) |
| Общая идемпотентность | `python3 student-tests/idempotency_concurrency.py` | 16 параллельных повторов через LB вернули одно сообщение; в истории одна запись | `evidence/idempotency-concurrency-2026-10-14.txt` | | Общая идемпотентность | `python3 student-tests/idempotency_concurrency.py` | 16 конкурентных повторов вернули одно сообщение; в истории одна запись | [idempotency](evidence/idempotency-concurrency-2026-10-14.txt) |
| Сохранность | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | PASS с прежней сессией и подтверждёнными данными после restart API, PostgreSQL и LB | `evidence/persistence-2026-10-14.txt` | | Сохранность после restart | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | PASS; сессия и данные сохранены | [persistence](evidence/persistence-2026-10-14.txt) |
| Отказ api-b | `make test-failover ACTION_SCRIPT=scripts/stop-one.sh` | 2 реплики до отказа; 130 успешных записей, 0 ошибок, первая успешная запись через 0,545 с | `evidence/failover-api-b-2026-10-14.txt` | | Отказ `api-b` | `make test-failover ACTION_SCRIPT=scripts/stop-one.sh` | 130 успешных записей, 0 ошибок, восстановление 0,765 с | [failover api-b](evidence/failover-api-b-2026-10-14.txt) |
| Отказ api-a | Повтор после восстановления api-b | 2 реплики до отказа; 129 успешных записей, 0 ошибок, первая успешная запись через 0,559 с | `evidence/failover-api-a-2026-10-14.txt` | | Отказ `api-a` | Повтор после восстановления `api-b` | 129 успешных записей, 0 ошибок, восстановление 0,567 с | [failover api-a](evidence/failover-api-a-2026-10-14.txt) |
| Rolling update под записью | `make test-rolling` | 380 успешных записей, 0 ошибок, заменены обе API-реплики | [rolling update](evidence/rolling-update-2026-10-14.txt) |
После обеих failover-проверок вручную восстановлены `api-a` и `api-b`; финальный `docker compose ps` показал `healthy` для обеих API-реплик, Nginx и PostgreSQL. Скрипт persistence перезапускает PostgreSQL, обе API-реплики и LB; failover script останавливает только реплику, hostname которой совпадает с переданным `TARGET_INSTANCE_ID`. RPS failover-сценариев: `130 / 15 = 8,667 RPS` для `api-b` и `129 / 15 = 8,600 RPS` для `api-a`. Rolling update длился 12,239 с: `380 / 12,239 = 31,048 RPS`. Это показатели проверок отказа, не capacity-тест.
## Эксперименты и отказы ## Уровень 5, трек 1 — цена масштабирования
Для уровня 3 проведены два 15-секундных сценария публичного `resilience.py` с его встроенным closed-loop потоком POST сообщений; это не нагрузочный бенчмарк. Параметры и ограничения генератора описаны в `tests/README.md`. Приведённые ниже данные и график получены 14.10.2026 с Nginx на версии `f2c4395`. Они не являются замерами HAProxy. После исправления readiness текущая команда `make track1` запускает HAProxy с активными проверками; для сравнения новой конфигурации требуется отдельная серия измерений.
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных | ### Гипотеза
| --- | --- | --- | --- |
| Остановка api-b | Новые записи возобновляются не позднее 10 с, подтверждённые данные и сессия сохраняются | 130 успешных записей, 0 ошибок | 0,545 с / потерь не выявлено публичным тестом | При фиксированных суммарных ресурсах API (2 CPU / 1024 MiB) деление сервиса на две или четыре реплики не даст роста throughput, если PostgreSQL с лимитом 0,75 CPU станет ограничивающим компонентом. Увеличение только API-бюджета до 4 CPU / 2048 MiB также не должно помочь, пока лимит PostgreSQL не меняется.
| Остановка api-a | То же после восстановления api-b | 129 успешных записей, 0 ошибок | 0,559 с / потерь не выявлено публичным тестом |
### Методика
Для эксперимента добавлен [compose.benchmark.yaml](compose.benchmark.yaml). Он создаёт отдельный проект `mtusi2026lab3bench`: LB опубликован на `:8081`, PostgreSQL использует отдельный volume, API масштабируется параметром `--scale`.
Скрипт [student-tests/track1_benchmark.py](student-tests/track1_benchmark.py) для каждой точки:
1. удаляет только временный volume benchmark-проекта;
2. запускает PostgreSQL, миграцию, заданное число API и LB;
3. запускает [tests/load.py](tests/load.py): 32 параллельных closed-loop клиента в течение 15 секунд отправляют POST сообщений без автоматических повторов;
4. примерно раз в секунду сохраняет `docker stats` всех benchmark-контейнеров;
5. записывает конфигурацию, метрики нагрузки и сэмплы ресурсов в JSON.
Порядок серий определён в [scripts/run-track1.sh](scripts/run-track1.sh). График строит [student-tests/render_track1_svg.py](student-tests/render_track1_svg.py). Все первичные данные находятся в [evidence/track1/raw](evidence/track1/raw).
### Результаты
Во всех точках используются одинаковые нагрузка и БД: 32 клиента, 15 секунд, POST сообщения; PostgreSQL — 0,75 CPU / 512 MiB, Nginx — 0,25 CPU / 128 MiB. RPS — число только успешно завершённых POST в секунду.
| Серия | API-реплики | CPU/RAM одной API | Суммарно API CPU/RAM | Успешные RPS | Ошибки | p95, мс | PostgreSQL CPU: среднее / максимум | LB CPU: среднее / максимум | Первичные данные |
| --- | ---: | --- | --- | ---: | ---: | ---: | --- | --- | --- |
| fixed-1 | 1 | 2 / 1024 MiB | 2 / 1024 MiB | 815,779 | 0 | 81,883 | 55,7% / 74,0% | 8,0% / 12,0% | [fixed-1.json](evidence/track1/raw/fixed-1.json) |
| fixed-2 | 2 | 1 / 512 MiB | 2 / 1024 MiB | 580,271 | 0 | 99,430 | 60,0% / 75,4% | 9,8% / 15,6% | [fixed-2.json](evidence/track1/raw/fixed-2.json) |
| fixed-4 | 4 | 0,5 / 256 MiB | 2 / 1024 MiB | 530,744 | 0 | 103,385 | 59,7% / 77,2% | 8,6% / 15,1% | [fixed-4.json](evidence/track1/raw/fixed-4.json) |
| growth-2 | 2 | 2 / 1024 MiB | 4 / 2048 MiB | 576,230 | 0 | 98,983 | 63,1% / 76,6% | 9,6% / 15,3% | [growth-2.json](evidence/track1/raw/growth-2.json) |
| growth-4 | 4 | 1 / 512 MiB | 4 / 2048 MiB | 503,443 | 0 | 103,761 | 69,2% / 77,3% | 9,6% / 16,7% | [growth-4.json](evidence/track1/raw/growth-4.json) |
![График successful RPS](evidence/track1/scale.svg)
### Анализ saturation point
1. При фиксированном API-бюджете максимальный результат показала одна реплика: 815,779 RPS. Две и четыре реплики показали 580,271 и 530,744 RPS соответственно.
2. Увеличение API-бюджета с 2 CPU / 1024 MiB до 4 CPU / 2048 MiB не увеличило RPS для многорепличных конфигураций: `580,271 → 576,230` для двух реплик и `530,744 → 503,443` для четырёх.
3. Во всех многорепличных сериях максимум PostgreSQL находится около его лимита 0,75 CPU: 75,4–77,3%. Максимум CPU Nginx — 16,7%, что ниже его лимита 0,25 CPU; данные не подтверждают насыщение LB.
4. В `fixed-4` нагрузку получают все API-контейнеры: их средний CPU составляет 24,4%, 24,8%, 28,5% и 27,2%; эти значения сохранены в [fixed-4.json](evidence/track1/raw/fixed-4.json). Поэтому отсутствие роста не объясняется маршрутизацией трафика на единственную реплику.
Следовательно, в этой измеренной конфигурации наиболее подтверждённое ограничение — CPU PostgreSQL. Добавление API после этой точки не повышает throughput, потому что каждая операция записи использует общую БД.
### Подтверждённое улучшение
Для данного профиля улучшенной конфигурацией стала одна API-реплика с 2 CPU / 1024 MiB вместо четырёх API по 0,5 CPU / 256 MiB при одинаковом суммарном бюджете. Расчёт по successful RPS:
```text
(815,779 − 530,744) / 530,744 × 100 = 53,7%
```
Это улучшение подтверждено первичными данными [fixed-1.json](evidence/track1/raw/fixed-1.json) и [fixed-4.json](evidence/track1/raw/fixed-4.json), но не является универсальным правилом: на каждую точку выполнен один запуск.
## Ограничения и следующие шаги ## Ограничения и следующие шаги
Стенд выдерживает отказ одного API-процесса и перезапуск используемых stores с сохранёнными volumes. Он не заявляет выживание отказа host, Nginx или PostgreSQL: эти компоненты существуют в единственном экземпляре. Nginx использует passive failover; отдельная активная проверка backend на уровне LB не реализована. Уровни 4 и 5 не заявлены. - Нагрузочный генератор closed-loop; он может быть ограничен клиентом и допускает coordinated omission. Latency в JSON относится только к успешным операциям.
- Каждая точка длится 15 секунд и выполнена один раз. Для статистического вывода нужны повторы, более длинные прогоны и доверительные интервалы.
- `docker stats` снимается примерно раз в секунду: этого достаточно для наблюдения CPU-лимита, но недостаточно для анализа SQL, lock waits и ожиданий пула соединений.
- PostgreSQL и HAProxy существуют в одном экземпляре. Стенд не заявляет выживание отказа host, LB или PostgreSQL.
## Исправления по ревью 16.10.2026
Результаты: [review-regressions-2026-10-16.txt](evidence/review-regressions-2026-10-16.txt). Новые регрессии, smoke, идемпотентность и persistence прошли. Rolling update: 318 успешных записей и 1 ошибка за 12,26 с; подтверждённые сообщения сохранены. Краткая ошибка до обнаружения остановленной реплики допустима, отсутствие ошибок во время замены не заявляется.
- Bearer с не-ASCII символами отклоняется до вычисления ASCII-хеша: 401, `WWW-Authenticate: Bearer …`, контрактный Error.
- Ошибки декодирования тела, которые FastAPI передаёт как HTTPException, преобразуются в Error. Для байта FF в JSON: 400, `invalid_request`, одинаковый request ID в теле и заголовке.
- Вместо passive-only Nginx применяется HAProxy с активным опросом готовности. Проверка зависимости от БД исключает API, даже если её процесс и `/health/live` продолжают работать.
Воспроизведение:
```sh
docker compose up -d --build --wait
python3 student-tests/review_regressions.py
python3 student-tests/readiness_failover.py
make test
make test-rolling
```
[readiness_failover.py](student-tests/readiness_failover.py) временно запрещает подключения IP api-a через pg_hba, закрывает её существующие подключения, проверяет 503 у api-a и 200 у api-b, затем выполняет 40 liveness-запросов и 20 регистраций через LB. В блоке finally восстанавливает исходный pg_hba, после чего проверяет возврат обеих реплик в балансировку. Запускать на учебном стенде, отдельно от других тестов отказа.
+102
View File
@@ -0,0 +1,102 @@
x-api: &api
build:
context: .
environment:
APP_HOST: 0.0.0.0
APP_PORT: 8080
APP_ENV: benchmark
DATABASE_URL_FILE: /run/secrets/database_url
SESSION_TTL_SECONDS: ${SESSION_TTL_SECONDS:-3600}
IDEMPOTENCY_TTL_SECONDS: ${IDEMPOTENCY_TTL_SECONDS:-86400}
CURSOR_SECRET_FILE: /run/secrets/cursor_secret
secrets:
- database_url
- cursor_secret
depends_on:
migrate:
condition: service_completed_successfully
expose:
- "8080"
healthcheck:
test: ["CMD", "/app/.venv/bin/python", "-c", "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=2).read()"]
interval: 5s
timeout: 3s
retries: 12
start_period: 10s
deploy:
resources:
limits:
cpus: "${BENCH_API_CPUS}"
memory: ${BENCH_API_MEMORY}
services:
postgres:
image: postgres:17.6-alpine
environment:
POSTGRES_DB: messenger
POSTGRES_USER: messenger
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
interval: 5s
timeout: 3s
retries: 12
start_period: 5s
deploy:
resources:
limits:
cpus: "${BENCH_DB_CPUS:-0.75}"
memory: ${BENCH_DB_MEMORY:-512M}
migrate:
build:
context: .
command: ["/app/.venv/bin/python", "-m", "src.migrate"]
environment:
DATABASE_URL_FILE: /run/secrets/database_url
CURSOR_SECRET_FILE: /run/secrets/cursor_secret
secrets:
- database_url
- cursor_secret
depends_on:
postgres:
condition: service_healthy
api:
<<: *api
load_balancer:
image: haproxy:3.0.11-alpine
ports:
- "8081:8080"
volumes:
- ./infra/haproxy.benchmark.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on:
api:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "wget -q -O /dev/null http://127.0.0.1:8080/health/ready"]
interval: 5s
timeout: 3s
retries: 12
start_period: 5s
deploy:
resources:
limits:
cpus: "${BENCH_LB_CPUS:-0.25}"
memory: ${BENCH_LB_MEMORY:-128M}
secrets:
postgres_password:
file: ./secrets/postgres_password
database_url:
file: ./secrets/database_url
cursor_secret:
file: ./secrets/cursor_secret
volumes:
postgres_data:
+22 -2
View File
@@ -24,6 +24,11 @@ x-api: &api
timeout: 3s timeout: 3s
retries: 12 retries: 12
start_period: 10s start_period: 10s
deploy:
resources:
limits:
cpus: "0.50"
memory: 256M
services: services:
postgres: postgres:
@@ -42,6 +47,11 @@ services:
timeout: 3s timeout: 3s
retries: 12 retries: 12
start_period: 5s start_period: 5s
deploy:
resources:
limits:
cpus: "0.75"
memory: 512M
migrate: migrate:
build: build:
@@ -57,6 +67,11 @@ services:
postgres: postgres:
condition: service_healthy condition: service_healthy
restart: "no" restart: "no"
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
api-a: api-a:
<<: *api <<: *api
@@ -65,11 +80,11 @@ services:
<<: *api <<: *api
load_balancer: load_balancer:
image: nginx:1.27.5-alpine image: haproxy:3.0.11-alpine
ports: ports:
- "8080:8080" - "8080:8080"
volumes: volumes:
- ./infra/nginx.conf:/etc/nginx/conf.d/default.conf:ro - ./infra/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
depends_on: depends_on:
api-a: api-a:
condition: service_healthy condition: service_healthy
@@ -81,6 +96,11 @@ services:
timeout: 3s timeout: 3s
retries: 12 retries: 12
start_period: 5s start_period: 5s
deploy:
resources:
limits:
cpus: "0.25"
memory: 128M
secrets: secrets:
postgres_password: postgres_password:
+1 -1
View File
@@ -1,6 +1,6 @@
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh $ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
Executing explicit failover hook; hook output suppressed to avoid leaking secrets. Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 129, "failed_attempts": 0, "first_recovery_seconds": 0.559} {"observed_instances_before": 2, "successful_writes": 129, "failed_attempts": 0, "first_recovery_seconds": 0.567}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
After the hook, `docker compose ps` showed api-b running and api-a stopped. api-a was then started and reached health=healthy. After the hook, `docker compose ps` showed api-b running and api-a stopped. api-a was then started and reached health=healthy.
+1 -1
View File
@@ -1,6 +1,6 @@
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh $ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
Executing explicit failover hook; hook output suppressed to avoid leaking secrets. Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 130, "failed_attempts": 0, "first_recovery_seconds": 0.545} {"observed_instances_before": 2, "successful_writes": 130, "failed_attempts": 0, "first_recovery_seconds": 0.765}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence. PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
After the hook, `docker compose ps` showed api-a running and api-b stopped. api-b was then started and reached health=healthy. After the hook, `docker compose ps` showed api-a running and api-b stopped. api-b was then started and reached health=healthy.
+5
View File
@@ -0,0 +1,5 @@
$ docker inspect --format '{{.Name}} cpu_nano={{.HostConfig.NanoCpus}} memory_bytes={{.HostConfig.Memory}}' <containers>
/mtusi2026lab3-api-a-1 cpu_nano=500000000 memory_bytes=268435456
/mtusi2026lab3-api-b-1 cpu_nano=500000000 memory_bytes=268435456
/mtusi2026lab3-postgres-1 cpu_nano=750000000 memory_bytes=536870912
/mtusi2026lab3-load_balancer-1 cpu_nano=250000000 memory_bytes=134217728
@@ -0,0 +1,30 @@
Review fixes, 2026-10-16. API behind haproxy:3.0.11-alpine.
$ python3 student-tests/review_regressions.py
PASS: non-ASCII Bearer returns 401/challenge; malformed JSON returns contract Error/400
$ python3 student-tests/readiness_failover.py
PASS: api-a ready=503, api-b ready=200; 40/40 live and 20/20 registrations use api-b
PASS: database access restored; both API replicas returned to LB
$ make test
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
$ python3 student-tests/idempotency_concurrency.py
PASS: concurrent idempotency through load balancer
$ make test-rolling
{"instances_before": 2, "instances_after": 2, "successful_writes": 318, "failed_writes": 1, "elapsed_seconds": 12.26, "successful_rps": 25.938, "successful_latency_ms": {"p50": 6.652, "p95": 13.944, "p99": 50.718}}
PASS: sequential API replacement preserved writes through load balancer
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
$ make check
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make validate PYTHON=.venv/bin/python
PASS: full OpenAPI 3.1 and JSON Schema validation; application NOT tested.
Final docker compose ps: api-a, api-b, load_balancer and postgres healthy.
Historical track1 results were NOT rerun and refer to Nginx, not HAProxy.
+4
View File
@@ -0,0 +1,4 @@
$ make test-rolling
python3 student-tests/rolling_update.py --base-url "http://localhost:8080"
{"instances_before": 2, "instances_after": 2, "successful_writes": 380, "failed_writes": 0, "elapsed_seconds": 12.239, "successful_rps": 31.048, "successful_latency_ms": {"p50": 6.288, "p95": 12.973, "p99": 55.053}}
PASS: sequential API replacement preserved writes through load balancer
+262
View File
@@ -0,0 +1,262 @@
{
"label": "fixed-1",
"topology": {
"api_replicas": 1,
"api_cpu_per_replica": "2.0",
"api_memory_per_replica": "1024M",
"api_cpu_total": 2.0,
"api_memory_total_mib": 1024,
"database_cpu": "0.75",
"database_memory": "512M",
"load_balancer_cpu": "0.25",
"load_balancer_memory": "128M"
},
"load": {
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 15.067,
"concurrency": 32,
"successful_requests": 12291,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 815.779,
"successful_latency_ms": {
"p50": 31.692,
"p95": 81.883,
"p99": 99.112
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
},
"docker_stats_samples": [
{
"at_seconds": 49856.203,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "98.16%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.66%",
"MemUsage": "47.73MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.25MB / 3.9MB",
"PIDs": "30"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "9.78%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.69%",
"MemUsage": "11.12MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "2.28MB / 2.41MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 58.5MB",
"CPUPerc": "29.31%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "9.86%",
"MemUsage": "50.51MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "1.05MB / 793kB",
"PIDs": "16"
}
]
},
{
"at_seconds": 49859.232,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "108.66%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.70%",
"MemUsage": "48.17MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "9.17MB / 11.1MB",
"PIDs": "30"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "12.00%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.93%",
"MemUsage": "11.43MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "6.49MB / 6.79MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 89MB",
"CPUPerc": "65.14%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "10.31%",
"MemUsage": "52.8MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "6.56MB / 4.96MB",
"PIDs": "16"
}
]
},
{
"at_seconds": 49862.267,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "82.08%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.77%",
"MemUsage": "48.81MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "12.7MB / 15.4MB",
"PIDs": "30"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.96%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.95%",
"MemUsage": "11.46MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "9.01MB / 9.36MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 140MB",
"CPUPerc": "73.64%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "10.87%",
"MemUsage": "55.66MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "12.8MB / 9.68MB",
"PIDs": "16"
}
]
},
{
"at_seconds": 49865.301,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "64.17%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.77%",
"MemUsage": "48.86MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "18MB / 22MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.09%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.66%",
"MemUsage": "11.09MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "12.9MB / 13.3MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 153MB",
"CPUPerc": "73.96%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "11.10%",
"MemUsage": "56.85MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "15.3MB / 11.6MB",
"PIDs": "16"
}
]
},
{
"at_seconds": 49868.334,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "59.01%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.76%",
"MemUsage": "48.77MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "20.3MB / 25MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "7.07%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.89%",
"MemUsage": "11.38MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "15.4MB / 15.8MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 176MB",
"CPUPerc": "73.72%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "11.66%",
"MemUsage": "59.7MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "19.5MB / 14.8MB",
"PIDs": "16"
}
]
},
{
"at_seconds": 49871.369,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "13.04%",
"Container": "3102616c2229fa51599408feade99a8b100221c2010bbef189a109ba08c9945e",
"ID": "3102616c2229",
"MemPerc": "4.74%",
"MemUsage": "48.54MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "22.6MB / 27.9MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "1.85%",
"Container": "171664a94f65c834d5a4aed6788677526142ddc3e4b2479685fc473b1054bf05",
"ID": "171664a94f65",
"MemPerc": "8.20%",
"MemUsage": "10.5MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "16.3MB / 16.7MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 183MB",
"CPUPerc": "18.52%",
"Container": "25ad43fd92ecbefa3123612afe34cc47b99e94fc12c5c8d9835f4ce82a8f9a63",
"ID": "25ad43fd92ec",
"MemPerc": "11.63%",
"MemUsage": "59.54MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "20.6MB / 15.7MB",
"PIDs": "16"
}
]
}
],
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second."
}
+328
View File
@@ -0,0 +1,328 @@
{
"label": "fixed-2",
"topology": {
"api_replicas": 2,
"api_cpu_per_replica": "1.0",
"api_memory_per_replica": "512M",
"api_cpu_total": 2.0,
"api_memory_total_mib": 1024,
"database_cpu": "0.75",
"database_memory": "512M",
"load_balancer_cpu": "0.25",
"load_balancer_memory": "128M"
},
"load": {
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 15.031,
"concurrency": 32,
"successful_requests": 8722,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 580.271,
"successful_latency_ms": {
"p50": 66.028,
"p95": 99.43,
"p99": 110.211
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
},
"docker_stats_samples": [
{
"at_seconds": 49950.007,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "57.55%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "8.73%",
"MemUsage": "44.71MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "1.55MB / 1.86MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "57.76%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "8.64%",
"MemUsage": "44.25MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "1.16MB / 1.38MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "15.61%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "9.23%",
"MemUsage": "11.82MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "1.9MB / 1.97MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 56.8MB",
"CPUPerc": "47.28%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "14.31%",
"MemUsage": "73.27MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "824kB / 632kB",
"PIDs": "26"
}
]
},
{
"at_seconds": 49953.036,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "46.48%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "8.78%",
"MemUsage": "44.96MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.21MB / 3.86MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "57.48%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "8.77%",
"MemUsage": "44.91MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "2.93MB / 3.5MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "13.20%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "9.02%",
"MemUsage": "11.54MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "4.92MB / 5.05MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 80MB",
"CPUPerc": "75.25%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "14.74%",
"MemUsage": "75.46MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "6.1MB / 4.73MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 49956.072,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "38.38%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "9.02%",
"MemUsage": "46.18MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "6.03MB / 7.28MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "41.71%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "8.90%",
"MemUsage": "45.55MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "3.97MB / 4.74MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "11.49%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "8.99%",
"MemUsage": "11.51MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "6.72MB / 6.87MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 110MB",
"CPUPerc": "75.42%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "15.16%",
"MemUsage": "77.61MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "9.24MB / 7.19MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 49959.112,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "51.47%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "8.99%",
"MemUsage": "46.03MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "7.14MB / 8.62MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "35.08%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "8.97%",
"MemUsage": "45.93MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "5.67MB / 6.78MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "9.03%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "9.04%",
"MemUsage": "11.57MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "9.53MB / 9.71MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 122MB",
"CPUPerc": "74.80%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "15.35%",
"MemUsage": "78.59MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "11.8MB / 9.17MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 49962.154,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "35.06%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "9.14%",
"MemUsage": "46.79MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "8.63MB / 10.4MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "33.37%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "9.03%",
"MemUsage": "46.21MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "6.7MB / 8MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "9.19%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "9.10%",
"MemUsage": "11.65MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "10.7MB / 10.9MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 128MB",
"CPUPerc": "75.30%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "15.49%",
"MemUsage": "79.31MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "13.2MB / 10.3MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 49965.205,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.29%",
"Container": "ea1aa235fcefcecfb8ac05be6d656bb9e5df6138bf761180c1b94c48b533de0f",
"ID": "ea1aa235fcef",
"MemPerc": "9.04%",
"MemUsage": "46.29MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "9.59MB / 11.6MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "4.63%",
"Container": "5cbbc0046dc1aeac6d9fd2dbea66268aa1c64ee8af76301972ee6f1987574df2",
"ID": "5cbbc0046dc1",
"MemPerc": "9.02%",
"MemUsage": "46.2MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "7.08MB / 8.46MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.00%",
"Container": "079b10b046fd16613076c6a14068871e3059723c27b8ae82fdb66363469dd49d",
"ID": "079b10b046fd",
"MemPerc": "8.30%",
"MemUsage": "10.62MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "11.9MB / 12.1MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 135MB",
"CPUPerc": "11.96%",
"Container": "a4acbfe434715cea38be5be954db7dc98738ff6098957c911e006fbbd34a2cd9",
"ID": "a4acbfe43471",
"MemPerc": "15.52%",
"MemUsage": "79.46MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "14.7MB / 11.5MB",
"PIDs": "26"
}
]
}
],
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second."
}
+460
View File
@@ -0,0 +1,460 @@
{
"label": "fixed-4",
"topology": {
"api_replicas": 4,
"api_cpu_per_replica": "0.5",
"api_memory_per_replica": "256M",
"api_cpu_total": 2.0,
"api_memory_total_mib": 1024,
"database_cpu": "0.75",
"database_memory": "512M",
"load_balancer_cpu": "0.25",
"load_balancer_memory": "128M"
},
"load": {
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 15.043,
"concurrency": 32,
"successful_requests": 7984,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 530.744,
"successful_latency_ms": {
"p50": 77.811,
"p95": 103.385,
"p99": 148.349
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
},
"docker_stats_samples": [
{
"at_seconds": 50011.66,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "10.92%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "41.54%",
"MemUsage": "106.3MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "5.54kB / 3.62kB",
"PIDs": "7"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "7.17%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "16.85%",
"MemUsage": "43.13MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "19.5kB / 21.5kB",
"PIDs": "9"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "27.10%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "16.76%",
"MemUsage": "42.91MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "18.8kB / 12.9kB",
"PIDs": "8"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "29.05%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "16.75%",
"MemUsage": "42.88MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "22.2kB / 17.7kB",
"PIDs": "8"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.79%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "8.16%",
"MemUsage": "10.45MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "37kB / 36.9kB",
"PIDs": "11"
},
{
"BlockIO": "0B / 53.1MB",
"CPUPerc": "7.44%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "13.91%",
"MemUsage": "71.24MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "59.4kB / 46.4kB",
"PIDs": "38"
}
]
},
{
"at_seconds": 50014.717,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "40.67%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "17.25%",
"MemUsage": "44.16MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "1.13MB / 1.35MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "42.75%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "22.36%",
"MemUsage": "57.25MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "938kB / 1.12MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "35.06%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "17.09%",
"MemUsage": "43.75MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "718kB / 853kB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "40.03%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "17.33%",
"MemUsage": "44.36MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "1.17MB / 1.41MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "15.05%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "9.05%",
"MemUsage": "11.59MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "3.05MB / 3.08MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 65MB",
"CPUPerc": "74.15%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "20.67%",
"MemUsage": "105.8MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "3.8MB / 2.97MB",
"PIDs": "40"
}
]
},
{
"at_seconds": 50017.772,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "25.86%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "17.39%",
"MemUsage": "44.51MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "2.02MB / 2.43MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "29.49%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "17.37%",
"MemUsage": "44.48MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "1.62MB / 1.94MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "28.21%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "17.32%",
"MemUsage": "44.34MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "1.7MB / 2.04MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "28.33%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "17.43%",
"MemUsage": "44.61MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "1.83MB / 2.21MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "11.36%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "9.05%",
"MemUsage": "11.59MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "5.49MB / 5.53MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 74.3MB",
"CPUPerc": "73.81%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "20.96%",
"MemUsage": "107.3MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "6.77MB / 5.34MB",
"PIDs": "40"
}
]
},
{
"at_seconds": 50020.818,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "34.36%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "21.01%",
"MemUsage": "53.8MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "2.58MB / 3.11MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "33.33%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "17.31%",
"MemUsage": "44.31MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "2.29MB / 2.73MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "26.22%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "17.28%",
"MemUsage": "44.23MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "2.73MB / 3.27MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "28.90%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "17.48%",
"MemUsage": "44.74MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "2.93MB / 3.52MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "10.15%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "9.33%",
"MemUsage": "11.94MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "7.71MB / 7.75MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 99.3MB",
"CPUPerc": "77.21%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "21.83%",
"MemUsage": "111.8MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "9.47MB / 7.5MB",
"PIDs": "41"
}
]
},
{
"at_seconds": 50023.862,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "21.34%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "17.50%",
"MemUsage": "44.8MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.48MB / 4.18MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "21.42%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "17.60%",
"MemUsage": "45.06MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "2.81MB / 3.34MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "21.12%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "17.38%",
"MemUsage": "44.48MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "3.38MB / 4.05MB",
"PIDs": "10"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "23.01%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "17.41%",
"MemUsage": "44.57MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "3.38MB / 4.05MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.97%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "9.13%",
"MemUsage": "11.69MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "9.5MB / 9.53MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 106MB",
"CPUPerc": "74.17%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "21.96%",
"MemUsage": "112.4MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "11.6MB / 9.26MB",
"PIDs": "41"
}
]
},
{
"at_seconds": 50026.913,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "13.36%",
"Container": "c9de83048557f4f3543fff6b1ae45c4ff32258e55b34bfa97c186b7ed2db6313",
"ID": "c9de83048557",
"MemPerc": "17.50%",
"MemUsage": "44.8MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "4.05MB / 4.87MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "14.44%",
"Container": "ab974c7d1209ff627e057a2b45da1468f6ebf5d93ca84ec43fdc3d42c045aed0",
"ID": "ab974c7d1209",
"MemPerc": "17.34%",
"MemUsage": "44.39MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "3.28MB / 3.91MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "33.24%",
"Container": "29fb69623a889b2c6931dc563d9df922e706a7d3688cf8d828455686a170a643",
"ID": "29fb69623a88",
"MemPerc": "17.28%",
"MemUsage": "44.23MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "3.81MB / 4.56MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "13.81%",
"Container": "2289c938a185fe8e13260275c1b52459e605081714ec62488805a1cd4054e395",
"ID": "2289c938a185",
"MemPerc": "17.65%",
"MemUsage": "45.19MiB / 256MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "4.17MB / 4.99MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "5.36%",
"Container": "cefdec1749029335b719a085966911e628cd1451e4a9cc4ebe09e1f5fb285896",
"ID": "cefdec174902",
"MemPerc": "8.54%",
"MemUsage": "10.93MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "11MB / 11.1MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 112MB",
"CPUPerc": "51.47%",
"Container": "ee1f8206bc6cde738ff4f2f6c7d3921d14ce88c5ab28444ea20b365494e11272",
"ID": "ee1f8206bc6c",
"MemPerc": "22.74%",
"MemUsage": "116.4MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "13.5MB / 10.8MB",
"PIDs": "42"
}
]
}
],
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second."
}
+328
View File
@@ -0,0 +1,328 @@
{
"label": "growth-2",
"topology": {
"api_replicas": 2,
"api_cpu_per_replica": "2.0",
"api_memory_per_replica": "1024M",
"api_cpu_total": 4.0,
"api_memory_total_mib": 2048,
"database_cpu": "0.75",
"database_memory": "512M",
"load_balancer_cpu": "0.25",
"load_balancer_memory": "128M"
},
"load": {
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 15.103,
"concurrency": 32,
"successful_requests": 8703,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 576.23,
"successful_latency_ms": {
"p50": 65.856,
"p95": 98.983,
"p99": 107.718
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
},
"docker_stats_samples": [
{
"at_seconds": 50062.647,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "56.68%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.38%",
"MemUsage": "44.87MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "1.27MB / 1.5MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "73.97%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.37%",
"MemUsage": "44.71MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "685kB / 816kB",
"PIDs": "10"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "15.35%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "8.85%",
"MemUsage": "11.33MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "2.08MB / 2.15MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 65.3MB",
"CPUPerc": "75.66%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "14.45%",
"MemUsage": "73.98MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "2.61MB / 2.01MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 50065.676,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "56.61%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.43%",
"MemUsage": "45.38MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.03MB / 3.62MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "54.95%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.41%",
"MemUsage": "45.19MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "4.06MB / 4.9MB",
"PIDs": "13"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "12.50%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "8.83%",
"MemUsage": "11.3MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "5.06MB / 5.19MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 77.3MB",
"CPUPerc": "76.58%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "14.60%",
"MemUsage": "74.75MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "5.22MB / 4.04MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 50068.716,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "40.76%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.45%",
"MemUsage": "45.62MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "4.08MB / 4.87MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "38.86%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.50%",
"MemUsage": "46.11MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "5.97MB / 7.22MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "10.41%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "8.98%",
"MemUsage": "11.49MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "7.53MB / 7.69MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 112MB",
"CPUPerc": "74.63%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "15.10%",
"MemUsage": "77.32MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "9.3MB / 7.23MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 50071.768,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "49.39%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.49%",
"MemUsage": "46MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "5.37MB / 6.41MB",
"PIDs": "19"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "49.20%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.54%",
"MemUsage": "46.53MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "7.11MB / 8.6MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "10.81%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "8.83%",
"MemUsage": "11.3MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "8.92MB / 9.09MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 124MB",
"CPUPerc": "75.31%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "15.29%",
"MemUsage": "78.3MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "11.8MB / 9.2MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 50074.811,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "34.36%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.52%",
"MemUsage": "46.33MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "6.48MB / 7.73MB",
"PIDs": "16"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "34.82%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.58%",
"MemUsage": "46.92MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "9.01MB / 10.9MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.61%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "9.02%",
"MemUsage": "11.55MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "11.3MB / 11.5MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 134MB",
"CPUPerc": "74.73%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "15.41%",
"MemUsage": "78.92MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "13.9MB / 10.9MB",
"PIDs": "26"
}
]
},
{
"at_seconds": 50077.862,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "1.44%",
"Container": "08a18866aedbba35e2d2f3feacb76ea5ab6c7df873d53de2ad25d6b12e0f3a5b",
"ID": "08a18866aedb",
"MemPerc": "4.53%",
"MemUsage": "46.39MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "7.17MB / 8.55MB",
"PIDs": "15"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "1.09%",
"Container": "2fde0e88d902b817e869695cc08d8e55d9cec4c9102457a5ef556ea2f4556dd3",
"ID": "2fde0e88d902",
"MemPerc": "4.56%",
"MemUsage": "46.66MiB / 1GiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "9.46MB / 11.5MB",
"PIDs": "14"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.00%",
"Container": "2f83ab1f449fb22b899b06e01cf4b4873da2df789f38e8dbd69bfef358f2e3d0",
"ID": "2f83ab1f449f",
"MemPerc": "8.71%",
"MemUsage": "11.15MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "11.9MB / 12.1MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 137MB",
"CPUPerc": "1.63%",
"Container": "e5422dd2da87c184f50cc39e4055b2feaf81f3e7cfd417ac79a51ca27f708fb3",
"ID": "e5422dd2da87",
"MemPerc": "15.54%",
"MemUsage": "79.59MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "14.6MB / 11.5MB",
"PIDs": "26"
}
]
}
],
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second."
}
+460
View File
@@ -0,0 +1,460 @@
{
"label": "growth-4",
"topology": {
"api_replicas": 4,
"api_cpu_per_replica": "1.0",
"api_memory_per_replica": "512M",
"api_cpu_total": 4.0,
"api_memory_total_mib": 2048,
"database_cpu": "0.75",
"database_memory": "512M",
"load_balancer_cpu": "0.25",
"load_balancer_memory": "128M"
},
"load": {
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 15.0,
"elapsed_seconds": 15.106,
"concurrency": 32,
"successful_requests": 7605,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 503.443,
"successful_latency_ms": {
"p50": 80.463,
"p95": 103.761,
"p99": 114.564
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
},
"docker_stats_samples": [
{
"at_seconds": 50109.046,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "34.69%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.58%",
"MemUsage": "43.95MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "498kB / 591kB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "37.96%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.50%",
"MemUsage": "43.53MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "344kB / 406kB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "34.55%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.55%",
"MemUsage": "43.76MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "496kB / 591kB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "24.06%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.46%",
"MemUsage": "43.33MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "65kB / 69.7kB",
"PIDs": "10"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "16.72%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "9.15%",
"MemUsage": "11.71MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "1.26MB / 1.28MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 58MB",
"CPUPerc": "74.68%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "19.64%",
"MemUsage": "100.6MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "1.61MB / 1.26MB",
"PIDs": "38"
}
]
},
{
"at_seconds": 50112.08,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "44.21%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.63%",
"MemUsage": "44.16MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "1.47MB / 1.77MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "46.08%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.61%",
"MemUsage": "44.1MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "1.05MB / 1.25MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "28.28%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.58%",
"MemUsage": "43.93MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "1.19MB / 1.42MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "45.04%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.60%",
"MemUsage": "44.04MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "1.41MB / 1.69MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "13.11%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "9.13%",
"MemUsage": "11.69MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "3.85MB / 3.88MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 68.5MB",
"CPUPerc": "76.54%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "21.85%",
"MemUsage": "111.9MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "4.77MB / 3.79MB",
"PIDs": "42"
}
]
},
{
"at_seconds": 50115.128,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "27.65%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.68%",
"MemUsage": "44.43MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "2.08MB / 2.49MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "27.69%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.58%",
"MemUsage": "43.95MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "1.53MB / 1.81MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "25.25%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.75%",
"MemUsage": "44.78MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "2.33MB / 2.8MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "26.16%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.62%",
"MemUsage": "44.16MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "1.99MB / 2.38MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "10.39%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "8.71%",
"MemUsage": "11.15MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "6.17MB / 6.19MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 74.5MB",
"CPUPerc": "74.06%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "22.00%",
"MemUsage": "112.7MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "6.73MB / 5.35MB",
"PIDs": "42"
}
]
},
{
"at_seconds": 50118.171,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "37.90%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.73%",
"MemUsage": "44.72MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "2.8MB / 3.36MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "25.12%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.76%",
"MemUsage": "44.84MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "2.27MB / 2.68MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "24.38%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.75%",
"MemUsage": "44.81MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "3.04MB / 3.64MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "23.76%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.81%",
"MemUsage": "45.12MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "2.97MB / 3.55MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "9.31%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "8.86%",
"MemUsage": "11.34MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "8.06MB / 8.07MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 101MB",
"CPUPerc": "77.26%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "22.37%",
"MemUsage": "114.5MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "9.87MB / 7.9MB",
"PIDs": "42"
}
]
},
{
"at_seconds": 50121.23,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "20.43%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.78%",
"MemUsage": "44.93MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.64MB / 4.35MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "23.91%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.78%",
"MemUsage": "44.96MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "2.76MB / 3.25MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "20.60%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.78%",
"MemUsage": "44.98MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "3.68MB / 4.39MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "20.78%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.82%",
"MemUsage": "45.15MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "3.38MB / 4.04MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.19%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "9.06%",
"MemUsage": "11.6MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "9.74MB / 9.74MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 107MB",
"CPUPerc": "74.34%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "22.54%",
"MemUsage": "115.4MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "11.9MB / 9.56MB",
"PIDs": "42"
}
]
},
{
"at_seconds": 50124.275,
"containers": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.34%",
"Container": "1bde062cfba194c45b14228152938bbc9c004eee37b0157c687b401a2e6c4b5a",
"ID": "1bde062cfba1",
"MemPerc": "8.83%",
"MemUsage": "45.21MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-1",
"NetIO": "3.92MB / 4.68MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.35%",
"Container": "4fcb51f8e179a8c6551f0b525aac3d2fadcc39759bc7c00cd2b6e63c4c27f8fa",
"ID": "4fcb51f8e179",
"MemPerc": "8.74%",
"MemUsage": "44.73MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-2",
"NetIO": "3.01MB / 3.55MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.36%",
"Container": "af470a1de18ee088b35c87cedcaa05f9c636243f35821aa47cb8fbe4366de1a7",
"ID": "af470a1de18e",
"MemPerc": "8.78%",
"MemUsage": "44.97MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-3",
"NetIO": "3.97MB / 4.75MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.33%",
"Container": "73979dc9a0ec84166945eec696afcadc95b1ce2ad790708f968aa562a8d53605",
"ID": "73979dc9a0ec",
"MemPerc": "8.84%",
"MemUsage": "45.27MiB / 512MiB",
"Name": "mtusi2026lab3bench-api-4",
"NetIO": "3.85MB / 4.6MB",
"PIDs": "12"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "0.00%",
"Container": "c2d50c6e8f3f09a418ff6d9555d4d6f2314ce63295b4c581e03a5ef02cfa1298",
"ID": "c2d50c6e8f3f",
"MemPerc": "8.51%",
"MemUsage": "10.89MiB / 128MiB",
"Name": "mtusi2026lab3bench-load_balancer-1",
"NetIO": "10.5MB / 10.5MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 110MB",
"CPUPerc": "38.04%",
"Container": "95fe3cc1dc5a7cbf961a8395acd1e4aa3fdcb25b8d5a2ddd5ba23164bb87ccdd",
"ID": "95fe3cc1dc5a",
"MemPerc": "22.70%",
"MemUsage": "116.2MiB / 512MiB",
"Name": "mtusi2026lab3bench-postgres-1",
"NetIO": "12.8MB / 10.3MB",
"PIDs": "42"
}
]
}
],
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second."
}
+10
View File
@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" width="820" height="430" viewBox="0 0 820 430">
<style>text{font:14px sans-serif;fill:#111827} .small{font-size:11px;fill:#4b5563} .grid{stroke:#d1d5db;stroke-width:1} .legend{font-size:12px}</style>
<rect width="100%" height="100%" fill="white"/>
<text x="55" y="28" font-size="20" font-weight="bold">Track 1: successful RPS (closed-loop POST, concurrency 32)</text>
<text x="55" y="50" class="small">Blue: fixed API total 2 CPU / 1024 MiB. Green: API total 4 CPU / 2048 MiB.</text>
<line x1="55" y1="355" x2="790" y2="355" class="grid"/><text x="48" y="359" text-anchor="end">0</text><line x1="55" y1="289" x2="790" y2="289" class="grid"/><text x="48" y="293" text-anchor="end">200</text><line x1="55" y1="223" x2="790" y2="223" class="grid"/><text x="48" y="227" text-anchor="end">400</text><line x1="55" y1="156" x2="790" y2="156" class="grid"/><text x="48" y="160" text-anchor="end">600</text><line x1="55" y1="90" x2="790" y2="90" class="grid"/><text x="48" y="94" text-anchor="end">800</text>
<line x1="55" y1="355" x2="790" y2="355" stroke="#111827"/>
<rect x="70" y="85" width="90" height="270" fill="#2563eb"/><text x="115" y="77" text-anchor="middle">815.8</text><text x="115" y="375" text-anchor="middle">fixed-1</text><text x="115" y="394" text-anchor="middle" class="small">p95 81.9 ms</text><rect x="215" y="163" width="90" height="192" fill="#2563eb"/><text x="260" y="155" text-anchor="middle">580.3</text><text x="260" y="375" text-anchor="middle">fixed-2</text><text x="260" y="394" text-anchor="middle" class="small">p95 99.4 ms</text><rect x="360" y="179" width="90" height="176" fill="#2563eb"/><text x="405" y="171" text-anchor="middle">530.7</text><text x="405" y="375" text-anchor="middle">fixed-4</text><text x="405" y="394" text-anchor="middle" class="small">p95 103.4 ms</text><rect x="505" y="164" width="90" height="191" fill="#16a34a"/><text x="550" y="156" text-anchor="middle">576.2</text><text x="550" y="375" text-anchor="middle">growth-2</text><text x="550" y="394" text-anchor="middle" class="small">p95 99.0 ms</text><rect x="650" y="188" width="90" height="167" fill="#16a34a"/><text x="695" y="180" text-anchor="middle">503.4</text><text x="695" y="375" text-anchor="middle">growth-4</text><text x="695" y="394" text-anchor="middle" class="small">p95 103.8 ms</text>
<text x="55" y="405" class="small">Data: evidence/track1/raw/*.json. Each point uses a fresh database volume; DB limit 0.75 CPU / 512 MiB.</text>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

+34
View File
@@ -0,0 +1,34 @@
global
log stdout format raw local0
defaults
mode http
log global
option httplog
option forwardfor
timeout connect 1s
timeout client 30s
timeout server 10s
timeout check 2s
retries 2
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 2s
hold obsolete 2s
frontend http
bind :8080
default_backend api
backend api
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host localhost
http-check expect status 200
default-server check inter 2s fall 1 rise 2 resolvers docker resolve-prefer ipv4 init-addr libc,none
server-template api 4 api:8080
+35
View File
@@ -0,0 +1,35 @@
global
log stdout format raw local0
defaults
mode http
log global
option httplog
option forwardfor
timeout connect 1s
timeout client 30s
timeout server 10s
timeout check 2s
retries 2
resolvers docker
nameserver dns 127.0.0.11:53
resolve_retries 3
timeout resolve 1s
timeout retry 1s
hold valid 2s
hold obsolete 2s
frontend http
bind :8080
default_backend api
backend api
balance roundrobin
option httpchk
http-check send meth GET uri /health/ready ver HTTP/1.1 hdr Host localhost
http-check expect status 200
default-server check inter 2s fall 1 rise 2 resolvers docker resolve-prefer ipv4 init-addr libc,none
server api-a api-a:8080
server api-b api-b:8080
+26
View File
@@ -0,0 +1,26 @@
# Historical configuration used for evidence/track1/raw from 2026-10-14.
# Current compose.benchmark.yaml uses haproxy.benchmark.cfg.
upstream messenger_api {
zone messenger_api 64k;
resolver 127.0.0.11 valid=2s ipv6=off;
resolver_timeout 1s;
least_conn;
server api:8080 resolve max_fails=1 fail_timeout=2s;
keepalive 16;
}
server {
listen 8080;
location / {
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection "";
proxy_connect_timeout 1s;
proxy_read_timeout 5s;
proxy_next_upstream error timeout http_502 http_503 http_504;
proxy_next_upstream_tries 2;
proxy_pass http://messenger_api;
}
}
+2
View File
@@ -1,3 +1,5 @@
# Historical configuration used for evidence dated 2026-10-14.
# Current compose.yaml uses haproxy.cfg with active readiness checks.
upstream messenger_api { upstream messenger_api {
zone messenger_api 64k; zone messenger_api 64k;
resolver 127.0.0.11 valid=2s ipv6=off; resolver 127.0.0.11 valid=2s ipv6=off;
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu
# Equivalent to a rolling update for this two-replica Compose topology.
# Build the image separately; this hook only replaces one healthy API process at a time.
cd "$(dirname "$0")/.."
for service in api-a api-b; do
docker compose up -d --no-deps --force-recreate --wait "$service"
done
+13
View File
@@ -0,0 +1,13 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
# 1/2/4 replicas: identical total budget of 2 vCPU and 1024 MiB for all APIs.
python3 student-tests/track1_benchmark.py --label fixed-1 --replicas 1 --api-cpus 2.0 --api-memory 1024M
python3 student-tests/track1_benchmark.py --label fixed-2 --replicas 2 --api-cpus 1.0 --api-memory 512M
python3 student-tests/track1_benchmark.py --label fixed-4 --replicas 4 --api-cpus 0.5 --api-memory 256M
# Resource-growth series: 4 vCPU and 2048 MiB for all APIs.
python3 student-tests/track1_benchmark.py --label growth-2 --replicas 2 --api-cpus 2.0 --api-memory 1024M
python3 student-tests/track1_benchmark.py --label growth-4 --replicas 4 --api-cpus 1.0 --api-memory 512M
python3 student-tests/render_track1_svg.py
+22 -1
View File
@@ -8,6 +8,7 @@ from fastapi import FastAPI, Request
from fastapi.exceptions import RequestValidationError from fastapi.exceptions import RequestValidationError
import uvicorn import uvicorn
from starlette.responses import JSONResponse, Response from starlette.responses import JSONResponse, Response
from starlette.exceptions import HTTPException
from .errors import ApiError from .errors import ApiError
from .cursor import configure_secret from .cursor import configure_secret
@@ -30,7 +31,6 @@ def logger(name: str) -> logging.Logger:
access_logger = logger("messenger.access") access_logger = logger("messenger.access")
logger("messenger.cache")
@asynccontextmanager @asynccontextmanager
@@ -41,9 +41,11 @@ async def lifespan(application: FastAPI):
await store.connect() await store.connect()
application.state.store = store application.state.store = store
application.state.settings = settings application.state.settings = settings
application.state.accepting_requests = True
try: try:
yield yield
finally: finally:
application.state.accepting_requests = False
await store.close() await store.close()
@@ -115,6 +117,25 @@ async def handle_validation_error(
return error_response(request, 400, "invalid_request", "Некорректный запрос") return error_response(request, 400, "invalid_request", "Некорректный запрос")
@app.exception_handler(HTTPException)
async def handle_http_error(request: Request, error: HTTPException) -> JSONResponse:
"""Включает ошибки декодирования тела, возникающие до Pydantic."""
codes = {
400: "invalid_request",
401: "unauthorized",
403: "forbidden",
404: "not_found",
405: "method_not_allowed",
503: "unavailable",
}
code = codes.get(error.status_code, "internal_error")
return error_response(
request, error.status_code, code,
"Некорректный запрос" if error.status_code < 500 else "Ошибка сервера",
error.headers,
)
@app.exception_handler(Exception) @app.exception_handler(Exception)
async def handle_unexpected_error(request: Request, error: Exception) -> JSONResponse: async def handle_unexpected_error(request: Request, error: Exception) -> JSONResponse:
"""Не раскрывает внутренние детали при непредвиденной ошибке приложения.""" """Не раскрывает внутренние детали при непредвиденной ошибке приложения."""
+4 -2
View File
@@ -36,7 +36,7 @@ async def get_current_user(
if authorization is None or not authorization.startswith("Bearer "): if authorization is None or not authorization.startswith("Bearer "):
raise ApiError(401, "unauthorized", "Требуется Bearer-сессия", BEARER_CHALLENGE) raise ApiError(401, "unauthorized", "Требуется Bearer-сессия", BEARER_CHALLENGE)
token = authorization[7:] token = authorization[7:]
if not token or token.strip() != token: if not token or not token.isascii() or token.strip() != token:
raise ApiError(401, "unauthorized", "Требуется Bearer-сессия", BEARER_CHALLENGE) raise ApiError(401, "unauthorized", "Требуется Bearer-сессия", BEARER_CHALLENGE)
user = await store.user_for_token(token) user = await store.user_for_token(token)
if user is None: if user is None:
@@ -79,7 +79,9 @@ async def liveness() -> dict[str, str]:
return {"status": "ok"} return {"status": "ok"}
@router.get("/health/ready") @router.get("/health/ready")
async def readiness(store: PostgresStore = Depends(get_store)) -> dict[str, str]: async def readiness(request: Request, store: PostgresStore = Depends(get_store)) -> dict[str, str]:
if not request.app.state.accepting_requests:
raise ApiError(503, "unavailable", "API завершает работу")
await store.ready() await store.ready()
return {"status": "ok"} return {"status": "ok"}
+2
View File
@@ -138,6 +138,8 @@ class PostgresStore:
return {"token": token, "token_type": "Bearer", "expires_at": row["expires_at"], "user": user} return {"token": token, "token_type": "Bearer", "expires_at": row["expires_at"], "user": user}
async def user_for_token(self, token: str) -> dict | None: async def user_for_token(self, token: str) -> dict | None:
if not token.isascii():
return None
token_hash = sha256(token.encode("ascii")).hexdigest() token_hash = sha256(token.encode("ascii")).hexdigest()
try: try:
row = await self.pool.fetchrow( row = await self.pool.fetchrow(
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
"""Запрет БД только для api-a через pg_hba; восстановление в finally."""
import ipaddress
import json
from pathlib import Path
import subprocess
import sys
import time
import uuid
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT / "tests"))
from client import Client, check, run
def compose(*args):
return subprocess.check_output(["docker", "compose", *args], cwd=ROOT, text=True).strip()
def sql(statement):
return compose("exec", "-T", "postgres", "psql", "-U", "messenger", "-d",
"messenger", "-v", "ON_ERROR_STOP=1", "-Atc", statement)
def ready(service):
code = """import urllib.request, urllib.error
try:
print(urllib.request.urlopen('http://127.0.0.1:8080/health/ready', timeout=7).status)
except urllib.error.HTTPError as error:
print(error.code)
"""
return compose("exec", "-T", service, "/app/.venv/bin/python", "-c", code)
def main():
client = Client()
container = json.loads(subprocess.check_output(
["docker", "inspect", compose("ps", "-q", "api-a")], text=True))[0]
addresses = list(container["NetworkSettings"]["Networks"].values())
check(len(addresses) == 1, "test expects one API network")
address = str(ipaddress.IPv4Address(addresses[0]["IPAddress"]))
bad_id = container["Config"]["Hostname"]
before = {client.call("GET", "/health/live")["headers"]["X-Instance-Id"] for _ in range(40)}
check(len(before) == 2 and bad_id in before, "both API replicas must be reachable")
check(ready("api-a") == ready("api-b") == "200", "both APIs must be ready")
# Сохраняем исходный pg_hba; чужую оставшуюся резервную копию не перезаписываем.
compose("exec", "-T", "postgres", "sh", "-ec",
'test ! -e "$PGDATA/pg_hba.conf.readiness-backup"; '
'cp -p "$PGDATA/pg_hba.conf" "$PGDATA/pg_hba.conf.readiness-backup"')
try:
compose("exec", "-T", "postgres", "sh", "-ec",
'{ printf "host all all %s/32 reject\\n" "$1"; '
'cat "$PGDATA/pg_hba.conf.readiness-backup"; } > "$PGDATA/pg_hba.conf"',
"sh", address)
sql("SELECT pg_reload_conf()")
time.sleep(0.5)
sql(f"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE client_addr = '{address}'::inet")
check(ready("api-a") == "503", "api-a must be unready")
check(ready("api-b") == "200", "api-b must remain ready")
# 2s interval + 2s check timeout, с запасом на планировщик Docker Desktop.
time.sleep(6)
for _ in range(40):
result = client.call("GET", "/health/live", 200)
check(result["headers"]["X-Instance-Id"] != bad_id, "LB selected unready api-a")
for _ in range(20):
result = client.call("POST", "/api/v1/users", 201, body={
"username": "r_" + uuid.uuid4().hex[:16],
"display_name": "Readiness regression",
"password": "Test-password-" + uuid.uuid4().hex,
}, schema="User")
check(result["headers"]["X-Instance-Id"] != bad_id, "registration reached api-a")
print("PASS: api-a ready=503, api-b ready=200; 40/40 live and 20/20 registrations use api-b")
finally:
compose("exec", "-T", "postgres", "sh", "-ec",
'mv "$PGDATA/pg_hba.conf.readiness-backup" "$PGDATA/pg_hba.conf"')
sql("SELECT pg_reload_conf()")
deadline = time.monotonic() + 20
while time.monotonic() < deadline:
observed = {client.call("GET", "/health/live")["headers"]["X-Instance-Id"] for _ in range(10)}
if observed == before:
check(ready("api-a") == "200", "restored api-a must be ready")
print("PASS: database access restored; both API replicas returned to LB")
return
time.sleep(0.5)
raise AssertionError("api-a did not return to LB")
if __name__ == "__main__":
run(main)
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env python3
"""Renders Track 1 raw JSON results into a small dependency-free SVG chart."""
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
ORDER = ["fixed-1", "fixed-2", "fixed-4", "growth-2", "growth-4"]
COLORS = {"fixed": "#2563eb", "growth": "#16a34a"}
def main() -> None:
raw = ROOT / "evidence" / "track1" / "raw"
values = []
for label in ORDER:
data = json.loads((raw / f"{label}.json").read_text(encoding="utf-8"))
values.append((label, data["load"]["successful_rps"], data["load"]["successful_latency_ms"]["p95"]))
maximum = max(value for _, value, _ in values)
width, height, bottom, chart_height = 820, 430, 355, 270
bars = []
for index, (label, rps, p95) in enumerate(values):
x = 70 + index * 145
bar_height = round(rps / maximum * chart_height)
y = bottom - bar_height
color = COLORS["fixed" if label.startswith("fixed") else "growth"]
bars.append(
f'<rect x="{x}" y="{y}" width="90" height="{bar_height}" fill="{color}"/>'
f'<text x="{x + 45}" y="{y - 8}" text-anchor="middle">{rps:.1f}</text>'
f'<text x="{x + 45}" y="{bottom + 20}" text-anchor="middle">{label}</text>'
f'<text x="{x + 45}" y="{bottom + 39}" text-anchor="middle" class="small">p95 {p95:.1f} ms</text>'
)
ticks = []
for value in range(0, int(maximum) + 100, 200):
y = bottom - round(value / maximum * chart_height)
ticks.append(f'<line x1="55" y1="{y}" x2="790" y2="{y}" class="grid"/><text x="48" y="{y + 4}" text-anchor="end">{value}</text>')
svg = f'''<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}">
<style>text{{font:14px sans-serif;fill:#111827}} .small{{font-size:11px;fill:#4b5563}} .grid{{stroke:#d1d5db;stroke-width:1}} .legend{{font-size:12px}}</style>
<rect width="100%" height="100%" fill="white"/>
<text x="55" y="28" font-size="20" font-weight="bold">Track 1: successful RPS (closed-loop POST, concurrency 32)</text>
<text x="55" y="50" class="small">Blue: fixed API total 2 CPU / 1024 MiB. Green: API total 4 CPU / 2048 MiB.</text>
{''.join(ticks)}
<line x1="55" y1="{bottom}" x2="790" y2="{bottom}" stroke="#111827"/>
{''.join(bars)}
<text x="55" y="405" class="small">Data: evidence/track1/raw/*.json. Each point uses a fresh database volume; DB limit 0.75 CPU / 512 MiB.</text>
</svg>'''
destination = ROOT / "evidence" / "track1" / "scale.svg"
destination.write_text(svg + "\n", encoding="utf-8")
print(destination.relative_to(ROOT))
if __name__ == "__main__":
main()
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
"""Регрессии ревью: не-ASCII Bearer и невалидная кодировка JSON через LB."""
from pathlib import Path
import sys
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
from client import Client, arguments, check, run
def main():
args = arguments(__doc__)
client = Client(args.base_url, args.ca_file)
for path in ("/api/v1/users/me", "/api/v1/auth/sessions/current"):
method = "DELETE" if path.endswith("/current") else "GET"
result = client.call(method, path, 401,
headers={"Authorization": "Bearer é"}, schema="Error")
check(result["headers"].get("WWW-Authenticate", "").startswith("Bearer"),
"missing Bearer challenge")
check(result["json"]["error"]["code"] == "unauthorized", "wrong error code")
check(result["json"]["error"]["request_id"] == result["headers"]["X-Request-Id"],
"request IDs differ")
for raw in (b"\xff", b"{", b'{"username":'):
result = client.call("POST", "/api/v1/users", 400, raw=raw,
headers={"Content-Type": "application/json"}, schema="Error")
check(result["json"]["error"]["code"] == "invalid_request", "wrong JSON error code")
check(result["json"]["error"]["request_id"] == result["headers"]["X-Request-Id"],
"request IDs differ")
print("PASS: non-ASCII Bearer returns 401/challenge; malformed JSON returns contract Error/400")
if __name__ == "__main__":
run(main)
+100
View File
@@ -0,0 +1,100 @@
#!/usr/bin/env python3
"""Проверяет поочерёдную замену двух API-реплик под записью через LB."""
import json
import os
from pathlib import Path
import statistics
import subprocess
import sys
import time
import uuid
from urllib.parse import quote
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tests"))
from client import Client, Failure, arguments, check, run # noqa: E402
ROOT = Path(__file__).resolve().parents[1]
def history(client: Client, actor: dict, chat: dict) -> list[dict]:
path = "/api/v1/chats/" + chat["id"] + "/messages?limit=100"
messages, cursors = [], set()
while True:
page = client.call("GET", path, actor=actor, schema="MessagePage")["json"]
messages.extend(page["items"])
cursor = page["next_cursor"]
if cursor is None:
return messages
check(cursor not in cursors, "history cursor cycle after rolling update")
cursors.add(cursor)
path = "/api/v1/chats/" + chat["id"] + "/messages?limit=100&cursor=" + quote(cursor, safe="")
def main() -> None:
args = arguments("Sequential API replacement under writes")
action = ROOT / "scripts" / "rolling-update.sh"
check(action.is_file() and os.access(action, os.X_OK), "rolling-update.sh must be executable")
client = Client(args.base_url, args.ca_file, timeout=2)
alice, _bob, _eve, chat = client.bootstrap()
before = {
client.call("GET", "/api/v1/users/me", actor=alice, schema="User")["headers"]["X-Instance-Id"]
for _ in range(40)
}
check(len(before) >= 2, "less than two API instances observed before rolling update")
process = subprocess.Popen([str(action)], cwd=ROOT)
started = time.monotonic()
latencies, failures, successful = [], 0, 0
confirmed_ids = []
try:
while process.poll() is None:
check(time.monotonic() - started < 90, "rolling update hook exceeded 90 seconds")
key = uuid.uuid4().hex
began = time.monotonic()
try:
message = client.message(alice, chat, "rolling-" + key, key=key)["json"]
successful += 1
confirmed_ids.append(message["id"])
latencies.append(time.monotonic() - began)
except Failure:
failures += 1
time.sleep(0.02)
check(process.wait(timeout=5) == 0, "rolling update hook failed")
finally:
if process.poll() is None:
process.terminate()
process.wait(timeout=5)
after = {
client.call("GET", "/api/v1/users/me", actor=alice, schema="User")["headers"]["X-Instance-Id"]
for _ in range(40)
}
check(len(after) >= 2, "less than two API instances observed after rolling update")
check(before.isdisjoint(after), "old API instance remained after sequential replacement")
check(successful > 0, "no writes succeeded during rolling update")
stored_ids = {message["id"] for message in history(client, alice, chat)}
check(all(message_id in stored_ids for message_id in confirmed_ids), "confirmed write lost during rolling update")
elapsed = time.monotonic() - started
ordered = sorted(latencies)
def percentile(fraction: float) -> float | None:
if not ordered:
return None
return round(1000 * ordered[max(0, int(len(ordered) * fraction + 0.999999) - 1)], 3)
print(json.dumps({
"instances_before": len(before),
"instances_after": len(after),
"successful_writes": successful,
"failed_writes": failures,
"elapsed_seconds": round(elapsed, 3),
"successful_rps": round(successful / elapsed, 3),
"successful_latency_ms": {"p50": percentile(0.50), "p95": percentile(0.95), "p99": percentile(0.99)},
}, ensure_ascii=False))
print("PASS: sequential API replacement preserved writes through load balancer")
if __name__ == "__main__":
run(main)
+101
View File
@@ -0,0 +1,101 @@
#!/usr/bin/env python3
"""One reproducible point for Lab 3, Level 5, Track 1."""
import argparse
import json
import os
from pathlib import Path
import subprocess
import sys
import threading
import time
ROOT = Path(__file__).resolve().parents[1]
COMPOSE = ["docker", "compose", "-p", "mtusi2026lab3bench", "-f", "compose.benchmark.yaml"]
def command(arguments: list[str], environment: dict[str, str] | None = None) -> subprocess.CompletedProcess:
return subprocess.run(arguments, cwd=ROOT, env=environment, check=True, text=True)
def compose(arguments: list[str], environment: dict[str, str] | None = None) -> subprocess.CompletedProcess:
return command(COMPOSE + arguments, environment)
def stats(container_ids: list[str]) -> list[dict]:
if not container_ids:
return []
output = subprocess.check_output(
["docker", "stats", "--no-stream", "--format", "{{json .}}", *container_ids],
cwd=ROOT,
text=True,
)
return [json.loads(line) for line in output.splitlines() if line.strip()]
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--label", required=True)
parser.add_argument("--replicas", type=int, required=True)
parser.add_argument("--api-cpus", required=True)
parser.add_argument("--api-memory", required=True)
parser.add_argument("--duration", type=float, default=15)
parser.add_argument("--concurrency", type=int, default=32)
parser.add_argument("--keep", action="store_true", help="Do not remove the isolated benchmark stack")
args = parser.parse_args()
if args.replicas < 1 or args.duration < 1 or args.concurrency < 1:
parser.error("replicas, duration and concurrency must be positive")
output = ROOT / "evidence" / "track1" / "raw" / f"{args.label}.json"
output.parent.mkdir(parents=True, exist_ok=True)
environment = os.environ.copy()
environment.update({"BENCH_API_CPUS": args.api_cpus, "BENCH_API_MEMORY": args.api_memory})
compose(["down", "--volumes", "--remove-orphans"], environment)
try:
compose(["up", "--build", "--detach", "--wait", "--scale", f"api={args.replicas}"], environment)
container_ids = subprocess.check_output(
COMPOSE + ["ps", "-q"], cwd=ROOT, env=environment, text=True
).split()
samples: list[dict] = []
loading = subprocess.Popen(
[
sys.executable, "tests/load.py", "--base-url", "http://localhost:8081",
"--duration", str(args.duration), "--concurrency", str(args.concurrency),
"--output", str(output.with_suffix(".load.json")),
],
cwd=ROOT,
)
while loading.poll() is None:
samples.append({"at_seconds": round(time.monotonic(), 3), "containers": stats(container_ids)})
time.sleep(1)
if loading.wait() != 0:
raise SystemExit("load generator failed")
load = json.loads(output.with_suffix(".load.json").read_text(encoding="utf-8"))
report = {
"label": args.label,
"topology": {
"load_balancer_image": "haproxy:3.0.11-alpine",
"api_replicas": args.replicas,
"api_cpu_per_replica": args.api_cpus,
"api_memory_per_replica": args.api_memory,
"api_cpu_total": round(args.replicas * float(args.api_cpus), 3),
"api_memory_total_mib": args.replicas * int(args.api_memory.removesuffix("M")),
"database_cpu": environment.get("BENCH_DB_CPUS", "0.75"),
"database_memory": environment.get("BENCH_DB_MEMORY", "512M"),
"load_balancer_cpu": environment.get("BENCH_LB_CPUS", "0.25"),
"load_balancer_memory": environment.get("BENCH_LB_MEMORY", "128M"),
},
"load": load,
"docker_stats_samples": samples,
"method": "Fresh PostgreSQL volume for this point; closed-loop POST messages, no automatic retries; Docker stats sampled about once a second.",
}
output.write_text(json.dumps(report, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
output.with_suffix(".load.json").unlink(missing_ok=True)
print(json.dumps({"saved": str(output.relative_to(ROOT)), "load": load}, ensure_ascii=False, indent=2))
finally:
if not args.keep:
compose(["down", "--volumes", "--remove-orphans"], environment)
if __name__ == "__main__":
main()