forked from mtusi2026/mtusi2026lab3
lab3
This commit is contained in:
@@ -18,3 +18,7 @@ __pycache__
|
||||
node_modules
|
||||
evidence
|
||||
.DS_Store
|
||||
bin
|
||||
coverage.out
|
||||
coverage.out.tmp
|
||||
*.log
|
||||
|
||||
+71
-10
@@ -1,13 +1,74 @@
|
||||
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
|
||||
# These are logical interface suggestions; map actual framework names in REPORT.md.
|
||||
APP_HOST=0.0.0.0
|
||||
APP_PORT=8080
|
||||
APP_ENV=lab
|
||||
# Values below are the variables this implementation actually reads
|
||||
# (viper: section.name -> SECTION_NAME, see internal/config/config.go).
|
||||
#
|
||||
# Mapping to the logical names suggested by the skeleton:
|
||||
# APP_HOST / APP_PORT -> SERVER_HOST / SERVER_PORT
|
||||
# SESSION_STORE=postgres -> server-side sessions live in PostgreSQL (SESSION_TTL_SECONDS)
|
||||
# DATABASE_URL_FILE -> unused: POSTGRES_* below pass no secret files
|
||||
# CACHE_URL_FILE -> unused: REDIS_* below pass no secret files
|
||||
# API_REPLICAS -> number of API replicas of the stand (compose.yaml)
|
||||
#
|
||||
# APP_ENV selects config/<env>/config.yaml; the implementation supports only `dev`.
|
||||
APP_ENV=dev
|
||||
|
||||
SERVER_HOST=0.0.0.0
|
||||
SERVER_PORT=8080
|
||||
SERVER_READ_HEADER_TIMEOUT=10s
|
||||
SERVER_SHUTDOWN_TIMEOUT=10s
|
||||
|
||||
LOG_LEVEL=info
|
||||
LOG_FORMAT=json
|
||||
|
||||
# Synthetic credentials for the local stand only; override in .env for anything else.
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_DATABASE=messenger
|
||||
POSTGRES_USER=messenger
|
||||
POSTGRES_PASSWORD=messenger
|
||||
POSTGRES_SSL_MODE=disable
|
||||
POSTGRES_MAX_CONNS=10
|
||||
POSTGRES_MIN_CONNS=1
|
||||
POSTGRES_MAX_CONN_LIFETIME=1h
|
||||
POSTGRES_MAX_CONN_IDLE_TIME=30m
|
||||
POSTGRES_CONNECT_TIMEOUT=5s
|
||||
POSTGRES_QUERY_TIMEOUT=5s
|
||||
|
||||
REDIS_ENABLED=true
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
REDIS_PASSWORD=
|
||||
REDIS_DB=0
|
||||
# -1 disables go-redis retries; 0 keeps the library default (3 retries).
|
||||
REDIS_MAX_RETRIES=-1
|
||||
REDIS_DIAL_TIMEOUT=300ms
|
||||
REDIS_READ_TIMEOUT=200ms
|
||||
REDIS_WRITE_TIMEOUT=200ms
|
||||
REDIS_POOL_SIZE=10
|
||||
|
||||
CACHE_ENABLED=true
|
||||
CACHE_CHAT_LIST_TTL=5m
|
||||
CACHE_LOCK_TTL=10s
|
||||
CACHE_LOCK_WAIT_TIMEOUT=2s
|
||||
|
||||
SESSION_TTL_SECONDS=3600
|
||||
# Choose credentials locally. File paths contain no secret values.
|
||||
DATABASE_URL_FILE=/run/secrets/database_url
|
||||
# Optional on 3, required use on 4 in lab2; Redis OR Valkey:
|
||||
SESSION_STORE=postgres
|
||||
CACHE_URL_FILE=/run/secrets/cache_url
|
||||
API_REPLICAS=2
|
||||
|
||||
# Retention of a message Idempotency-Key in the shared store; contract 1.3.0
|
||||
# requires at least 24 h.
|
||||
IDEMPOTENCY_TTL_SECONDS=86400
|
||||
|
||||
# Lab3 stand (compose.yaml): number of API replicas behind the LB and per-replica
|
||||
# CPU/RAM limits. Track 1 varies them to compare 1/2/4 replicas at a fixed total
|
||||
# budget, e.g. API_REPLICAS=4 API_CPU_LIMIT=0.25 API_MEM_LIMIT=192M.
|
||||
API_REPLICAS=2
|
||||
API_CPU_LIMIT=0.50
|
||||
API_MEM_LIMIT=256M
|
||||
|
||||
# Connections of ONE API replica to PostgreSQL; the total is replicas × value.
|
||||
# Track 1 checks whether the shared connection budget becomes the saturation
|
||||
# point: at 4 replicas the default 10 means 40 connections against one database.
|
||||
POSTGRES_MAX_CONNS=10
|
||||
|
||||
# CPU quota of the shared database. Track 1 shows it is the stand's saturation
|
||||
# point: the API uses a fraction of its budget while PostgreSQL sits at its own.
|
||||
POSTGRES_CPU_LIMIT=0.50
|
||||
|
||||
@@ -45,3 +45,33 @@ jobs:
|
||||
context: .
|
||||
push: false
|
||||
tags: mtusi-messenger:ci
|
||||
|
||||
stand:
|
||||
name: Lab3 stand scenario
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: cp .env.example .env
|
||||
- run: docker compose --env-file .env config --quiet
|
||||
- run: docker compose --env-file .env up -d --build
|
||||
- name: Wait for readiness through the load balancer
|
||||
run: |
|
||||
for attempt in $(seq 1 60); do
|
||||
if curl -fsS -o /dev/null http://localhost:8080/health/ready; then exit 0; fi
|
||||
sleep 2
|
||||
done
|
||||
docker compose --env-file .env ps
|
||||
exit 1
|
||||
- name: Public smoke through the LB
|
||||
run: make test
|
||||
- name: Parallel idempotency through the LB
|
||||
run: python3 student-tests/idempotency_parallel.py --base-url http://localhost:8080
|
||||
- name: Stop one API replica and keep writing
|
||||
run: make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
- name: Logs on failure
|
||||
if: failure()
|
||||
run: docker compose --env-file .env logs --tail 100
|
||||
- if: always()
|
||||
run: docker compose --env-file .env down -v
|
||||
|
||||
@@ -24,6 +24,8 @@ target/
|
||||
bin/
|
||||
obj/
|
||||
coverage/
|
||||
coverage.out
|
||||
coverage.out.tmp
|
||||
*.log
|
||||
.DS_Store
|
||||
.idea/
|
||||
|
||||
+14
-2
@@ -4,8 +4,14 @@ ARG GO_VERSION=1.27.1
|
||||
ARG ALPINE_VERSION=3.22
|
||||
|
||||
FROM golang:${GO_VERSION}-alpine AS build
|
||||
ARG TARGETOS=linux
|
||||
ARG TARGETARCH=amd64
|
||||
# Platform of the produced binaries. Left empty on purpose: the classic builder
|
||||
# does not supply these args, and the previous hardcoded `amd64` default silently
|
||||
# produced x86-64 binaries inside an arm64 image. Those ran under emulation and
|
||||
# the Go runtime crashed under load (fatals like "found pointer to free object").
|
||||
# Empty means "build for the builder's own platform"; cross-compile explicitly:
|
||||
# docker build --build-arg TARGETARCH=amd64 ...
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ARG VERSION=dev
|
||||
ENV GOTOOLCHAIN=local
|
||||
WORKDIR /opt
|
||||
@@ -13,6 +19,12 @@ WORKDIR /opt
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
# The Go compiler spikes well above 1 GiB per package on large dependencies, so
|
||||
# an unbounded parallel build OOMs small Docker VMs and CI runners. Cap
|
||||
# parallelism; override with --build-arg GOFLAGS=-p=$(nproc) on a bigger host.
|
||||
ARG GOFLAGS="-p=2"
|
||||
ENV GOFLAGS=$GOFLAGS
|
||||
|
||||
COPY . .
|
||||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
|
||||
go build -trimpath -buildvcs=false -tags timetzdata \
|
||||
|
||||
@@ -3,11 +3,13 @@ BASE_URL ?= http://localhost:8080
|
||||
CA_FILE ?=
|
||||
ACTION_SCRIPT ?=
|
||||
TLS_ARGS = $(if $(CA_FILE),--ca-file "$(CA_FILE)",)
|
||||
PYTHON_LOCAL = env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 $(PYTHON)
|
||||
|
||||
.PHONY: help check validate test load test-persistence test-failover
|
||||
.PHONY: help check validate test load test-persistence test-failover smoke-local load-local test-idempotency test-lb-readiness up down ps logs
|
||||
|
||||
help:
|
||||
@echo "check: offline structure; validate: full OpenAPI (requirements-dev.txt); test: running API; load: synthetic writes"
|
||||
@echo "up/down/ps/logs: lab3 stand from compose.yaml (LB + API_REPLICAS replicas + stores)"
|
||||
|
||||
check:
|
||||
$(PYTHON) scripts/check_contract.py
|
||||
@@ -28,3 +30,118 @@ test-persistence:
|
||||
test-failover:
|
||||
@test -n "$(ACTION_SCRIPT)" || (echo "Set ACTION_SCRIPT to your implemented executable stop-one hook"; exit 2)
|
||||
$(PYTHON) tests/resilience.py --mode failover --action-script "$(ACTION_SCRIPT)" --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
# Локальный запуск без прокси: в окружении автора HTTP(S)_PROXY ломает localhost.
|
||||
smoke-local:
|
||||
$(PYTHON_LOCAL) tests/smoke.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
load-local:
|
||||
$(PYTHON_LOCAL) tests/load.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
# Собственная проверка уровня 4: параллельные повторы одного Idempotency-Key
|
||||
# через LB обязаны создать ровно одно сообщение.
|
||||
test-idempotency:
|
||||
$(PYTHON_LOCAL) student-tests/idempotency_parallel.py --base-url "$(BASE_URL)" $(TLS_ARGS)
|
||||
|
||||
# Собственная проверка уровня 4: LB обязан убрать из ротации реплику, которая
|
||||
# осталась доступной, но потеряла БД (readiness 503).
|
||||
test-lb-readiness:
|
||||
scripts/lb_readiness_check.sh
|
||||
|
||||
COMPOSE_BIN ?= docker compose
|
||||
COMPOSE_FILE ?= compose.yaml
|
||||
ENV_FILE ?= .env
|
||||
|
||||
up:
|
||||
$(COMPOSE_BIN) --env-file $(ENV_FILE) -f $(COMPOSE_FILE) up -d --build
|
||||
|
||||
down:
|
||||
$(COMPOSE_BIN) --env-file $(ENV_FILE) -f $(COMPOSE_FILE) down
|
||||
|
||||
ps:
|
||||
$(COMPOSE_BIN) --env-file $(ENV_FILE) -f $(COMPOSE_FILE) ps
|
||||
|
||||
logs:
|
||||
$(COMPOSE_BIN) --env-file $(ENV_FILE) -f $(COMPOSE_FILE) logs -f --tail 100
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
GO ?= go
|
||||
APP_NAME ?= messenger
|
||||
CMD_PKG := ./cmd/$(APP_NAME)
|
||||
LOCAL_BIN := $(CURDIR)/bin
|
||||
GOLANGCI_LINT_VERSION ?= v2.13.2
|
||||
GOLANGCI_LINT := $(LOCAL_BIN)/golangci-lint
|
||||
OPENAPI_SPEC := contracts/openapi.json
|
||||
OGEN_CONFIG := .ogen.yml
|
||||
OAS_DIR := internal/transport/rest/internal/oas
|
||||
|
||||
-include .env
|
||||
export
|
||||
|
||||
# .env feeds local tooling, but its application variables must not leak into the
|
||||
# Go test process: the config tests assert defaults and the dev YAML, so an
|
||||
# ambient REDIS_ENABLED/CACHE_ENABLED would fail them.
|
||||
ENV_KEYS := $(shell sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)=.*/\1/p' .env 2>/dev/null)
|
||||
CLEAN_ENV = env $(addprefix -u ,$(ENV_KEYS))
|
||||
|
||||
.PHONY: unit-test
|
||||
unit-test:
|
||||
$(CLEAN_ENV) $(GO) test -race -shuffle=on -count=1 -timeout=5m ./...
|
||||
|
||||
.PHONY: integration-test
|
||||
integration-test:
|
||||
$(GO) test -tags=integration -p 1 -count=1 -timeout=15m ./internal/storage/postgres ./internal/storage/redis
|
||||
|
||||
.PHONY: test-db-up test-db-down
|
||||
test-db-up:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --wait postgres redis
|
||||
|
||||
test-db-down:
|
||||
@docker-compose -f docker-compose.local.yaml down
|
||||
|
||||
# не учитываем генеренные файлы, также cmd в подсчете покрытия
|
||||
COVER_EXCLUDE ?= /(mocks|oas)/|/cmd/
|
||||
|
||||
.PHONY: cover
|
||||
cover:
|
||||
$(CLEAN_ENV) $(GO) test -race -shuffle=on -count=1 -timeout=5m \
|
||||
-covermode=atomic -coverprofile=coverage.out.tmp ./...
|
||||
@grep -Ev '$(COVER_EXCLUDE)' coverage.out.tmp > coverage.out
|
||||
@rm coverage.out.tmp
|
||||
$(GO) tool cover -func=coverage.out | tail -n 1
|
||||
$(GO) tool cover -html=coverage.out
|
||||
|
||||
.PHONY: generate
|
||||
generate: generate-api generate-mocks sqlc
|
||||
|
||||
.PHONY: generate-api
|
||||
generate-api:
|
||||
$(GO) tool ogen --config $(OGEN_CONFIG) --target $(OAS_DIR) --package oas --clean $(OPENAPI_SPEC)
|
||||
|
||||
.PHONY: generate-mocks
|
||||
generate-mocks:
|
||||
$(GO) tool mockery
|
||||
|
||||
.PHONY: sqlc
|
||||
sqlc:
|
||||
$(GO) tool sqlc generate
|
||||
|
||||
.PHONY: dev-up dev-down dev-reload
|
||||
dev-up:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --build
|
||||
|
||||
dev-down:
|
||||
@docker-compose -f docker-compose.local.yaml down
|
||||
|
||||
dev-reload:
|
||||
@docker-compose -f docker-compose.local.yaml up -d --build --force-recreate
|
||||
|
||||
.PHONY: migrate
|
||||
migrate:
|
||||
$(GO) run ./cmd/migrate up
|
||||
|
||||
$(GOLANGCI_LINT):
|
||||
GOBIN=$(LOCAL_BIN) $(GO) install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
|
||||
|
||||
lint: $(GOLANGCI_LINT)
|
||||
$(GOLANGCI_LINT) run -v
|
||||
|
||||
@@ -1,37 +1,188 @@
|
||||
# Отчёт — лабораторная 3
|
||||
|
||||
- Автор, группа: TODO
|
||||
- Целевая оценка; выбранный трек 5, если нужен: TODO
|
||||
- Commit/PR: TODO после публикации
|
||||
- Использованные источники, библиотеки и помощь ИИ: TODO
|
||||
- Автор, группа: Владислав Кунецкий, БВT2303
|
||||
- Целевая оценка; выбранный трек 5, если нужен: 5; трек 1 «Цена масштабирования»
|
||||
- Commit/PR: solution/bvt2303-kunetsky (fork репозитория лабораторной 3)
|
||||
- Использованные источники, библиотеки и помощь ИИ: ogen (HTTP-транспорт из `contracts/openapi.json`), sqlc (SQL-слой), goose (миграции), pgx/v5, go-redis/v9, viper + validator (конфигурация), mockery/v3 + testify (тесты), zap через `log/slog`. Помощь ИИ использовалась для обсуждения архитектуры, ревью и подготовки кода; решение проверено и изменено автором. База перенесена из лабораторной 2.
|
||||
|
||||
## Запуск из чистого clone
|
||||
|
||||
TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных.
|
||||
Требования: Docker Engine с Compose v2 (`docker compose`), `make`; Python 3.9+ (только стандартная библиотека) для проверок; Go 1.27 — для локальной сборки и unit/integration-тестов.
|
||||
|
||||
Проверено на: macOS 25.5.0, Apple M5 Pro, 48 GiB RAM, Docker Engine 29.5.2 (Colima, macOS Virtualization.framework), Docker Compose 5.5.1, Go 1.27.1. Docker VM: **2 vCPU и ≈1.9 GiB RAM** — лимиты контейнеров в `compose.yaml` подобраны под этот бюджет (API 0.5 CPU / 256 MiB на реплику, PostgreSQL 0.5 CPU / 384 MiB, Redis 0.25 / 192 MiB, LB 0.25 / 64 MiB), суммарно меньше доступного. Образы зафиксированы по версии: `haproxy:3.2-alpine`, `redis:7.4-alpine`, `postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873`; приложение собирается из `Dockerfile` (`golang:1.27.1-alpine` → `alpine:3.22`), сборка ограничена `GOFLAGS=-p=2`, чтобы компилятор Go не выбил память небольшой VM.
|
||||
|
||||
```sh
|
||||
cp .env.example .env # синтетические креды локального стенда, реальных секретов нет
|
||||
make up # docker compose --env-file .env up -d --build
|
||||
make ps # контейнеры и health
|
||||
curl -fsS http://localhost:8080/health/ready
|
||||
|
||||
make test # публичный smoke (профиль lab3) через LB
|
||||
make test-idempotency # параллельные повторы одного Idempotency-Key
|
||||
make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
python3 student-tests/replica_failover.py --action-script scripts/stop-one.sh
|
||||
make test-lb-readiness # LB и реплика, потерявшая БД (readiness 503)
|
||||
scripts/rolling_update.sh # поочерёдная замена реплик под нагрузкой
|
||||
|
||||
make down # остановка стенда; named volumes остаются
|
||||
```
|
||||
|
||||
Намеренное удаление учебных данных (удаляет volumes и сессии):
|
||||
|
||||
```sh
|
||||
docker compose --env-file .env down -v
|
||||
```
|
||||
|
||||
Оператору достаточно `cp .env.example .env` и `make up`: миграции выполняет отдельный сервис `migrate` (`goose up`), он завершается успешно до старта API-реплик (`depends_on: service_completed_successfully`), поэтому реплики не гоняют схему наперегонки. Приложение принимает SIGTERM и дренирует сервер в пределах `SERVER_SHUTDOWN_TIMEOUT=10s`; у контейнера API `stop_grace_period: 15s`, чтобы Docker не убил запрос в полёте.
|
||||
|
||||
### Соответствие переменных `.env.example` реальной конфигурации
|
||||
|
||||
| Логическое имя из задания | Реальная переменная | Смысл |
|
||||
| --- | --- | --- |
|
||||
| `APP_HOST` / `APP_PORT` | `SERVER_HOST` / `SERVER_PORT` | адрес и порт HTTP-сервера API |
|
||||
| `APP_ENV` | `APP_ENV` | выбор `config/<env>/config.yaml`; реализован только `dev` |
|
||||
| `SESSION_STORE=postgres` | — | сессии лежат в PostgreSQL (`sessions.token_hash`), параметр не нужен |
|
||||
| `DATABASE_URL_FILE` | `POSTGRES_*` | параметры подключения к общей БД без файлов секретов |
|
||||
| `CACHE_URL_FILE` | `REDIS_*`, `CACHE_*` | общий кэш списка чатов и его блокировки |
|
||||
| `IDEMPOTENCY_TTL_SECONDS` | `IDEMPOTENCY_TTL_SECONDS` | срок хранения записи идемпотентности (по умолчанию 86400 с) |
|
||||
| `API_REPLICAS` | `API_REPLICAS` | число API-реплик стенда (`deploy.replicas`) |
|
||||
| — | `API_CPU_LIMIT` / `API_MEM_LIMIT` | лимиты CPU/RAM одной реплики (для профилей трека 1) |
|
||||
|
||||
## Архитектура и решения
|
||||
|
||||
TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab2, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации.
|
||||
Схема: клиент → LB (HAProxy с активными проверками `/health/ready`) → 2+ API-реплики → общие PostgreSQL и Redis. Единая точка входа — только LB: `127.0.0.1:8080`; порты API и хранилищ наружу не публикуются.
|
||||
|
||||
| Роль | Сервис в compose | Образ / версия | Проверка готовности | Сеть и порт | Данные |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Единая точка входа | `lb` | `haproxy:3.2-alpine` | активный `httpchk GET /health/ready`, период 2 с, `fall 2 rise 2` | публикует `127.0.0.1:8080`; страница оператора `127.0.0.1:8404` | — |
|
||||
| API-реплики | `api`, `deploy.replicas=${API_REPLICAS:-2}` | сборка из `Dockerfile` → `mtusi-messenger:lab3` | Docker healthcheck `/health/ready`, интервал 10 с | только внутренняя сеть, alias `api-replica` | — |
|
||||
| Миграции схемы | `migrate` | тот же образ, one-shot `goose up` | завершение с кодом 0 до старта реплик | только внутренняя сеть | — |
|
||||
| Источник истины | `postgres` | `postgres:18-alpine@sha256:77f5…1873` | `pg_isready`, 5 с | только внутренняя сеть | volume `postgres18-data` |
|
||||
| Кэш и блокировки | `redis` | `redis:7.4-alpine` (AOF everysec) | `redis-cli ping`, 5 с | только внутренняя сеть | volume `redis7-data` |
|
||||
| Credentials | — | — | — | `.env` (вне git, синтетические значения для локального стенда), в контейнеры передаются явными переменными | — |
|
||||
|
||||
- **Источник истины — PostgreSQL**: пользователи, чаты, участники, сообщения, серверные сессии (`sha256(token)`), записи идемпотентности. Транзакционные границы: создание чата вместе с участниками; отправка сообщения вместе с записью идемпотентности.
|
||||
- **Redis/Valkey** — кэш списка чатов с распределённой блокировкой от stampede и версиями (`user_chat_versions`); не хранит ничего, что нужно для корректности ответа.
|
||||
- **Общие сессии**: сессия создаётся одной репликой, любые другие её читают из БД, поэтому логин не привязан к реплике (sticky-сессии не используются).
|
||||
- **`X-Instance-Id`**: значение стабильно в пределах процесса (`INSTANCE_ID` или hostname = короткий ID контейнера) и проставляется middleware на **каждый** ответ, включая ошибки 400/404/405, которые формирует транспорт, а не handler.
|
||||
- **Идемпотентность отправки** (`Idempotency-Key` обязателен, `[A-Za-z0-9._:-]{1,128}`):
|
||||
- таблица `message_idempotency (actor_id, chat_id, key, request_hash, message_id, expires_at)`, PK `(actor_id, chat_id, key)` — область уникальности «пользователь + чат + ключ»;
|
||||
- claim — один `INSERT ... ON CONFLICT (actor_id, chat_id, key) DO UPDATE ... WHERE expires_at <= now() RETURNING`: живая запись не перезаписывается, истёкшая занимается заново;
|
||||
- вставка сообщения и запись `message_id` идут в **одной транзакции с claim**, поэтому не бывает ключа без сообщения и наоборот; при откате (например, отправитель не участник) ключ не занимается;
|
||||
- конкурентный повтор через разные реплики блокируется на строке и после коммита победителя возвращает его сообщение → ровно один INSERT в `messages`;
|
||||
- повтор с тем же ключом и другим payload — `409`, для этого хранится `request_hash` (sha256 канонического payload `{"text":...}`; порядок ключей и пробелы в JSON не влияют).
|
||||
- **LB**: HAProxy 3.2 (образ зафиксирован), `server-template api 4 api-replica:8080` + `resolvers docker` (Docker DNS 127.0.0.11, `hold valid 5s`) — адреса берутся из общего сетевого alias, выданного всем репликам, и переразрешаются каждые 5 с, поэтому масштабирование (1/2/4), замена контейнеров и смена IP не требуют правки конфига. Балансировка `leastconn`. Aктивные проверки готовности: `option httpchk GET /health/ready` + `http-check expect status 200`, `inter 2s fall 2 rise 2` — неготовая реплика исключается из ротации за ≤4 с и возвращается за ≤4 с. Это принципиально: пассивные проверки (nginx OSS, прежний вариант) не умели убирать реплику, которая остаётся доступной по сети, но теряет БД — она продолжала получать трафик и отвечать 503 (зафиксировано в ревью: 20 из 40 запросов `/health/live`). После перехода на активные проверки такая реплика получает **0 из 40** запросов, её статус `DOWN` (`evidence/lb-readiness.txt`), а запись через LB не прерывается (1 247 RPS, ноль ошибок в том же сценарии).
|
||||
- **Повторы и идемпотентность**: HAProxy настроен на `retry-on conn-failure` + `retries 2` — повтор происходит только когда соединение не установилось и запрос не ушёл. Уже отправленный POST не повторяется, поэтому прозрачного дублирования создания чата нет (прежний вариант с `proxy_next_upstream ... non_idempotent` этим страдал). Неопределённый результат повтора остаётся за клиентом, а отправка сообщения защищена обязательным `Idempotency-Key`.
|
||||
- **Страница оператора**: `127.0.0.1:8404/stats` (только loopback) показывает, какие реплики `UP`/`DOWN` и почему — именно по ней сняты доказательства выше.
|
||||
- **Миграции**: одна последовательность для всего стенда (`migrate`), совместимость с работающей версией — новая таблица добавляется отдельной миграцией, старый код её не читает. Новая миграция пронумерована `00003`, а не `00002`: в базе, перенесённой из ЛР2, goose уже содержит применённую версию 2 (другая миграция того же репозитория), и совпадающий номер был бы молча пропущен при обновлении существующего стенда — это проверено на dev-базе (`goose: no migrations to run. current version: 2` при отсутствующей таблице).
|
||||
|
||||
### Что перенесено из lab2
|
||||
|
||||
Перенос: ветки `lab1` + `lab2` репозитория `mtusi-messenger`, перенесены только исходники, миграции, собственные тесты, Dockerfile и конфигурации (по правилам CONTRIBUTING.md; README/COURSE/contracts/публичные tests остались от skeleton ЛР3).
|
||||
|
||||
- Транспорт: HTTP-слой, сгенерированный ogen из `contracts/openapi.json`, REST-адаптер поверх него, middleware X-Request-Id и структурного логирования.
|
||||
- Домен и сервисы: user / chat / message / session с валидацией и keyset-пагинацией.
|
||||
- PostgreSQL — источник истины: pgx + sqlc, миграции goose, транзакции на создание чата.
|
||||
- Сессии: Basic только при создании сессии, далее Bearer; в БД `sha256(token)`, TTL, переживают перезапуск процесса.
|
||||
- Redis/Valkey: кэш списка чатов с распределённой блокировкой от stampede (`user_chat_versions`).
|
||||
- Наблюдаемость: `/health/live`, `/health/ready`, структурированные логи (log/slog + zap).
|
||||
- Инструменты: multi-stage `Dockerfile`, `docker-compose.local.yaml` для локального запуска, Makefile-таргеты, `.github/workflows/app.yml`.
|
||||
|
||||
### Изменения в этой работе (лаб. 3)
|
||||
|
||||
- Контракт 1.3.0: транспорт перегенерирован, `X-Instance-Id` во всех ответах, обязательный `Idempotency-Key` для отправки сообщения.
|
||||
- Общая идемпотентность в PostgreSQL (миграция `00003_message_idempotency.sql`, sqlc-запросы, транзакция в `MessageRepository.Create`), 409 на конфликт payload.
|
||||
- `IDEMPOTENCY_TTL_SECONDS` в конфиге (по умолчанию 24 ч), `.env.example` приведён к реальным переменным.
|
||||
- Стенд ЛР3: `compose.yaml` (LB + `API_REPLICAS` реплик + PostgreSQL + Redis + одноразовый `migrate`), конфигурация LB `infra/lb/haproxy.cfg` (активные проверки готовности, ограниченные повторы, страница оператора), action-скрипты `scripts/stop-one.sh` и `scripts/restart.sh`, Makefile-таргеты `up/down/ps/logs`.
|
||||
- Собственные проверки: `make test-idempotency` (параллельные повторы через LB), `student-tests/replica_failover.py` (поочерёдная остановка каждой реплики с метриками), `scripts/lb_readiness_check.sh` (неготовая реплика и LB), `scripts/rolling_update.sh`, эксперименты трека 1.
|
||||
- `Dockerfile`: убран жёстко заданный `TARGETARCH=amd64` — на Apple Silicon он давал x86-64 бинарник внутри arm64-образа, тот исполнялся через эмуляцию и падал по runtime-фаталам под нагрузкой (см. «Ограничения»); сборка ограничена `GOFLAGS=-p=2`, чтобы компилятор не выбил память небольшой Colima VM.
|
||||
- Удалён осиротевший `scripts/track1_benchmark.py` (бенчмарк in-memory хранилища ЛР1: сам in-memory store удалён ещё в ЛР2, скрипт ссылался на несуществующий файл).
|
||||
|
||||
## Доказательства критериев
|
||||
|
||||
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
|
||||
| --- | --- | --- | --- |
|
||||
| Публичный smoke | make test | TODO | TODO |
|
||||
| Остальные пункты уровня 3 | TODO | TODO | TODO |
|
||||
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
|
||||
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
|
||||
| Публичный smoke | `make test` | `PASS: lab3 public API scenario` через LB с двумя репликами | `evidence/smoke.txt` |
|
||||
| Разные запросы одного пользователя обслуживают разные реплики | 40× `GET /users/me` через LB одной сессией | два разных `X-Instance-Id` | `evidence/failover/sequential.txt` |
|
||||
| Идемпотентность: повтор, конкурентный повтор, смена реплики | `make test-idempotency` | 12 параллельных повторов одного ключа → одно сообщение; 12 разных payload → один 201 и одиннадцать 409; без ключа и с недопустимым ключом → 400 | `evidence/idempotency.txt` |
|
||||
| Остановка одной реплики при работающей другой | `make test-failover ACTION_SCRIPT=scripts/stop-one.sh` (два прогона) | 118 и 101 подтверждённая запись, 0 ошибок, первое восстановление 1.22 с и 0.22 с | `evidence/failover/run1.txt`, `evidence/failover/run2.txt` |
|
||||
| Последовательно остановлена каждая реплика, с измерениями | `python3 student-tests/replica_failover.py --action-script scripts/stop-one.sh` | реплика A: 101 запись, 0 ошибок, восстановление 1.76 с; реплика B: 100 записей, 0 ошибок, 1.76 с; после отказа обслуживает только вторая реплика; восстановление обеих 0.17–0.20 с; дублей нет (201 сообщение) | `evidence/failover/sequential.txt` |
|
||||
| LB исключает неготовую реплику | `scripts/lb_readiness_check.sh` | реплика с потерянной БД (осталась доступной, readiness 503): **0 из 40** запросов, статус `DOWN` за ≤4 с, при этом запись через LB не прервалась (1 247 RPS, 0 ошибок) | `evidence/lb-readiness.txt` |
|
||||
| Сохранность при перезапуске API и хранилищ | `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | `PASS`: подтверждённые сообщения и прежний токен после перезапуска, volumes не удалялись | `evidence/persistence.txt` |
|
||||
| Лимиты CPU/RAM, отсутствие публичных портов API, отсутствие `container_name` | `docker compose --env-file .env config`, `docker ps` | лимиты у каждого сервиса, публикуется только `127.0.0.1:8080` (LB) | `evidence/stand.txt` |
|
||||
| Поочерёдная замена реплик под нагрузкой | `scripts/rolling_update.sh` (60 с, 8 клиентов) | две реплики заменены по одной с ожиданием готовности: 101 685 подтверждённых записей, 4 переходные ошибки (0.004 %), **0 ответов 5xx от LB**, 0 рестартов | `evidence/rolling-update/after/` |
|
||||
| Трек 1: цена масштабирования | `scripts/track1_scaling.sh` + `scripts/track1_report.py` | потолок ≈1 900 RPS: 1/2/4 реплики → +3 %/−9 %, бюджет API ×3 и бюджет БД ×2 не меняют RPS, пул не исчерпан | `evidence/track1/summary.md`, `evidence/track1/scaling-*.png` |
|
||||
|
||||
TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены.
|
||||
`make check`, `make validate` (полная OpenAPI-валидация в venv) и `make unit-test` (`-race`) проходят; интеграционные тесты PostgreSQL (`-tags=integration`, включая конкурентный повтор одного ключа) — тоже.
|
||||
|
||||
## Эксперименты и отказы
|
||||
|
||||
TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения.
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| TODO | TODO | TODO | TODO |
|
||||
| `docker stop` одной API-реплики (прогон 1) | записи продолжаются, остановленная реплика исчезает из ответов | 118 успешных записей, 0 ошибок | 1.22 с |
|
||||
| `docker stop` другой API-реплики (прогон 2) | то же | 101 запись, 0 ошибок | 0.22 с |
|
||||
| Поочерёдно остановлены обе реплики (свой скрипт) | после каждой остановки пишет только вторая реплика, дублей нет | 101 и 100 записей, 0 ошибок, повторы с тем же ключом дубля не создали | 1.76 с и 1.76 с |
|
||||
| Одной реплике закрыт доступ к БД (она остаётся доступной, readiness 503) | LB исключает её из ротации | 0 из 40 запросов ей, статус `DOWN` за ≤4 с, запись через LB не прервалась | — |
|
||||
| Поочерёдная замена каждой реплики под нагрузкой | потери только на время остановки, дублей нет | 101 685 записей, 4 переходные ошибки, 0 ответов 5xx от LB, 0 рестартов | окно замены 5–6 с на реплику |
|
||||
| Перезапуск API и всех хранилищ с сохранением volumes | сессия и данные живут | `PASS`, прежний токен работает | потери нет |
|
||||
| Эмуляция x86-64 бинарника в arm64-образе (`--build-arg TARGETARCH=amd64`) | реплики замедляются и падают | в коротком контроле (60 с, 8 клиентов) падений **не воспроизведено**: 63 173 запроса, 0 ошибок; crash-loop наблюдались в других условиях | эффект не измерен |
|
||||
| Двукратный CPU БД, пул 5 вместо 10, 4 реплики, 32 клиента | пропускная способность вырастет, если узкое место — БД/пул | RPS не меняется (1 782–1 961, ±9 %), при 32 клиентах растёт только задержка | — |
|
||||
|
||||
## Трек 1. Цена масштабирования
|
||||
|
||||
Методика: один и тот же профиль `tests/load.py` (closed loop, `concurrency=8`, `duration=60` с, прогрев 15 с) против стенда на 1, 2 и 4 API-репликах при **фиксированном суммарном бюджете** 1.0 CPU / 768 MiB на API; лимиты PostgreSQL (0.5 CPU / 512 MiB в сериях r/g/pool; в контрольном профиле `db1cpu` — 1.0 CPU / 384 MiB, см. `profile-*.json` и сырые `stats-*.csv`), Redis (0.25 / 192), LB (0.25 / 64) не меняются. Затем серия с ростом бюджета: 2 реплики и суммарно 0.5, 1.0 и 1.5 CPU. Бюджеты выбраны под Colima VM (2 vCPU, ≈1.9 GiB), чтобы измерения шли в её пределах, а не за счёт хоста. Ресурсы реплик считаются суммированием по одному timestamp: в первой версии сводки несколько реплик усреднялись как одна выборка, что занижало CPU и память вдвое — исправлено по замечанию ревью, сырые CSV не менялись. Сырые артефакты — `evidence/track1/` (`load-*.json`, `stats-*.csv`, `profile-*.json`), сводка — `evidence/track1/summary.md`, графики — `scaling-fixed-budget.png` и `scaling-growth.png`.
|
||||
|
||||
### Профили и результаты
|
||||
|
||||
Серия 1 — фиксированный суммарный бюджет 1.0 CPU / 768 MiB на API (PostgreSQL 0.5 CPU / 512 MiB, Redis 0.25, LB 0.25), нагрузка `tests/load.py` (closed loop, 8 клиентов, 60 с, прогрев 15 с):
|
||||
|
||||
| реплик | CPU на реплику | успешный RPS | p50, мс | p95, мс | p99, мс | ошибки | API CPU (сумма) | API RAM max (сумма, MiB) | PG CPU |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 1 | 1.00 | 1 895 | 4.03 | 6.51 | 8.91 | 0 | 0.34 | 43.5 | 0.60 |
|
||||
| 2 | 0.50 | 1 956 | 3.96 | 6.18 | 8.50 | 0 | 0.40 | 307.2 | 0.59 |
|
||||
| 4 | 0.25 | 1 787 | 4.29 | 7.05 | 10.00 | 0 | 0.44 | 592.0 | 0.53 |
|
||||
|
||||
Серия 2 — рост бюджета при 2 репликах:
|
||||
|
||||
| суммарный CPU API | CPU на реплику | успешный RPS | p95, мс | ошибки | API CPU (сумма) | API RAM max (сумма, MiB) | PG CPU |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| 0.5 | 0.25 | 1 906 | 6.46 | 0.3 % | 0.40 | 389.9 | 0.55 |
|
||||
| 1.0 | 0.50 | 1 954 | 6.06 | 1.7 % | 0.38 | 341.9 | 0.56 |
|
||||
| 1.5 | 0.75 | 1 857 | 6.76 | 0 | 0.40 | 344.1 | 0.59 |
|
||||
|
||||
Единичные ошибки в серии 2 — переходные обрывы соединений в момент смены состава реплик между профилями (максимум 1.7 %), подтверждённых записей не потеряно: повтор с тем же ключом дубля не создаёт (см. проверку идемпотентности).
|
||||
|
||||
Контрольные точки: база данных с удвоенной квотой CPU (1.0 вместо 0.5) — 1 961 RPS (было 1 956); пул соединений 5 вместо 10 на реплику при 4 репликах — 1 817 RPS (было 1 890); 32 клиента вместо 8 — 1 782 RPS и p95 28 мс (было 1 956 и p95 6.2 мс, то есть растёт очередь, а не пропускная способность).
|
||||
|
||||
### Где насыщение
|
||||
|
||||
Ни одна ручка приложения или БД не сдвигает потолок ≈1 900 RPS: **+3 %** при переходе с 1 на 2 реплики, **−9 %** на 4 репликах, ноль от трёхкратного бюджета API, ноль от двукратного бюджета БД, ноль от размера пула (23 соединения из 100 — пул не исчерпан). Суммарный CPU реплик (0.34–0.44 из бюджета 1.0 CPU) не упирается в квоту, а PostgreSQL держится у своей (0.52–0.60 при квоте 0.5). Тот же код вне Docker (нативный процесс против локальной БД) даёт 2 730 RPS при 32 клиентах и нуле ошибок. То есть на этой машине узкое место — путь «хост → Colima VM (2 vCPU) → LB»: потолок задаёт виртуализация и проброс порта, а не приложение, БД или балансировщик. Оговорка о честности: абсолютные значения `docker stats` в этой VM выглядят заниженными (суммарно ~1 CPU на 1 900 RPS ≈ 0.5 мс на запись вместе с БД), а независимая проверка соблюдения квот на 2-vCPU VM оказалась неубедительной, поэтому «фиксированный бюджет» в сериях — номинальный; на вывод это не влияет, потому что потолок не двигался ни при каком бюджете. Дополнительно исправлена ошибка сводки: ресурсы реплик теперь суммируются по одному timestamp (в первой версии API усреднялся как одна выборка, что занижало CPU и память вдвое; сырые CSV не менялись). На Linux-хосте с большим числом ядер те же скрипты (`scripts/track1_scaling.sh`, `scripts/track1_report.py`) нужно прогнать заново — там ожидаемое насыщение сместится в БД и пул.
|
||||
|
||||
### Подтверждённое улучшение и проверенные гипотезы
|
||||
|
||||
**Подтверждено (измерено до/после):** балансировщик перестал отправлять трафик неготовой реплике. `scripts/lb_readiness_check.sh` поднимает рядом с рабочими репликами третью с тем же сетевым alias, но её доступ к БД идёт через временный TCP-прокси; после остановки прокси реплика остаётся доступной по сети, её `/health/ready` отвечает 503.
|
||||
|
||||
| Вариант LB | запросов неготовой реплике из 40 | статус в LB | запись через LB |
|
||||
| --- | --- | --- | --- |
|
||||
| пассивные проверки (nginx OSS, до правки) | 20 из 40 `/health/live` и бизнес-запросы (зафиксировано в ревью) | продолжает обслуживать | 503 и 200 вперемешку |
|
||||
| активные проверки (HAProxy, `httpchk /health/ready`, `inter 2s fall 2 rise 2`) | **0 из 40** | `DOWN` за ≤4 с | 1 247 RPS, 0 ошибок (`evidence/lb-readiness.txt`) |
|
||||
|
||||
Вместе с этим убраны две связанные проблемы: прозрачный повтор POST (`proxy_next_upstream ... non_idempotent` мог повторить создание чата) заменён на `retry-on conn-failure`, а недоступная реплика убирается из ротации полностью, а не «на 3 секунды». Сценарий rolling update по-прежнему проходит под нагрузкой (0 ответов 5xx от LB, `restarts=0`, `evidence/rolling-update/after/`).
|
||||
|
||||
**Дефект доказан, эффект его устранения — нет.** Архитектурная ошибка унаследованного `Dockerfile` (`ARG TARGETARCH=amd64`, а классический builder платформу не подставляет → x86-64 бинарник в arm64-образе) подтверждена ELF-заголовками (`evidence/arch.txt`): `e_machine=0x3e` против `0xb7`. Но контролируемое сравнение **не подтвердило**, что именно она вызывала прежние runtime-фаталы: оба прогона rolling update — на исправленном и на эмулируемом образе — завершились без ошибок (`evidence/rolling-update/emulated/load.json` показывает нули). Падения (`fatal error: found pointer to free object`, `sync: inconsistent mutex state`, crash-loop реплик) наблюдались в других условиях и в приложенный A/B не попали. Корректная формулировка: эмуляция x86-64 на arm64 — доказанный дефект сборки, который устранён, но его вклад в те падения не измерен.
|
||||
|
||||
**Не подтвердились измерениями:** размер пула соединений (10 → 5) и удвоенный лимит CPU БД — оба в пределах шума; на этой машине потолок задаёт не БД.
|
||||
|
||||
**Следующий шаг для измерения:** сократить число операторов в БД на одно сообщение — сейчас их три (claim ключа, вставка сообщения, запись `message_id`), нужно два (вставка сообщения + upsert ключа в той же транзакции, конфликт — через откат и повторное чтение). Гипотеза: меньше round-trip и меньше версий строк; эффект будет виден на стенде, где потолок задаёт БД.
|
||||
|
||||
## Ограничения и следующие шаги
|
||||
|
||||
TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза.
|
||||
- **Архитектура образа (главная находка этапа отладки).** Унаследованный `Dockerfile` содержал `ARG TARGETARCH=amd64`, а классический builder платформу не подставляет — в arm64-образ попадал x86-64 бинарник (`e_machine=0x3e` против `0xb7` у busybox базового образа; в стеке паники видно `runtime/asm_amd64.s`). Пока нагрузка была низкой, эмуляция справлялась; под нагрузкой Go runtime падал с `fatal error: found pointer to free object`, `sync: inconsistent mutex state`, `bad pointer in Go heap`, `runtime: name offset base pointer out of range` — и это выглядело как проблема приложения. Контрольный эксперимент снял подозрения с кода: тот же исходник, собранный нативно (вне Docker, против локальной БД), выдержал 90 с при 32 клиентах — 245 798 запросов, 0 ошибок, p50 11.1 мс, p95 16.0 мс, p99 20.7 мс, 2 730 успешных rps. После исправления (`ARG TARGETARCH` без значения по умолчанию, кросс-сборка — явным `--build-arg`) стенд стабилен, однако строгий A/B связь с прежними падениями не подтвердил (см. «Подтверждённое улучшение»). Если вы собираете под другую платформу, задавайте `TARGETOS`/`TARGETARCH` явно.
|
||||
- **Ресурсы VM.** Colima (macOS Virtualization.framework) даёт 2 vCPU и ≈1.9 GiB RAM: сборка образа была один раз убита OOM, поэтому компилятор ограничен `GOFLAGS=-p=2`, а бюджеты экспериментов трека 1 подобраны под VM (1.0 CPU суммарно на API), иначе измеряется не масштабирование, а нехватка ресурсов.
|
||||
- **Окно обнаружения отказа.** Готовность проверяется активно (`httpchk /health/ready`, период 2 с, `fall 2`): реплика уходит из ротации за ≤4 с. Между фактическим отказом и первой неудачной проверкой она ещё получает трафик, поэтому клиент может увидеть 503 от неё или ошибку соединения — в измеренных сценариях это единичные переходные ошибки (0–2 %), они учтены в таблицах отказа.
|
||||
- **Строгая проверка «до/после» по архитектуре не удалась.** Исходный дефект сборки доказан (ELF-заголовки), но воспроизвести падения в контролируемом A/B не удалось: эмулируемый образ в коротком прогоне тоже прошёл без ошибок. Считать эффект устранения измеренным нельзя.
|
||||
- Один Docker-host: эксперименты показывают отказ **процесса** API, но не отказ узла. Потеря хоста, а также LB, PostgreSQL и Redis остаются единичными точками отказа; выживание узла БД не заявлено.
|
||||
- PostgreSQL не реплицирована, Redis не кластеризован — при их отказе стенд недоступен, это честное учебное упрощение.
|
||||
- Генератор нагрузки `tests/load.py` — closed-loop: он ограничен клиентом и страдает coordinated omission, поэтому измеренный RPS — это пропускная способность HTTP-подтверждений, а не предельная ёмкость системы. Для серьёзных выводов нужен k6/Locust или свой open-loop генератор.
|
||||
- Записи идемпотентности не удаляются фоновым процессом: истёкшие строки занимаются лениво при повторном использовании ключа, остальные ждут будущей уборки (индекс `expires_at` уже есть).
|
||||
|
||||
@@ -50,7 +50,7 @@ func run(cfg config.Config, log *slog.Logger) error {
|
||||
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
|
||||
defer stop()
|
||||
|
||||
store, err := postgres.New(ctx, cfg.Postgres)
|
||||
store, err := postgres.New(ctx, cfg.Postgres, time.Duration(cfg.Idempotency.TTLSeconds)*time.Second)
|
||||
if err != nil {
|
||||
return fmt.Errorf("connect database: %w", err)
|
||||
}
|
||||
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
# Lab3 stand: two API replicas behind a HAProxy load balancer.
|
||||
#
|
||||
# cp -n .env.example .env
|
||||
# docker compose --env-file .env up -d --build
|
||||
# curl http://localhost:8080/health/ready
|
||||
#
|
||||
# Only the load balancer is published (127.0.0.1). Stores and API replicas are
|
||||
# reachable from the host via `docker compose exec` / `docker compose logs`.
|
||||
# No container_name anywhere: replica hostnames stay the short container IDs,
|
||||
# which the application reports back as X-Instance-Id.
|
||||
name: mtusi-messenger-lab3
|
||||
|
||||
x-app: &app
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger:lab3
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:18-alpine@sha256:77f585114c32fbca283dc835b0596f4e52b51b4c6662d7810b2f4084f60a1873
|
||||
environment:
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
||||
POSTGRES_DB: ${POSTGRES_DB:-messenger}
|
||||
volumes:
|
||||
- postgres18-data:/var/lib/postgresql
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
# Saturation point of the stand (see REPORT.md, track 1): the database
|
||||
# runs at its quota while API replicas idle. Raise this knob to give the
|
||||
# shared dependency more of the host CPU.
|
||||
cpus: "${POSTGRES_CPU_LIMIT:-0.50}"
|
||||
memory: 384M
|
||||
restart: unless-stopped
|
||||
|
||||
redis:
|
||||
image: redis:7.4-alpine
|
||||
command:
|
||||
- redis-server
|
||||
- --appendonly
|
||||
- "yes"
|
||||
- --appendfsync
|
||||
- everysec
|
||||
- --save
|
||||
- "60"
|
||||
- "1"
|
||||
volumes:
|
||||
- redis7-data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 3s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 192M
|
||||
restart: unless-stopped
|
||||
|
||||
# One-shot schema bootstrap; runs once to completion before any API replica.
|
||||
migrate:
|
||||
<<: *app
|
||||
entrypoint: ["/usr/local/bin/migrate"]
|
||||
command: ["up"]
|
||||
environment:
|
||||
APP_CONFIG: /etc/messenger/dev/config.yaml
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
||||
POSTGRES_SSL_MODE: disable
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.50"
|
||||
memory: 256M
|
||||
restart: "no"
|
||||
|
||||
api:
|
||||
<<: *app
|
||||
# Общий сетевой alias: LB резолвит одно имя в адреса всех реплик, поэтому
|
||||
# масштабирование и замена контейнеров не зависят от их номеров/ID.
|
||||
networks:
|
||||
default:
|
||||
aliases:
|
||||
- api-replica
|
||||
env_file:
|
||||
- path: .env
|
||||
required: false
|
||||
# Explicit values win over localhost defaults coming from .env (see .env.example).
|
||||
environment:
|
||||
APP_CONFIG: /etc/messenger/dev/config.yaml
|
||||
POSTGRES_HOST: postgres
|
||||
POSTGRES_PORT: "5432"
|
||||
POSTGRES_DATABASE: ${POSTGRES_DB:-messenger}
|
||||
POSTGRES_USER: ${POSTGRES_USER:-messenger}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-messenger}
|
||||
POSTGRES_SSL_MODE: disable
|
||||
REDIS_ENABLED: "true"
|
||||
REDIS_HOST: redis
|
||||
REDIS_PORT: "6379"
|
||||
CACHE_ENABLED: "true"
|
||||
# Размер пула соединений ОДНОЙ реплики; общий расход = реплики × значение.
|
||||
# Это один из общих ресурсов, который масштабирование расходует первым.
|
||||
POSTGRES_MAX_CONNS: "${POSTGRES_MAX_CONNS:-10}"
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${API_CPU_LIMIT:-0.50}"
|
||||
memory: ${API_MEM_LIMIT:-256M}
|
||||
# The app drains on SIGTERM within SERVER_SHUTDOWN_TIMEOUT; keep the grace
|
||||
# period above it so Docker does not SIGKILL an in-flight request.
|
||||
stop_grace_period: 15s
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "-O", "/dev/null", "http://127.0.0.1:8080/health/ready"]
|
||||
interval: 10s
|
||||
# Готовность проверяет ещё и БД/кэш: под насыщающей нагрузкой ответ может
|
||||
# подойти к секундам, и слишком строгий таймаут помечает занятую, но
|
||||
# работающую реплику как unhealthy.
|
||||
timeout: 5s
|
||||
retries: 6
|
||||
start_period: 5s
|
||||
restart: unless-stopped
|
||||
|
||||
# Public entry point. Active /health/ready probes remove a not-ready replica from
|
||||
# rotation entirely; infra/lb/haproxy.cfg holds the upstream, checks and retries.
|
||||
lb:
|
||||
image: haproxy:3.2-alpine
|
||||
volumes:
|
||||
- ./infra/lb/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro
|
||||
ports:
|
||||
- "127.0.0.1:${SERVER_PORT:-8080}:80"
|
||||
# Operator-only stats page on loopback: shows which replica is UP/DOWN and why.
|
||||
- "127.0.0.1:${LB_STATS_PORT:-8404}:8404"
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_healthy
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.25"
|
||||
memory: 64M
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres18-data:
|
||||
redis7-data:
|
||||
@@ -45,3 +45,7 @@ cache:
|
||||
|
||||
session:
|
||||
ttl_seconds: 3600
|
||||
|
||||
# Retention of a message Idempotency-Key; contract 1.3.0 requires ≥ 24 h.
|
||||
idempotency:
|
||||
ttl_seconds: 86400
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# Architecture of the app binary inside the image
|
||||
# generated: 2026-10-15T19:03:01Z
|
||||
|
||||
## emulated build (--build-arg TARGETARCH=amd64): e_machine 3e = x86-64
|
||||
02 00 3e 00
|
||||
## fixed build (no TARGETARCH default): e_machine b7 = aarch64
|
||||
02 00 b7 00
|
||||
@@ -0,0 +1,4 @@
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 118, "failed_attempts": 0, "first_recovery_seconds": 1.224}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,4 @@
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 101, "failed_attempts": 0, "first_recovery_seconds": 0.219}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,51 @@
|
||||
{
|
||||
"before": {
|
||||
"instances": [
|
||||
"d9b697bac595",
|
||||
"f53bcf445c6d"
|
||||
]
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"stopped": "d9b697bac595",
|
||||
"stopped_container": "stop-one.sh: stopped api replica(s): mtusi-messenger-lab3-api-3",
|
||||
"hook_returncode": 0,
|
||||
"hook_seconds": 0.156,
|
||||
"hook_error": "",
|
||||
"successful_writes": 101,
|
||||
"failed_attempts": 0,
|
||||
"uncertain_retries": 0,
|
||||
"first_recovery_seconds": 1.761,
|
||||
"instances_after_recovery": [
|
||||
"f53bcf445c6d"
|
||||
],
|
||||
"messages_in_history": 101,
|
||||
"restored_seconds": 0.199,
|
||||
"instances_restored": [
|
||||
"d9b697bac595",
|
||||
"f53bcf445c6d"
|
||||
]
|
||||
},
|
||||
{
|
||||
"stopped": "f53bcf445c6d",
|
||||
"stopped_container": "stop-one.sh: stopped api replica(s): mtusi-messenger-lab3-api-4",
|
||||
"hook_returncode": 0,
|
||||
"hook_seconds": 0.151,
|
||||
"hook_error": "",
|
||||
"successful_writes": 100,
|
||||
"failed_attempts": 0,
|
||||
"uncertain_retries": 0,
|
||||
"first_recovery_seconds": 1.759,
|
||||
"instances_after_recovery": [
|
||||
"d9b697bac595"
|
||||
],
|
||||
"messages_in_history": 201,
|
||||
"restored_seconds": 0.174,
|
||||
"instances_restored": [
|
||||
"d9b697bac595",
|
||||
"f53bcf445c6d"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
PASS: каждая реплика остановлена по очереди; записи продолжились, дублей и потерь нет
|
||||
@@ -0,0 +1,3 @@
|
||||
env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 python3 student-tests/idempotency_parallel.py --base-url "http://localhost:8080"
|
||||
{"replay": {"workers": 12, "instances": ["69acca5cd6cd", "e9df09de18d5"], "message_id": "01a144ec-4559-7d23-9619-7298c9db3b95"}, "conflict": {"workers": 12, "accepted": 1, "conflicts": 11}, "stable_body": {"message_id": "01a144ec-457c-7898-a2cf-4ad1bbf12e93"}, "key_required": {"status": 400}}
|
||||
PASS: параллельный повтор с одним Idempotency-Key создаёт ровно одно сообщение
|
||||
@@ -0,0 +1,30 @@
|
||||
# LB excludes a not-ready but reachable replica (lab3)
|
||||
# generated: 2026-10-16T13:34:41Z
|
||||
# lb: haproxy:3.2-alpine
|
||||
|
||||
## 1. baseline: requests through LB by replica
|
||||
24 69acca5cd6cd
|
||||
16 e9df09de18d5
|
||||
stats: api1=UP api2=UP api3=MAINT (resolution) api4=MAINT (resolution) BACKEND=UP
|
||||
|
||||
## 2. start a temporary TCP proxy to postgres and a candidate replica behind the same network alias
|
||||
instance-id: 78bfb4c32a64, readiness while its database is reachable: 200
|
||||
load balancer slot for the candidate: api3, stats: api1=UP api2=UP api3=UP api4=MAINT (resolution) BACKEND=UP
|
||||
|
||||
## 3. cut the candidate's database access (stop only the TCP proxy)
|
||||
candidate is still running: running, readiness: 503
|
||||
waiting for the load balancer to mark api3 DOWN
|
||||
stats after failure: api1=UP api2=UP api3=DOWN api4=MAINT (resolution) BACKEND=UP
|
||||
|
||||
## 4. 40 requests through LB while the candidate is not ready
|
||||
19 69acca5cd6cd
|
||||
21 e9df09de18d5
|
||||
(the candidate must not appear above)
|
||||
|
||||
## 5. business writes through LB during the exclusion
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1247.834,
|
||||
|
||||
## 6. cleanup
|
||||
stats after cleanup: api1=UP api2=UP api3=MAINT (resolution) api4=MAINT (resolution) BACKEND=UP
|
||||
@@ -0,0 +1,3 @@
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.012,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 101685,
|
||||
"failed_requests": 4,
|
||||
"error_ratio": 3.9e-05,
|
||||
"errors_by_kind": {
|
||||
"http_error": 4
|
||||
},
|
||||
"successful_rps": 1694.423,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.971,
|
||||
"p95": 8.062,
|
||||
"p99": 23.175
|
||||
},
|
||||
"instances": {
|
||||
"6f572ff329c7": 3673,
|
||||
"8b63314a0aae": 51567,
|
||||
"ed9b4a867eaf": 46445
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.012,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 101685,
|
||||
"failed_requests": 4,
|
||||
"error_ratio": 3.9e-05,
|
||||
"errors_by_kind": {
|
||||
"http_error": 4
|
||||
},
|
||||
"successful_rps": 1694.423,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.971,
|
||||
"p95": 8.062,
|
||||
"p99": 23.175
|
||||
},
|
||||
"instances": {
|
||||
"6f572ff329c7": 3673,
|
||||
"8b63314a0aae": 51567,
|
||||
"ed9b4a867eaf": 46445
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
# Rolling update under load
|
||||
# generated: 2026-10-16T13:36:30Z
|
||||
# load: tests/load.py duration=60s concurrency=8 (closed loop)
|
||||
# steps: delete one replica, recreate it from the freshly built image, wait for health + LB
|
||||
|
||||
time="2026-10-16T16:36:30+03:00" level=warning msg="buildx Docker CLI plugin not found: falling back to the classic builder. BuildKit-only build features (multi-arch, secrets, ssh, additional contexts, ...) will not be available"
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Sending build context to Docker daemon 218.8kB␍
|
||||
Step 1/25 : ARG GO_VERSION=1.27.1
|
||||
Step 2/25 : ARG ALPINE_VERSION=3.22
|
||||
Step 3/25 : FROM golang:${GO_VERSION}-alpine AS build
|
||||
---> 8a5910f31396
|
||||
Step 4/25 : ARG TARGETOS
|
||||
---> Using cache
|
||||
---> d5f2c47ea7a5
|
||||
Step 5/25 : ARG TARGETARCH
|
||||
---> Using cache
|
||||
---> 047ee34b445c
|
||||
Step 6/25 : ARG VERSION=dev
|
||||
---> Using cache
|
||||
---> a529d045efeb
|
||||
Step 7/25 : ENV GOTOOLCHAIN=local
|
||||
---> Using cache
|
||||
---> 428f1b16b5c5
|
||||
Step 8/25 : WORKDIR /opt
|
||||
---> Using cache
|
||||
---> f37febf8b423
|
||||
Step 9/25 : COPY go.mod go.sum ./
|
||||
---> Using cache
|
||||
---> c4015f597b99
|
||||
Step 10/25 : RUN go mod download
|
||||
---> Using cache
|
||||
---> 34ef6a6167b0
|
||||
Step 11/25 : ARG GOFLAGS="-p=2"
|
||||
---> Using cache
|
||||
---> deb54a0ce57a
|
||||
Step 12/25 : ENV GOFLAGS=$GOFLAGS
|
||||
---> Using cache
|
||||
---> 3da36569422d
|
||||
Step 13/25 : COPY . .
|
||||
---> 20bd22e6c5a6
|
||||
Step 14/25 : RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/messenger ./cmd/messenger && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/migrate ./cmd/migrate
|
||||
---> Running in 3975cf2aa5aa
|
||||
---> Removed intermediate container 3975cf2aa5aa
|
||||
---> 3d418af44a0b
|
||||
Step 15/25 : FROM alpine:${ALPINE_VERSION} AS runtime
|
||||
---> 5291449c3df7
|
||||
Step 16/25 : RUN apk add --no-cache ca-certificates wget && addgroup -S -g 10001 app && adduser -S -D -H -u 10001 -G app app
|
||||
---> Using cache
|
||||
---> f47b074d9bd5
|
||||
Step 17/25 : COPY --from=build --chown=10001:10001 /out/messenger /usr/local/bin/messenger
|
||||
---> Using cache
|
||||
---> 50fc6abe3b04
|
||||
Step 18/25 : COPY --from=build --chown=10001:10001 /out/migrate /usr/local/bin/migrate
|
||||
---> Using cache
|
||||
---> 9bf6afe0256d
|
||||
Step 19/25 : COPY --chown=10001:10001 config/dev/config.yaml /etc/messenger/dev/config.yaml
|
||||
---> Using cache
|
||||
---> 0d1870a325ec
|
||||
Step 20/25 : USER 10001:10001
|
||||
---> Using cache
|
||||
---> 1991f2ae06cc
|
||||
Step 21/25 : EXPOSE 8080
|
||||
---> Using cache
|
||||
---> 762d1bfb7606
|
||||
Step 22/25 : STOPSIGNAL SIGTERM
|
||||
---> Using cache
|
||||
---> 8a9d8f4f7101
|
||||
Step 23/25 : HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 CMD wget -q -O /dev/null "http://127.0.0.1:${SERVER_PORT:-8080}/health/live" || exit 1
|
||||
---> Using cache
|
||||
---> 65dea502a3f3
|
||||
Step 24/25 : ENTRYPOINT ["/usr/local/bin/messenger"]
|
||||
---> Using cache
|
||||
---> 83bbee72905e
|
||||
Step 25/25 : LABEL com.docker.compose.image.builder=classic
|
||||
---> Using cache
|
||||
---> 037f969d5ea1
|
||||
Successfully built 037f969d5ea1
|
||||
Successfully tagged mtusi-messenger:lab3
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Container mtusi-messenger-lab3-api-3 Recreate
|
||||
Container mtusi-messenger-lab3-api-4 Recreate
|
||||
Container mtusi-messenger-lab3-api-4 Recreated
|
||||
Container mtusi-messenger-lab3-api-3 Recreated
|
||||
Container mtusi-messenger-lab3-api-3 Starting
|
||||
Container mtusi-messenger-lab3-api-3 Started
|
||||
Container mtusi-messenger-lab3-api-4 Starting
|
||||
Container mtusi-messenger-lab3-api-4 Started
|
||||
replicas before: 2; instances seen through LB: 2
|
||||
Container mtusi-messenger-lab3-api-4 Running
|
||||
Container mtusi-messenger-lab3-api-5 Creating
|
||||
Container mtusi-messenger-lab3-api-5 Created
|
||||
Container mtusi-messenger-lab3-api-5 Starting
|
||||
Container mtusi-messenger-lab3-api-5 Started
|
||||
step 1: removed a9189349e890 at 2026-10-16T13:37:17Z, 2 healthy replicas served again at 2026-10-16T13:37:23Z
|
||||
Container mtusi-messenger-lab3-api-5 Running
|
||||
Container mtusi-messenger-lab3-api-6 Creating
|
||||
Container mtusi-messenger-lab3-api-6 Created
|
||||
Container mtusi-messenger-lab3-api-6 Starting
|
||||
Container mtusi-messenger-lab3-api-6 Started
|
||||
step 2: removed 6f572ff329c7 at 2026-10-16T13:37:23Z, 2 healthy replicas served again at 2026-10-16T13:37:28Z
|
||||
|
||||
load summary (tolerant generator):
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.012,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 101685,
|
||||
"failed_requests": 4,
|
||||
"error_ratio": 3.9e-05,
|
||||
"errors_by_kind": {
|
||||
"http_error": 4
|
||||
},
|
||||
"successful_rps": 1694.423,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.971,
|
||||
"p95": 8.062,
|
||||
"p99": 23.175
|
||||
},
|
||||
"instances": {
|
||||
"6f572ff329c7": 3673,
|
||||
"8b63314a0aae": 51567,
|
||||
"ed9b4a867eaf": 46445
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
|
||||
LB responses with 5xx during the update: 0
|
||||
|
||||
API containers after the update:
|
||||
mtusi-messenger-lab3-api-6 Up 55 seconds (healthy)
|
||||
mtusi-messenger-lab3-api-5 Up About a minute (healthy)
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 119005,
|
||||
"failed_requests": 1323,
|
||||
"error_ratio": 0.010995,
|
||||
"errors_by_kind": {
|
||||
"connection_broken": 1323
|
||||
},
|
||||
"successful_rps": 1982.673,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.88,
|
||||
"p95": 5.891,
|
||||
"p99": 7.733
|
||||
},
|
||||
"instances": {
|
||||
"e327ef9e0e4e": 7594,
|
||||
"0bd2666d4be8": 60080,
|
||||
"c35d7accbbd1": 51331
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 119005,
|
||||
"failed_requests": 1323,
|
||||
"error_ratio": 0.010995,
|
||||
"errors_by_kind": {
|
||||
"connection_broken": 1323
|
||||
},
|
||||
"successful_rps": 1982.673,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.88,
|
||||
"p95": 5.891,
|
||||
"p99": 7.733
|
||||
},
|
||||
"instances": {
|
||||
"e327ef9e0e4e": 7594,
|
||||
"0bd2666d4be8": 60080,
|
||||
"c35d7accbbd1": 51331
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
# Rolling update under load
|
||||
# generated: 2026-10-15T18:59:10Z
|
||||
# load: tests/load.py duration=60s concurrency=8 (closed loop)
|
||||
# steps: delete one replica, recreate it from the freshly built image, wait for health + LB
|
||||
|
||||
time="2026-10-15T21:59:10+03:00" level=warning msg="buildx Docker CLI plugin not found: falling back to the classic builder. BuildKit-only build features (multi-arch, secrets, ssh, additional contexts, ...) will not be available"
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Sending build context to Docker daemon 213.7kB␍
|
||||
Step 1/25 : ARG GO_VERSION=1.27.1
|
||||
Step 2/25 : ARG ALPINE_VERSION=3.22
|
||||
Step 3/25 : FROM golang:${GO_VERSION}-alpine AS build
|
||||
---> 8a5910f31396
|
||||
Step 4/25 : ARG TARGETOS
|
||||
---> Using cache
|
||||
---> d5f2c47ea7a5
|
||||
Step 5/25 : ARG TARGETARCH
|
||||
---> Using cache
|
||||
---> 047ee34b445c
|
||||
Step 6/25 : ARG VERSION=dev
|
||||
---> Using cache
|
||||
---> a529d045efeb
|
||||
Step 7/25 : ENV GOTOOLCHAIN=local
|
||||
---> Using cache
|
||||
---> 428f1b16b5c5
|
||||
Step 8/25 : WORKDIR /opt
|
||||
---> Using cache
|
||||
---> f37febf8b423
|
||||
Step 9/25 : COPY go.mod go.sum ./
|
||||
---> Using cache
|
||||
---> c4015f597b99
|
||||
Step 10/25 : RUN go mod download
|
||||
---> Using cache
|
||||
---> 34ef6a6167b0
|
||||
Step 11/25 : ARG GOFLAGS="-p=2"
|
||||
---> Using cache
|
||||
---> deb54a0ce57a
|
||||
Step 12/25 : ENV GOFLAGS=$GOFLAGS
|
||||
---> Using cache
|
||||
---> 3da36569422d
|
||||
Step 13/25 : COPY . .
|
||||
---> 596dc1ab02d1
|
||||
Step 14/25 : RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/messenger ./cmd/messenger && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/migrate ./cmd/migrate
|
||||
---> Running in dd30e24fc0a9
|
||||
---> Removed intermediate container dd30e24fc0a9
|
||||
---> 01aa8bc6200d
|
||||
Step 15/25 : FROM alpine:${ALPINE_VERSION} AS runtime
|
||||
---> 5291449c3df7
|
||||
Step 16/25 : RUN apk add --no-cache ca-certificates wget && addgroup -S -g 10001 app && adduser -S -D -H -u 10001 -G app app
|
||||
---> Using cache
|
||||
---> f47b074d9bd5
|
||||
Step 17/25 : COPY --from=build --chown=10001:10001 /out/messenger /usr/local/bin/messenger
|
||||
---> Using cache
|
||||
---> 50fc6abe3b04
|
||||
Step 18/25 : COPY --from=build --chown=10001:10001 /out/migrate /usr/local/bin/migrate
|
||||
---> Using cache
|
||||
---> 9bf6afe0256d
|
||||
Step 19/25 : COPY --chown=10001:10001 config/dev/config.yaml /etc/messenger/dev/config.yaml
|
||||
---> Using cache
|
||||
---> 0d1870a325ec
|
||||
Step 20/25 : USER 10001:10001
|
||||
---> Using cache
|
||||
---> 1991f2ae06cc
|
||||
Step 21/25 : EXPOSE 8080
|
||||
---> Using cache
|
||||
---> 762d1bfb7606
|
||||
Step 22/25 : STOPSIGNAL SIGTERM
|
||||
---> Using cache
|
||||
---> 8a9d8f4f7101
|
||||
Step 23/25 : HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 CMD wget -q -O /dev/null "http://127.0.0.1:${SERVER_PORT:-8080}/health/live" || exit 1
|
||||
---> Using cache
|
||||
---> 65dea502a3f3
|
||||
Step 24/25 : ENTRYPOINT ["/usr/local/bin/messenger"]
|
||||
---> Using cache
|
||||
---> 83bbee72905e
|
||||
Step 25/25 : LABEL com.docker.compose.image.builder=classic
|
||||
---> Using cache
|
||||
---> 037f969d5ea1
|
||||
Successfully built 037f969d5ea1
|
||||
Successfully tagged mtusi-messenger:lab3
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Container mtusi-messenger-lab3-api-14 Stopping
|
||||
Container mtusi-messenger-lab3-api-12 Recreate
|
||||
Container mtusi-messenger-lab3-api-15 Stopping
|
||||
Container mtusi-messenger-lab3-api-13 Recreate
|
||||
Container mtusi-messenger-lab3-api-15 Stopped
|
||||
Container mtusi-messenger-lab3-api-15 Removing
|
||||
Container mtusi-messenger-lab3-api-14 Stopped
|
||||
Container mtusi-messenger-lab3-api-14 Removing
|
||||
Container mtusi-messenger-lab3-api-15 Removed
|
||||
Container mtusi-messenger-lab3-api-14 Removed
|
||||
Container mtusi-messenger-lab3-api-12 Recreated
|
||||
Container mtusi-messenger-lab3-api-13 Recreated
|
||||
Container mtusi-messenger-lab3-api-13 Starting
|
||||
Container mtusi-messenger-lab3-api-13 Started
|
||||
Container mtusi-messenger-lab3-api-12 Starting
|
||||
Container mtusi-messenger-lab3-api-12 Started
|
||||
replicas before: 2; instances seen through LB: 2
|
||||
Container mtusi-messenger-lab3-api-12 Running
|
||||
Container mtusi-messenger-lab3-api-13 Creating
|
||||
Container mtusi-messenger-lab3-api-13 Created
|
||||
Container mtusi-messenger-lab3-api-13 Starting
|
||||
Container mtusi-messenger-lab3-api-13 Started
|
||||
step 1: removed 3b7d42e67efa at 2026-10-15T18:59:58Z, 2 healthy replicas served again at 2026-10-15T19:00:04Z
|
||||
Container mtusi-messenger-lab3-api-13 Running
|
||||
Container mtusi-messenger-lab3-api-14 Creating
|
||||
Container mtusi-messenger-lab3-api-14 Created
|
||||
Container mtusi-messenger-lab3-api-14 Starting
|
||||
Container mtusi-messenger-lab3-api-14 Started
|
||||
step 2: removed e327ef9e0e4e at 2026-10-15T19:00:04Z, 2 healthy replicas served again at 2026-10-15T19:00:10Z
|
||||
|
||||
load summary (tolerant generator):
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 119005,
|
||||
"failed_requests": 1323,
|
||||
"error_ratio": 0.010995,
|
||||
"errors_by_kind": {
|
||||
"connection_broken": 1323
|
||||
},
|
||||
"successful_rps": 1982.673,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.88,
|
||||
"p95": 5.891,
|
||||
"p99": 7.733
|
||||
},
|
||||
"instances": {
|
||||
"e327ef9e0e4e": 7594,
|
||||
"0bd2666d4be8": 60080,
|
||||
"c35d7accbbd1": 51331
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
|
||||
LB responses with 5xx during the update: 0
|
||||
|
||||
API containers after the update:
|
||||
mtusi-messenger-lab3-api-14 Up 55 seconds (healthy)
|
||||
mtusi-messenger-lab3-api-13 Up About a minute (healthy)
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 45.0,
|
||||
"elapsed_seconds": 45.014,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 89560,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"errors_by_kind": {},
|
||||
"successful_rps": 1989.584,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.905,
|
||||
"p95": 6.02,
|
||||
"p99": 7.984
|
||||
},
|
||||
"instances": {
|
||||
"388ebcb74200": 7524,
|
||||
"73d07d7d76db": 45354,
|
||||
"cc6274635bd6": 36682
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 45.0,
|
||||
"elapsed_seconds": 45.014,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 89560,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"errors_by_kind": {},
|
||||
"successful_rps": 1989.584,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.905,
|
||||
"p95": 6.02,
|
||||
"p99": 7.984
|
||||
},
|
||||
"instances": {
|
||||
"388ebcb74200": 7524,
|
||||
"73d07d7d76db": 45354,
|
||||
"cc6274635bd6": 36682
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
# Rolling update under load
|
||||
# generated: 2026-10-15T19:03:13Z
|
||||
# load: tests/load.py duration=45s concurrency=8 (closed loop)
|
||||
# steps: delete one replica, recreate it from the freshly built image, wait for health + LB
|
||||
|
||||
time="2026-10-15T22:03:13+03:00" level=warning msg="buildx Docker CLI plugin not found: falling back to the classic builder. BuildKit-only build features (multi-arch, secrets, ssh, additional contexts, ...) will not be available"
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Image mtusi-messenger:lab3 Building
|
||||
Sending build context to Docker daemon 213.7kB␍
|
||||
Step 1/25 : ARG GO_VERSION=1.27.1
|
||||
Step 2/25 : ARG ALPINE_VERSION=3.22
|
||||
Step 3/25 : FROM golang:${GO_VERSION}-alpine AS build
|
||||
---> 8a5910f31396
|
||||
Step 4/25 : ARG TARGETOS
|
||||
---> Using cache
|
||||
---> d5f2c47ea7a5
|
||||
Step 5/25 : ARG TARGETARCH
|
||||
---> Using cache
|
||||
---> 047ee34b445c
|
||||
Step 6/25 : ARG VERSION=dev
|
||||
---> Using cache
|
||||
---> a529d045efeb
|
||||
Step 7/25 : ENV GOTOOLCHAIN=local
|
||||
---> Using cache
|
||||
---> 428f1b16b5c5
|
||||
Step 8/25 : WORKDIR /opt
|
||||
---> Using cache
|
||||
---> f37febf8b423
|
||||
Step 9/25 : COPY go.mod go.sum ./
|
||||
---> Using cache
|
||||
---> c4015f597b99
|
||||
Step 10/25 : RUN go mod download
|
||||
---> Using cache
|
||||
---> 34ef6a6167b0
|
||||
Step 11/25 : ARG GOFLAGS="-p=2"
|
||||
---> Using cache
|
||||
---> deb54a0ce57a
|
||||
Step 12/25 : ENV GOFLAGS=$GOFLAGS
|
||||
---> Using cache
|
||||
---> 3da36569422d
|
||||
Step 13/25 : COPY . .
|
||||
---> Using cache
|
||||
---> 596dc1ab02d1
|
||||
Step 14/25 : RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/messenger ./cmd/messenger && CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -trimpath -buildvcs=false -tags timetzdata -ldflags="-s -w -X main.version=${VERSION}" -o /out/migrate ./cmd/migrate
|
||||
---> Using cache
|
||||
---> 01aa8bc6200d
|
||||
Step 15/25 : FROM alpine:${ALPINE_VERSION} AS runtime
|
||||
---> 5291449c3df7
|
||||
Step 16/25 : RUN apk add --no-cache ca-certificates wget && addgroup -S -g 10001 app && adduser -S -D -H -u 10001 -G app app
|
||||
---> Using cache
|
||||
---> f47b074d9bd5
|
||||
Step 17/25 : COPY --from=build --chown=10001:10001 /out/messenger /usr/local/bin/messenger
|
||||
---> Using cache
|
||||
---> 50fc6abe3b04
|
||||
Step 18/25 : COPY --from=build --chown=10001:10001 /out/migrate /usr/local/bin/migrate
|
||||
---> Using cache
|
||||
---> 9bf6afe0256d
|
||||
Step 19/25 : COPY --chown=10001:10001 config/dev/config.yaml /etc/messenger/dev/config.yaml
|
||||
---> Using cache
|
||||
---> 0d1870a325ec
|
||||
Step 20/25 : USER 10001:10001
|
||||
---> Using cache
|
||||
---> 1991f2ae06cc
|
||||
Step 21/25 : EXPOSE 8080
|
||||
---> Using cache
|
||||
---> 762d1bfb7606
|
||||
Step 22/25 : STOPSIGNAL SIGTERM
|
||||
---> Using cache
|
||||
---> 8a9d8f4f7101
|
||||
Step 23/25 : HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 CMD wget -q -O /dev/null "http://127.0.0.1:${SERVER_PORT:-8080}/health/live" || exit 1
|
||||
---> Using cache
|
||||
---> 65dea502a3f3
|
||||
Step 24/25 : ENTRYPOINT ["/usr/local/bin/messenger"]
|
||||
---> Using cache
|
||||
---> 83bbee72905e
|
||||
Step 25/25 : LABEL com.docker.compose.image.builder=classic
|
||||
---> Using cache
|
||||
---> 037f969d5ea1
|
||||
Successfully built 037f969d5ea1
|
||||
Successfully tagged mtusi-messenger:lab3
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Image mtusi-messenger:lab3 Built
|
||||
Container mtusi-messenger-lab3-api-13 Recreate
|
||||
Container mtusi-messenger-lab3-api-14 Recreate
|
||||
Container mtusi-messenger-lab3-api-13 Recreated
|
||||
Container mtusi-messenger-lab3-api-14 Recreated
|
||||
Container mtusi-messenger-lab3-api-14 Starting
|
||||
Container mtusi-messenger-lab3-api-14 Started
|
||||
Container mtusi-messenger-lab3-api-13 Starting
|
||||
Container mtusi-messenger-lab3-api-13 Started
|
||||
replicas before: 2; instances seen through LB: 2
|
||||
Container mtusi-messenger-lab3-api-13 Running
|
||||
Container mtusi-messenger-lab3-api-14 Creating
|
||||
Container mtusi-messenger-lab3-api-14 Created
|
||||
Container mtusi-messenger-lab3-api-14 Starting
|
||||
Container mtusi-messenger-lab3-api-14 Started
|
||||
step 1: removed 54a7e7888b5f at 2026-10-15T19:03:20Z, 2 healthy replicas served again at 2026-10-15T19:03:26Z
|
||||
Container mtusi-messenger-lab3-api-14 Running
|
||||
Container mtusi-messenger-lab3-api-15 Creating
|
||||
Container mtusi-messenger-lab3-api-15 Created
|
||||
Container mtusi-messenger-lab3-api-15 Starting
|
||||
Container mtusi-messenger-lab3-api-15 Started
|
||||
step 2: removed 388ebcb74200 at 2026-10-15T19:03:26Z, 2 healthy replicas served again at 2026-10-15T19:03:31Z
|
||||
|
||||
load summary (tolerant generator):
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; failures counted, not raised",
|
||||
"requested_duration_seconds": 45.0,
|
||||
"elapsed_seconds": 45.014,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 89560,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"errors_by_kind": {},
|
||||
"successful_rps": 1989.584,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.905,
|
||||
"p95": 6.02,
|
||||
"p99": 7.984
|
||||
},
|
||||
"instances": {
|
||||
"388ebcb74200": 7524,
|
||||
"73d07d7d76db": 45354,
|
||||
"cc6274635bd6": 36682
|
||||
},
|
||||
"note": "Percentiles cover successful writes only; transitional errors are expected during a rolling update."
|
||||
}
|
||||
|
||||
LB responses with 5xx during the update: 0
|
||||
|
||||
API containers after the update:
|
||||
mtusi-messenger-lab3-api-15 Up 41 seconds (healthy)
|
||||
mtusi-messenger-lab3-api-14 Up 46 seconds (healthy)
|
||||
+2
-2
@@ -1,2 +1,2 @@
|
||||
env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1 python3 tests/smoke.py --base-url "http://127.0.0.1:8080"
|
||||
PASS: lab1 public API scenario; infrastructure and grading evidence remain separate.
|
||||
python3 tests/smoke.py --base-url "http://localhost:8080"
|
||||
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# Lab3 stand evidence
|
||||
# generated: 2026-10-16T13:38:19Z
|
||||
|
||||
## docker ps (ports)
|
||||
mtusi-messenger-lab3-api-6 | 8080/tcp
|
||||
mtusi-messenger-lab3-api-5 | 8080/tcp
|
||||
mtusi-messenger-lab3-lb-1 | 127.0.0.1:8404->8404/tcp, 127.0.0.1:8080->80/tcp
|
||||
mtusi-messenger-lab3-postgres-1 | 5432/tcp
|
||||
mtusi-messenger-lab3-redis-1 | 6379/tcp
|
||||
|
||||
## compose config: limits/replicas/published
|
||||
api:
|
||||
replicas: 2
|
||||
cpus: 0.5
|
||||
memory: "268435456"
|
||||
lb:
|
||||
cpus: 0.25
|
||||
memory: "67108864"
|
||||
published: "8080"
|
||||
published: "8404"
|
||||
migrate:
|
||||
cpus: 0.5
|
||||
memory: "268435456"
|
||||
postgres:
|
||||
cpus: 0.5
|
||||
memory: "402653184"
|
||||
redis:
|
||||
cpus: 0.25
|
||||
memory: "201326592"
|
||||
default:
|
||||
build:
|
||||
image: mtusi-messenger:lab3
|
||||
|
||||
container_name: absent
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117712,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1961.212,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.984,
|
||||
"p95": 6.09,
|
||||
"p99": 8.13
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 114389,
|
||||
"failed_requests": 340,
|
||||
"error_ratio": 0.002964,
|
||||
"successful_rps": 1905.841,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.032,
|
||||
"p95": 6.456,
|
||||
"p99": 9.098
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117266,
|
||||
"failed_requests": 1984,
|
||||
"error_ratio": 0.016637,
|
||||
"successful_rps": 1953.781,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.923,
|
||||
"p95": 6.062,
|
||||
"p99": 8.041
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.018,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 111442,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1856.809,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.132,
|
||||
"p95": 6.761,
|
||||
"p99": 9.34
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.016,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 113438,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1890.142,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.133,
|
||||
"p95": 6.416,
|
||||
"p99": 8.487
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 109073,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1817.2,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.258,
|
||||
"p95": 6.758,
|
||||
"p99": 9.171
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 113740,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1895.027,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.031,
|
||||
"p95": 6.507,
|
||||
"p99": 8.906
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117433,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1956.481,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.957,
|
||||
"p95": 6.18,
|
||||
"p99": 8.499
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.014,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 107236,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1786.838,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.288,
|
||||
"p95": 7.051,
|
||||
"p99": 10.001
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"db1cpu","replicas":2,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"g05","replicas":2,"total_cpu":0.5,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"g10","replicas":2,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"g15","replicas":2,"total_cpu":1.5,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"pool10","replicas":4,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"pool5","replicas":4,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"r1","replicas":1,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"r2","replicas":2,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
@@ -0,0 +1 @@
|
||||
{"label":"r4","replicas":4,"total_cpu":1.0,"total_mem_mb":768,"duration":60,"concurrency":8,"warmup":15}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
@@ -0,0 +1,101 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T19:05:43Z,mtusi-messenger-lab3-api-14,19.81%,171.3MiB / 384MiB
|
||||
2026-10-15T19:05:43Z,mtusi-messenger-lab3-api-15,19.83%,169.6MiB / 384MiB
|
||||
2026-10-15T19:05:43Z,mtusi-messenger-lab3-postgres-1,38.36%,78.45MiB / 384MiB
|
||||
2026-10-15T19:05:43Z,mtusi-messenger-lab3-lb-1,12.90%,4.754MiB / 64MiB
|
||||
2026-10-15T19:05:43Z,mtusi-messenger-lab3-redis-1,0.22%,6.32MiB / 192MiB
|
||||
2026-10-15T19:05:46Z,mtusi-messenger-lab3-api-14,19.69%,11.96MiB / 384MiB
|
||||
2026-10-15T19:05:46Z,mtusi-messenger-lab3-api-15,20.57%,11.95MiB / 384MiB
|
||||
2026-10-15T19:05:46Z,mtusi-messenger-lab3-postgres-1,57.52%,83.28MiB / 384MiB
|
||||
2026-10-15T19:05:46Z,mtusi-messenger-lab3-lb-1,12.32%,4.758MiB / 64MiB
|
||||
2026-10-15T19:05:46Z,mtusi-messenger-lab3-redis-1,0.77%,6.32MiB / 192MiB
|
||||
2026-10-15T19:05:49Z,mtusi-messenger-lab3-api-14,20.20%,11.88MiB / 384MiB
|
||||
2026-10-15T19:05:49Z,mtusi-messenger-lab3-api-15,20.31%,12.03MiB / 384MiB
|
||||
2026-10-15T19:05:49Z,mtusi-messenger-lab3-postgres-1,58.70%,86.24MiB / 384MiB
|
||||
2026-10-15T19:05:49Z,mtusi-messenger-lab3-lb-1,12.39%,4.758MiB / 64MiB
|
||||
2026-10-15T19:05:49Z,mtusi-messenger-lab3-redis-1,0.24%,6.32MiB / 192MiB
|
||||
2026-10-15T19:05:52Z,mtusi-messenger-lab3-api-14,19.64%,12.94MiB / 384MiB
|
||||
2026-10-15T19:05:52Z,mtusi-messenger-lab3-api-15,20.01%,11.41MiB / 384MiB
|
||||
2026-10-15T19:05:52Z,mtusi-messenger-lab3-postgres-1,58.35%,88.61MiB / 384MiB
|
||||
2026-10-15T19:05:52Z,mtusi-messenger-lab3-lb-1,12.27%,4.727MiB / 64MiB
|
||||
2026-10-15T19:05:52Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:05:55Z,mtusi-messenger-lab3-api-14,20.22%,12.78MiB / 384MiB
|
||||
2026-10-15T19:05:55Z,mtusi-messenger-lab3-api-15,19.27%,11.62MiB / 384MiB
|
||||
2026-10-15T19:05:55Z,mtusi-messenger-lab3-postgres-1,57.95%,92.84MiB / 384MiB
|
||||
2026-10-15T19:05:55Z,mtusi-messenger-lab3-lb-1,12.21%,4.738MiB / 64MiB
|
||||
2026-10-15T19:05:55Z,mtusi-messenger-lab3-redis-1,0.78%,6.32MiB / 192MiB
|
||||
2026-10-15T19:05:58Z,mtusi-messenger-lab3-api-14,20.70%,12.79MiB / 384MiB
|
||||
2026-10-15T19:05:58Z,mtusi-messenger-lab3-api-15,21.21%,11.7MiB / 384MiB
|
||||
2026-10-15T19:05:58Z,mtusi-messenger-lab3-postgres-1,61.29%,96.34MiB / 384MiB
|
||||
2026-10-15T19:05:58Z,mtusi-messenger-lab3-lb-1,12.84%,4.762MiB / 64MiB
|
||||
2026-10-15T19:05:58Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:01Z,mtusi-messenger-lab3-api-14,21.09%,12.96MiB / 384MiB
|
||||
2026-10-15T19:06:01Z,mtusi-messenger-lab3-api-15,20.33%,11.8MiB / 384MiB
|
||||
2026-10-15T19:06:01Z,mtusi-messenger-lab3-postgres-1,58.81%,102.3MiB / 384MiB
|
||||
2026-10-15T19:06:01Z,mtusi-messenger-lab3-lb-1,12.05%,4.754MiB / 64MiB
|
||||
2026-10-15T19:06:01Z,mtusi-messenger-lab3-redis-1,0.83%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:04Z,mtusi-messenger-lab3-api-14,20.21%,12.85MiB / 384MiB
|
||||
2026-10-15T19:06:04Z,mtusi-messenger-lab3-api-15,19.93%,11.73MiB / 384MiB
|
||||
2026-10-15T19:06:04Z,mtusi-messenger-lab3-postgres-1,59.51%,105.7MiB / 384MiB
|
||||
2026-10-15T19:06:04Z,mtusi-messenger-lab3-lb-1,12.60%,4.754MiB / 64MiB
|
||||
2026-10-15T19:06:04Z,mtusi-messenger-lab3-redis-1,0.25%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:07Z,mtusi-messenger-lab3-api-14,19.57%,12.88MiB / 384MiB
|
||||
2026-10-15T19:06:07Z,mtusi-messenger-lab3-api-15,19.51%,11.56MiB / 384MiB
|
||||
2026-10-15T19:06:07Z,mtusi-messenger-lab3-postgres-1,54.92%,108.8MiB / 384MiB
|
||||
2026-10-15T19:06:07Z,mtusi-messenger-lab3-lb-1,11.80%,4.73MiB / 64MiB
|
||||
2026-10-15T19:06:07Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:10Z,mtusi-messenger-lab3-api-14,19.80%,12.83MiB / 384MiB
|
||||
2026-10-15T19:06:10Z,mtusi-messenger-lab3-api-15,20.15%,11.79MiB / 384MiB
|
||||
2026-10-15T19:06:10Z,mtusi-messenger-lab3-postgres-1,55.61%,111.5MiB / 384MiB
|
||||
2026-10-15T19:06:10Z,mtusi-messenger-lab3-lb-1,12.71%,4.727MiB / 64MiB
|
||||
2026-10-15T19:06:10Z,mtusi-messenger-lab3-redis-1,0.73%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:13Z,mtusi-messenger-lab3-api-14,19.62%,12.82MiB / 384MiB
|
||||
2026-10-15T19:06:13Z,mtusi-messenger-lab3-api-15,19.45%,11.72MiB / 384MiB
|
||||
2026-10-15T19:06:13Z,mtusi-messenger-lab3-postgres-1,56.81%,113.5MiB / 384MiB
|
||||
2026-10-15T19:06:13Z,mtusi-messenger-lab3-lb-1,11.95%,4.715MiB / 64MiB
|
||||
2026-10-15T19:06:13Z,mtusi-messenger-lab3-redis-1,0.24%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:15Z,mtusi-messenger-lab3-api-14,19.78%,12.93MiB / 384MiB
|
||||
2026-10-15T19:06:15Z,mtusi-messenger-lab3-api-15,19.93%,11.73MiB / 384MiB
|
||||
2026-10-15T19:06:15Z,mtusi-messenger-lab3-postgres-1,58.14%,116.5MiB / 384MiB
|
||||
2026-10-15T19:06:15Z,mtusi-messenger-lab3-lb-1,12.32%,4.746MiB / 64MiB
|
||||
2026-10-15T19:06:15Z,mtusi-messenger-lab3-redis-1,0.73%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:18Z,mtusi-messenger-lab3-api-14,20.01%,12.91MiB / 384MiB
|
||||
2026-10-15T19:06:18Z,mtusi-messenger-lab3-api-15,19.95%,11.8MiB / 384MiB
|
||||
2026-10-15T19:06:18Z,mtusi-messenger-lab3-postgres-1,59.13%,119.9MiB / 384MiB
|
||||
2026-10-15T19:06:18Z,mtusi-messenger-lab3-lb-1,12.38%,4.746MiB / 64MiB
|
||||
2026-10-15T19:06:18Z,mtusi-messenger-lab3-redis-1,0.24%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:21Z,mtusi-messenger-lab3-api-14,20.05%,12.79MiB / 384MiB
|
||||
2026-10-15T19:06:21Z,mtusi-messenger-lab3-api-15,20.46%,11.82MiB / 384MiB
|
||||
2026-10-15T19:06:21Z,mtusi-messenger-lab3-postgres-1,56.55%,123.3MiB / 384MiB
|
||||
2026-10-15T19:06:21Z,mtusi-messenger-lab3-lb-1,11.91%,4.77MiB / 64MiB
|
||||
2026-10-15T19:06:21Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:25Z,mtusi-messenger-lab3-api-14,19.83%,13.04MiB / 384MiB
|
||||
2026-10-15T19:06:25Z,mtusi-messenger-lab3-api-15,19.91%,11.82MiB / 384MiB
|
||||
2026-10-15T19:06:25Z,mtusi-messenger-lab3-postgres-1,57.49%,125.2MiB / 384MiB
|
||||
2026-10-15T19:06:25Z,mtusi-messenger-lab3-lb-1,12.00%,4.789MiB / 64MiB
|
||||
2026-10-15T19:06:25Z,mtusi-messenger-lab3-redis-1,0.76%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:28Z,mtusi-messenger-lab3-api-14,20.71%,12.79MiB / 384MiB
|
||||
2026-10-15T19:06:28Z,mtusi-messenger-lab3-api-15,19.92%,11.71MiB / 384MiB
|
||||
2026-10-15T19:06:28Z,mtusi-messenger-lab3-postgres-1,59.82%,129.1MiB / 384MiB
|
||||
2026-10-15T19:06:28Z,mtusi-messenger-lab3-lb-1,12.80%,4.723MiB / 64MiB
|
||||
2026-10-15T19:06:28Z,mtusi-messenger-lab3-redis-1,0.25%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:31Z,mtusi-messenger-lab3-api-14,20.59%,12.79MiB / 384MiB
|
||||
2026-10-15T19:06:31Z,mtusi-messenger-lab3-api-15,19.69%,11.76MiB / 384MiB
|
||||
2026-10-15T19:06:31Z,mtusi-messenger-lab3-postgres-1,58.74%,132.7MiB / 384MiB
|
||||
2026-10-15T19:06:31Z,mtusi-messenger-lab3-lb-1,12.20%,4.703MiB / 64MiB
|
||||
2026-10-15T19:06:31Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:34Z,mtusi-messenger-lab3-api-14,20.17%,13MiB / 384MiB
|
||||
2026-10-15T19:06:34Z,mtusi-messenger-lab3-api-15,20.27%,11.76MiB / 384MiB
|
||||
2026-10-15T19:06:34Z,mtusi-messenger-lab3-postgres-1,58.51%,135.7MiB / 384MiB
|
||||
2026-10-15T19:06:34Z,mtusi-messenger-lab3-lb-1,12.09%,4.738MiB / 64MiB
|
||||
2026-10-15T19:06:34Z,mtusi-messenger-lab3-redis-1,0.23%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:37Z,mtusi-messenger-lab3-api-14,19.98%,12.88MiB / 384MiB
|
||||
2026-10-15T19:06:37Z,mtusi-messenger-lab3-api-15,20.61%,11.8MiB / 384MiB
|
||||
2026-10-15T19:06:37Z,mtusi-messenger-lab3-postgres-1,56.89%,139.2MiB / 384MiB
|
||||
2026-10-15T19:06:37Z,mtusi-messenger-lab3-lb-1,12.27%,4.754MiB / 64MiB
|
||||
2026-10-15T19:06:37Z,mtusi-messenger-lab3-redis-1,0.22%,6.32MiB / 192MiB
|
||||
2026-10-15T19:06:40Z,mtusi-messenger-lab3-api-14,20.58%,13.01MiB / 384MiB
|
||||
2026-10-15T19:06:40Z,mtusi-messenger-lab3-api-15,19.44%,11.7MiB / 384MiB
|
||||
2026-10-15T19:06:40Z,mtusi-messenger-lab3-postgres-1,59.27%,142.4MiB / 384MiB
|
||||
2026-10-15T19:06:40Z,mtusi-messenger-lab3-lb-1,12.31%,4.746MiB / 64MiB
|
||||
2026-10-15T19:06:40Z,mtusi-messenger-lab3-redis-1,0.25%,6.32MiB / 192MiB
|
||||
|
@@ -0,0 +1,106 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:52:00Z,mtusi-messenger-lab3-api-12,7.06%,139MiB / 384MiB
|
||||
2026-10-15T18:52:00Z,mtusi-messenger-lab3-api-13,23.54%,139.3MiB / 384MiB
|
||||
2026-10-15T18:52:00Z,mtusi-messenger-lab3-lb-1,0.13%,5.102MiB / 64MiB
|
||||
2026-10-15T18:52:00Z,mtusi-messenger-lab3-postgres-1,1.05%,279.3MiB / 512MiB
|
||||
2026-10-15T18:52:00Z,mtusi-messenger-lab3-redis-1,0.40%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:03Z,mtusi-messenger-lab3-api-12,19.79%,194.5MiB / 384MiB
|
||||
2026-10-15T18:52:03Z,mtusi-messenger-lab3-api-13,20.37%,195.4MiB / 384MiB
|
||||
2026-10-15T18:52:03Z,mtusi-messenger-lab3-lb-1,12.28%,5.48MiB / 64MiB
|
||||
2026-10-15T18:52:03Z,mtusi-messenger-lab3-postgres-1,60.79%,282.8MiB / 512MiB
|
||||
2026-10-15T18:52:03Z,mtusi-messenger-lab3-redis-1,0.20%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:06Z,mtusi-messenger-lab3-api-12,20.15%,11.92MiB / 384MiB
|
||||
2026-10-15T18:52:06Z,mtusi-messenger-lab3-api-13,20.76%,12.44MiB / 384MiB
|
||||
2026-10-15T18:52:06Z,mtusi-messenger-lab3-lb-1,12.45%,5.492MiB / 64MiB
|
||||
2026-10-15T18:52:06Z,mtusi-messenger-lab3-postgres-1,59.77%,282.9MiB / 512MiB
|
||||
2026-10-15T18:52:06Z,mtusi-messenger-lab3-redis-1,0.79%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:09Z,mtusi-messenger-lab3-api-12,20.05%,11.88MiB / 384MiB
|
||||
2026-10-15T18:52:09Z,mtusi-messenger-lab3-api-13,20.18%,12.37MiB / 384MiB
|
||||
2026-10-15T18:52:09Z,mtusi-messenger-lab3-lb-1,12.45%,5.477MiB / 64MiB
|
||||
2026-10-15T18:52:09Z,mtusi-messenger-lab3-postgres-1,59.67%,283.2MiB / 512MiB
|
||||
2026-10-15T18:52:09Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:12Z,mtusi-messenger-lab3-api-12,20.46%,11.69MiB / 384MiB
|
||||
2026-10-15T18:52:12Z,mtusi-messenger-lab3-api-13,20.21%,11.68MiB / 384MiB
|
||||
2026-10-15T18:52:12Z,mtusi-messenger-lab3-lb-1,11.98%,5.234MiB / 64MiB
|
||||
2026-10-15T18:52:12Z,mtusi-messenger-lab3-postgres-1,58.24%,283.1MiB / 512MiB
|
||||
2026-10-15T18:52:12Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:15Z,mtusi-messenger-lab3-api-12,20.39%,11.67MiB / 384MiB
|
||||
2026-10-15T18:52:15Z,mtusi-messenger-lab3-api-13,20.15%,11.75MiB / 384MiB
|
||||
2026-10-15T18:52:15Z,mtusi-messenger-lab3-lb-1,12.51%,5.246MiB / 64MiB
|
||||
2026-10-15T18:52:15Z,mtusi-messenger-lab3-postgres-1,59.77%,283.1MiB / 512MiB
|
||||
2026-10-15T18:52:15Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:18Z,mtusi-messenger-lab3-api-12,19.92%,11.61MiB / 384MiB
|
||||
2026-10-15T18:52:18Z,mtusi-messenger-lab3-api-13,21.09%,11.73MiB / 384MiB
|
||||
2026-10-15T18:52:18Z,mtusi-messenger-lab3-lb-1,12.06%,5.219MiB / 64MiB
|
||||
2026-10-15T18:52:18Z,mtusi-messenger-lab3-postgres-1,57.45%,285.5MiB / 512MiB
|
||||
2026-10-15T18:52:18Z,mtusi-messenger-lab3-redis-1,0.25%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:21Z,mtusi-messenger-lab3-api-12,20.07%,11.55MiB / 384MiB
|
||||
2026-10-15T18:52:21Z,mtusi-messenger-lab3-api-13,19.96%,11.67MiB / 384MiB
|
||||
2026-10-15T18:52:21Z,mtusi-messenger-lab3-lb-1,12.51%,5.223MiB / 64MiB
|
||||
2026-10-15T18:52:21Z,mtusi-messenger-lab3-postgres-1,59.61%,285.8MiB / 512MiB
|
||||
2026-10-15T18:52:21Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:25Z,mtusi-messenger-lab3-api-12,19.43%,11.62MiB / 384MiB
|
||||
2026-10-15T18:52:25Z,mtusi-messenger-lab3-api-13,19.64%,11.57MiB / 384MiB
|
||||
2026-10-15T18:52:25Z,mtusi-messenger-lab3-lb-1,12.15%,5.219MiB / 64MiB
|
||||
2026-10-15T18:52:25Z,mtusi-messenger-lab3-postgres-1,57.16%,286.2MiB / 512MiB
|
||||
2026-10-15T18:52:25Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:28Z,mtusi-messenger-lab3-api-12,20.51%,11.68MiB / 384MiB
|
||||
2026-10-15T18:52:28Z,mtusi-messenger-lab3-api-13,19.61%,11.62MiB / 384MiB
|
||||
2026-10-15T18:52:28Z,mtusi-messenger-lab3-lb-1,12.39%,5.234MiB / 64MiB
|
||||
2026-10-15T18:52:28Z,mtusi-messenger-lab3-postgres-1,58.61%,286.2MiB / 512MiB
|
||||
2026-10-15T18:52:28Z,mtusi-messenger-lab3-redis-1,0.25%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:31Z,mtusi-messenger-lab3-api-12,19.92%,11.63MiB / 384MiB
|
||||
2026-10-15T18:52:31Z,mtusi-messenger-lab3-api-13,19.68%,11.61MiB / 384MiB
|
||||
2026-10-15T18:52:31Z,mtusi-messenger-lab3-lb-1,11.99%,5.258MiB / 64MiB
|
||||
2026-10-15T18:52:31Z,mtusi-messenger-lab3-postgres-1,58.08%,286.6MiB / 512MiB
|
||||
2026-10-15T18:52:31Z,mtusi-messenger-lab3-redis-1,0.75%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:34Z,mtusi-messenger-lab3-api-12,20.42%,11.14MiB / 384MiB
|
||||
2026-10-15T18:52:34Z,mtusi-messenger-lab3-api-13,20.22%,11.64MiB / 384MiB
|
||||
2026-10-15T18:52:34Z,mtusi-messenger-lab3-lb-1,12.20%,5.215MiB / 64MiB
|
||||
2026-10-15T18:52:34Z,mtusi-messenger-lab3-postgres-1,59.14%,286.9MiB / 512MiB
|
||||
2026-10-15T18:52:34Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:37Z,mtusi-messenger-lab3-api-12,20.04%,11.19MiB / 384MiB
|
||||
2026-10-15T18:52:37Z,mtusi-messenger-lab3-api-13,19.44%,11.64MiB / 384MiB
|
||||
2026-10-15T18:52:37Z,mtusi-messenger-lab3-lb-1,10.32%,5.086MiB / 64MiB
|
||||
2026-10-15T18:52:37Z,mtusi-messenger-lab3-postgres-1,57.77%,286.7MiB / 512MiB
|
||||
2026-10-15T18:52:37Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:40Z,mtusi-messenger-lab3-api-12,20.29%,11.27MiB / 384MiB
|
||||
2026-10-15T18:52:40Z,mtusi-messenger-lab3-api-13,20.07%,11.46MiB / 384MiB
|
||||
2026-10-15T18:52:40Z,mtusi-messenger-lab3-lb-1,12.58%,5.246MiB / 64MiB
|
||||
2026-10-15T18:52:40Z,mtusi-messenger-lab3-postgres-1,58.97%,286.8MiB / 512MiB
|
||||
2026-10-15T18:52:40Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:43Z,mtusi-messenger-lab3-api-12,20.92%,11.27MiB / 384MiB
|
||||
2026-10-15T18:52:43Z,mtusi-messenger-lab3-api-13,19.92%,11.21MiB / 384MiB
|
||||
2026-10-15T18:52:43Z,mtusi-messenger-lab3-lb-1,12.44%,5.238MiB / 64MiB
|
||||
2026-10-15T18:52:43Z,mtusi-messenger-lab3-postgres-1,59.46%,286.9MiB / 512MiB
|
||||
2026-10-15T18:52:43Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:46Z,mtusi-messenger-lab3-api-12,19.86%,11.27MiB / 384MiB
|
||||
2026-10-15T18:52:46Z,mtusi-messenger-lab3-api-13,19.73%,11.21MiB / 384MiB
|
||||
2026-10-15T18:52:46Z,mtusi-messenger-lab3-lb-1,12.33%,5.191MiB / 64MiB
|
||||
2026-10-15T18:52:46Z,mtusi-messenger-lab3-postgres-1,59.02%,286.9MiB / 512MiB
|
||||
2026-10-15T18:52:46Z,mtusi-messenger-lab3-redis-1,0.88%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:49Z,mtusi-messenger-lab3-api-12,20.89%,11.3MiB / 384MiB
|
||||
2026-10-15T18:52:49Z,mtusi-messenger-lab3-api-13,20.30%,11.21MiB / 384MiB
|
||||
2026-10-15T18:52:49Z,mtusi-messenger-lab3-lb-1,12.62%,5.25MiB / 64MiB
|
||||
2026-10-15T18:52:49Z,mtusi-messenger-lab3-postgres-1,60.37%,287MiB / 512MiB
|
||||
2026-10-15T18:52:49Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:52Z,mtusi-messenger-lab3-api-12,20.47%,11.3MiB / 384MiB
|
||||
2026-10-15T18:52:52Z,mtusi-messenger-lab3-api-13,19.29%,11.25MiB / 384MiB
|
||||
2026-10-15T18:52:52Z,mtusi-messenger-lab3-lb-1,11.77%,5.246MiB / 64MiB
|
||||
2026-10-15T18:52:52Z,mtusi-messenger-lab3-postgres-1,65.73%,288.6MiB / 512MiB
|
||||
2026-10-15T18:52:52Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:55Z,mtusi-messenger-lab3-api-12,20.53%,11.3MiB / 384MiB
|
||||
2026-10-15T18:52:55Z,mtusi-messenger-lab3-api-13,20.27%,11.25MiB / 384MiB
|
||||
2026-10-15T18:52:55Z,mtusi-messenger-lab3-lb-1,12.43%,5.16MiB / 64MiB
|
||||
2026-10-15T18:52:55Z,mtusi-messenger-lab3-postgres-1,70.45%,288.2MiB / 512MiB
|
||||
2026-10-15T18:52:55Z,mtusi-messenger-lab3-redis-1,0.78%,8.898MiB / 192MiB
|
||||
2026-10-15T18:52:58Z,mtusi-messenger-lab3-api-12,20.51%,11.3MiB / 384MiB
|
||||
2026-10-15T18:52:58Z,mtusi-messenger-lab3-api-13,20.69%,11.25MiB / 384MiB
|
||||
2026-10-15T18:52:58Z,mtusi-messenger-lab3-lb-1,12.78%,5.238MiB / 64MiB
|
||||
2026-10-15T18:52:58Z,mtusi-messenger-lab3-postgres-1,56.36%,289.3MiB / 512MiB
|
||||
2026-10-15T18:52:58Z,mtusi-messenger-lab3-redis-1,0.25%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:01Z,mtusi-messenger-lab3-lb-1,3.84%,5.23MiB / 64MiB
|
||||
2026-10-15T18:53:01Z,mtusi-messenger-lab3-postgres-1,21.56%,282.9MiB / 512MiB
|
||||
2026-10-15T18:53:01Z,mtusi-messenger-lab3-redis-1,0.80%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:01Z,mtusi-messenger-lab3-api-13,18.83%,135.3MiB / 384MiB
|
||||
2026-10-15T18:53:01Z,mtusi-messenger-lab3-api-12,18.89%,135.2MiB / 384MiB
|
||||
|
@@ -0,0 +1,101 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:53:18Z,mtusi-messenger-lab3-api-13,19.84%,170.9MiB / 384MiB
|
||||
2026-10-15T18:53:18Z,mtusi-messenger-lab3-api-12,19.64%,171MiB / 384MiB
|
||||
2026-10-15T18:53:18Z,mtusi-messenger-lab3-lb-1,12.57%,5.191MiB / 64MiB
|
||||
2026-10-15T18:53:18Z,mtusi-messenger-lab3-postgres-1,59.81%,318.8MiB / 512MiB
|
||||
2026-10-15T18:53:18Z,mtusi-messenger-lab3-redis-1,0.20%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:21Z,mtusi-messenger-lab3-api-13,19.80%,11.41MiB / 384MiB
|
||||
2026-10-15T18:53:21Z,mtusi-messenger-lab3-api-12,19.90%,11.51MiB / 384MiB
|
||||
2026-10-15T18:53:21Z,mtusi-messenger-lab3-lb-1,12.17%,5.254MiB / 64MiB
|
||||
2026-10-15T18:53:21Z,mtusi-messenger-lab3-postgres-1,58.11%,318.9MiB / 512MiB
|
||||
2026-10-15T18:53:21Z,mtusi-messenger-lab3-redis-1,0.75%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:24Z,mtusi-messenger-lab3-api-13,20.77%,11.41MiB / 384MiB
|
||||
2026-10-15T18:53:24Z,mtusi-messenger-lab3-api-12,19.82%,11.32MiB / 384MiB
|
||||
2026-10-15T18:53:24Z,mtusi-messenger-lab3-lb-1,12.92%,5.219MiB / 64MiB
|
||||
2026-10-15T18:53:24Z,mtusi-messenger-lab3-postgres-1,58.24%,319.4MiB / 512MiB
|
||||
2026-10-15T18:53:24Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:27Z,mtusi-messenger-lab3-api-13,21.25%,11.14MiB / 384MiB
|
||||
2026-10-15T18:53:27Z,mtusi-messenger-lab3-api-12,20.94%,11.16MiB / 384MiB
|
||||
2026-10-15T18:53:27Z,mtusi-messenger-lab3-lb-1,12.71%,5.223MiB / 64MiB
|
||||
2026-10-15T18:53:27Z,mtusi-messenger-lab3-postgres-1,60.44%,319.7MiB / 512MiB
|
||||
2026-10-15T18:53:27Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:31Z,mtusi-messenger-lab3-api-13,20.42%,11.13MiB / 384MiB
|
||||
2026-10-15T18:53:31Z,mtusi-messenger-lab3-api-12,20.45%,11.16MiB / 384MiB
|
||||
2026-10-15T18:53:31Z,mtusi-messenger-lab3-lb-1,12.43%,5.238MiB / 64MiB
|
||||
2026-10-15T18:53:31Z,mtusi-messenger-lab3-postgres-1,57.47%,331.4MiB / 512MiB
|
||||
2026-10-15T18:53:31Z,mtusi-messenger-lab3-redis-1,0.77%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:34Z,mtusi-messenger-lab3-api-13,3.14%,11.13MiB / 384MiB
|
||||
2026-10-15T18:53:34Z,mtusi-messenger-lab3-api-12,3.21%,11.09MiB / 384MiB
|
||||
2026-10-15T18:53:34Z,mtusi-messenger-lab3-lb-1,1.82%,5.48MiB / 64MiB
|
||||
2026-10-15T18:53:34Z,mtusi-messenger-lab3-postgres-1,9.18%,331.3MiB / 512MiB
|
||||
2026-10-15T18:53:34Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:37Z,mtusi-messenger-lab3-api-13,20.62%,11.12MiB / 384MiB
|
||||
2026-10-15T18:53:37Z,mtusi-messenger-lab3-api-12,20.29%,11.08MiB / 384MiB
|
||||
2026-10-15T18:53:37Z,mtusi-messenger-lab3-lb-1,12.12%,5.223MiB / 64MiB
|
||||
2026-10-15T18:53:37Z,mtusi-messenger-lab3-postgres-1,57.80%,331.7MiB / 512MiB
|
||||
2026-10-15T18:53:37Z,mtusi-messenger-lab3-redis-1,0.77%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:40Z,mtusi-messenger-lab3-api-13,20.17%,11.12MiB / 384MiB
|
||||
2026-10-15T18:53:40Z,mtusi-messenger-lab3-api-12,20.36%,11.15MiB / 384MiB
|
||||
2026-10-15T18:53:40Z,mtusi-messenger-lab3-lb-1,12.44%,5.238MiB / 64MiB
|
||||
2026-10-15T18:53:40Z,mtusi-messenger-lab3-postgres-1,58.95%,331.6MiB / 512MiB
|
||||
2026-10-15T18:53:40Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:43Z,mtusi-messenger-lab3-api-13,20.31%,11.02MiB / 384MiB
|
||||
2026-10-15T18:53:43Z,mtusi-messenger-lab3-api-12,20.91%,11.16MiB / 384MiB
|
||||
2026-10-15T18:53:43Z,mtusi-messenger-lab3-lb-1,12.66%,5.195MiB / 64MiB
|
||||
2026-10-15T18:53:43Z,mtusi-messenger-lab3-postgres-1,59.18%,331.6MiB / 512MiB
|
||||
2026-10-15T18:53:43Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:46Z,mtusi-messenger-lab3-api-13,19.73%,11.05MiB / 384MiB
|
||||
2026-10-15T18:53:46Z,mtusi-messenger-lab3-api-12,20.01%,11.14MiB / 384MiB
|
||||
2026-10-15T18:53:46Z,mtusi-messenger-lab3-lb-1,12.33%,5.254MiB / 64MiB
|
||||
2026-10-15T18:53:46Z,mtusi-messenger-lab3-postgres-1,58.92%,331.6MiB / 512MiB
|
||||
2026-10-15T18:53:46Z,mtusi-messenger-lab3-redis-1,0.85%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:49Z,mtusi-messenger-lab3-api-13,19.61%,11.05MiB / 384MiB
|
||||
2026-10-15T18:53:49Z,mtusi-messenger-lab3-api-12,20.70%,11.09MiB / 384MiB
|
||||
2026-10-15T18:53:49Z,mtusi-messenger-lab3-lb-1,12.37%,5.207MiB / 64MiB
|
||||
2026-10-15T18:53:49Z,mtusi-messenger-lab3-postgres-1,58.94%,331.8MiB / 512MiB
|
||||
2026-10-15T18:53:49Z,mtusi-messenger-lab3-redis-1,0.21%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:52Z,mtusi-messenger-lab3-api-13,17.84%,11MiB / 384MiB
|
||||
2026-10-15T18:53:52Z,mtusi-messenger-lab3-api-12,18.65%,11.12MiB / 384MiB
|
||||
2026-10-15T18:53:52Z,mtusi-messenger-lab3-lb-1,11.23%,5.18MiB / 64MiB
|
||||
2026-10-15T18:53:52Z,mtusi-messenger-lab3-postgres-1,60.38%,337.7MiB / 512MiB
|
||||
2026-10-15T18:53:52Z,mtusi-messenger-lab3-redis-1,0.21%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:55Z,mtusi-messenger-lab3-api-13,20.26%,11.01MiB / 384MiB
|
||||
2026-10-15T18:53:55Z,mtusi-messenger-lab3-api-12,20.57%,11.11MiB / 384MiB
|
||||
2026-10-15T18:53:55Z,mtusi-messenger-lab3-lb-1,12.39%,5.215MiB / 64MiB
|
||||
2026-10-15T18:53:55Z,mtusi-messenger-lab3-postgres-1,59.56%,334.1MiB / 512MiB
|
||||
2026-10-15T18:53:55Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:53:58Z,mtusi-messenger-lab3-api-13,20.38%,11.08MiB / 384MiB
|
||||
2026-10-15T18:53:58Z,mtusi-messenger-lab3-api-12,20.41%,11.27MiB / 384MiB
|
||||
2026-10-15T18:53:58Z,mtusi-messenger-lab3-lb-1,12.51%,5.25MiB / 64MiB
|
||||
2026-10-15T18:53:58Z,mtusi-messenger-lab3-postgres-1,59.53%,335.6MiB / 512MiB
|
||||
2026-10-15T18:53:58Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:01Z,mtusi-messenger-lab3-api-13,20.28%,10.96MiB / 384MiB
|
||||
2026-10-15T18:54:01Z,mtusi-messenger-lab3-api-12,19.98%,11.16MiB / 384MiB
|
||||
2026-10-15T18:54:01Z,mtusi-messenger-lab3-lb-1,12.11%,5.23MiB / 64MiB
|
||||
2026-10-15T18:54:01Z,mtusi-messenger-lab3-postgres-1,58.99%,335.7MiB / 512MiB
|
||||
2026-10-15T18:54:01Z,mtusi-messenger-lab3-redis-1,0.80%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:04Z,mtusi-messenger-lab3-api-13,19.75%,10.92MiB / 384MiB
|
||||
2026-10-15T18:54:04Z,mtusi-messenger-lab3-api-12,20.34%,11.27MiB / 384MiB
|
||||
2026-10-15T18:54:04Z,mtusi-messenger-lab3-lb-1,12.47%,5.23MiB / 64MiB
|
||||
2026-10-15T18:54:04Z,mtusi-messenger-lab3-postgres-1,58.33%,335.6MiB / 512MiB
|
||||
2026-10-15T18:54:04Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:07Z,mtusi-messenger-lab3-api-13,19.51%,10.94MiB / 384MiB
|
||||
2026-10-15T18:54:07Z,mtusi-messenger-lab3-api-12,20.43%,11.09MiB / 384MiB
|
||||
2026-10-15T18:54:07Z,mtusi-messenger-lab3-lb-1,12.31%,5.152MiB / 64MiB
|
||||
2026-10-15T18:54:07Z,mtusi-messenger-lab3-postgres-1,59.07%,335.5MiB / 512MiB
|
||||
2026-10-15T18:54:07Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:10Z,mtusi-messenger-lab3-api-13,20.24%,10.88MiB / 384MiB
|
||||
2026-10-15T18:54:10Z,mtusi-messenger-lab3-api-12,21.00%,11.22MiB / 384MiB
|
||||
2026-10-15T18:54:10Z,mtusi-messenger-lab3-lb-1,12.57%,5.23MiB / 64MiB
|
||||
2026-10-15T18:54:10Z,mtusi-messenger-lab3-postgres-1,58.95%,335.6MiB / 512MiB
|
||||
2026-10-15T18:54:10Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:14Z,mtusi-messenger-lab3-api-13,20.37%,11.08MiB / 384MiB
|
||||
2026-10-15T18:54:14Z,mtusi-messenger-lab3-api-12,20.12%,11.28MiB / 384MiB
|
||||
2026-10-15T18:54:14Z,mtusi-messenger-lab3-lb-1,12.41%,5.25MiB / 64MiB
|
||||
2026-10-15T18:54:14Z,mtusi-messenger-lab3-postgres-1,58.27%,335.6MiB / 512MiB
|
||||
2026-10-15T18:54:14Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:17Z,mtusi-messenger-lab3-api-13,18.20%,11.04MiB / 384MiB
|
||||
2026-10-15T18:54:17Z,mtusi-messenger-lab3-api-12,18.30%,11.12MiB / 384MiB
|
||||
2026-10-15T18:54:17Z,mtusi-messenger-lab3-lb-1,10.78%,5.09MiB / 64MiB
|
||||
2026-10-15T18:54:17Z,mtusi-messenger-lab3-postgres-1,53.19%,338.6MiB / 512MiB
|
||||
2026-10-15T18:54:17Z,mtusi-messenger-lab3-redis-1,0.79%,8.898MiB / 192MiB
|
||||
|
@@ -0,0 +1,101 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:54:35Z,mtusi-messenger-lab3-api-13,19.73%,172MiB / 384MiB
|
||||
2026-10-15T18:54:35Z,mtusi-messenger-lab3-api-12,19.66%,172.1MiB / 384MiB
|
||||
2026-10-15T18:54:35Z,mtusi-messenger-lab3-lb-1,9.83%,5.23MiB / 64MiB
|
||||
2026-10-15T18:54:35Z,mtusi-messenger-lab3-postgres-1,58.85%,334.9MiB / 512MiB
|
||||
2026-10-15T18:54:35Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:38Z,mtusi-messenger-lab3-api-13,19.67%,11.71MiB / 384MiB
|
||||
2026-10-15T18:54:38Z,mtusi-messenger-lab3-api-12,20.03%,11.73MiB / 384MiB
|
||||
2026-10-15T18:54:38Z,mtusi-messenger-lab3-lb-1,11.91%,5.254MiB / 64MiB
|
||||
2026-10-15T18:54:38Z,mtusi-messenger-lab3-postgres-1,57.40%,335MiB / 512MiB
|
||||
2026-10-15T18:54:38Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:41Z,mtusi-messenger-lab3-api-13,20.24%,11.59MiB / 384MiB
|
||||
2026-10-15T18:54:41Z,mtusi-messenger-lab3-api-12,20.02%,11.74MiB / 384MiB
|
||||
2026-10-15T18:54:41Z,mtusi-messenger-lab3-lb-1,12.02%,5.234MiB / 64MiB
|
||||
2026-10-15T18:54:41Z,mtusi-messenger-lab3-postgres-1,57.00%,335.2MiB / 512MiB
|
||||
2026-10-15T18:54:41Z,mtusi-messenger-lab3-redis-1,0.69%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:44Z,mtusi-messenger-lab3-api-13,20.61%,11.64MiB / 384MiB
|
||||
2026-10-15T18:54:44Z,mtusi-messenger-lab3-api-12,21.23%,11.5MiB / 384MiB
|
||||
2026-10-15T18:54:44Z,mtusi-messenger-lab3-lb-1,12.72%,5.234MiB / 64MiB
|
||||
2026-10-15T18:54:44Z,mtusi-messenger-lab3-postgres-1,59.13%,335.5MiB / 512MiB
|
||||
2026-10-15T18:54:44Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:47Z,mtusi-messenger-lab3-api-13,21.08%,11.4MiB / 384MiB
|
||||
2026-10-15T18:54:47Z,mtusi-messenger-lab3-api-12,20.84%,11.48MiB / 384MiB
|
||||
2026-10-15T18:54:47Z,mtusi-messenger-lab3-lb-1,12.41%,5.258MiB / 64MiB
|
||||
2026-10-15T18:54:47Z,mtusi-messenger-lab3-postgres-1,59.61%,335.4MiB / 512MiB
|
||||
2026-10-15T18:54:47Z,mtusi-messenger-lab3-redis-1,0.80%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:50Z,mtusi-messenger-lab3-api-13,20.79%,11.41MiB / 384MiB
|
||||
2026-10-15T18:54:50Z,mtusi-messenger-lab3-api-12,20.14%,11.4MiB / 384MiB
|
||||
2026-10-15T18:54:50Z,mtusi-messenger-lab3-lb-1,12.22%,5.258MiB / 64MiB
|
||||
2026-10-15T18:54:50Z,mtusi-messenger-lab3-postgres-1,59.45%,336MiB / 512MiB
|
||||
2026-10-15T18:54:50Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:53Z,mtusi-messenger-lab3-api-13,20.11%,11.41MiB / 384MiB
|
||||
2026-10-15T18:54:53Z,mtusi-messenger-lab3-api-12,20.59%,11.39MiB / 384MiB
|
||||
2026-10-15T18:54:53Z,mtusi-messenger-lab3-lb-1,12.10%,5.238MiB / 64MiB
|
||||
2026-10-15T18:54:53Z,mtusi-messenger-lab3-postgres-1,63.11%,342.4MiB / 512MiB
|
||||
2026-10-15T18:54:53Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:56Z,mtusi-messenger-lab3-api-13,17.39%,11.32MiB / 384MiB
|
||||
2026-10-15T18:54:56Z,mtusi-messenger-lab3-api-12,18.56%,11.49MiB / 384MiB
|
||||
2026-10-15T18:54:56Z,mtusi-messenger-lab3-lb-1,10.41%,5.242MiB / 64MiB
|
||||
2026-10-15T18:54:56Z,mtusi-messenger-lab3-postgres-1,69.97%,355.8MiB / 512MiB
|
||||
2026-10-15T18:54:56Z,mtusi-messenger-lab3-redis-1,0.74%,8.898MiB / 192MiB
|
||||
2026-10-15T18:54:59Z,mtusi-messenger-lab3-api-13,20.95%,11.33MiB / 384MiB
|
||||
2026-10-15T18:54:59Z,mtusi-messenger-lab3-api-12,20.19%,11.42MiB / 384MiB
|
||||
2026-10-15T18:54:59Z,mtusi-messenger-lab3-lb-1,12.72%,5.246MiB / 64MiB
|
||||
2026-10-15T18:54:59Z,mtusi-messenger-lab3-postgres-1,59.69%,356.3MiB / 512MiB
|
||||
2026-10-15T18:54:59Z,mtusi-messenger-lab3-redis-1,0.26%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:02Z,mtusi-messenger-lab3-api-13,20.35%,11.33MiB / 384MiB
|
||||
2026-10-15T18:55:02Z,mtusi-messenger-lab3-api-12,20.13%,11.26MiB / 384MiB
|
||||
2026-10-15T18:55:02Z,mtusi-messenger-lab3-lb-1,12.03%,5.258MiB / 64MiB
|
||||
2026-10-15T18:55:02Z,mtusi-messenger-lab3-postgres-1,57.98%,353.7MiB / 512MiB
|
||||
2026-10-15T18:55:02Z,mtusi-messenger-lab3-redis-1,0.26%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:05Z,mtusi-messenger-lab3-api-13,19.92%,11.36MiB / 384MiB
|
||||
2026-10-15T18:55:05Z,mtusi-messenger-lab3-api-12,20.86%,11.5MiB / 384MiB
|
||||
2026-10-15T18:55:05Z,mtusi-messenger-lab3-lb-1,12.50%,5.25MiB / 64MiB
|
||||
2026-10-15T18:55:05Z,mtusi-messenger-lab3-postgres-1,58.10%,354.7MiB / 512MiB
|
||||
2026-10-15T18:55:05Z,mtusi-messenger-lab3-redis-1,0.26%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:08Z,mtusi-messenger-lab3-api-13,21.50%,11.36MiB / 384MiB
|
||||
2026-10-15T18:55:08Z,mtusi-messenger-lab3-api-12,21.00%,11.57MiB / 384MiB
|
||||
2026-10-15T18:55:08Z,mtusi-messenger-lab3-lb-1,12.69%,5.246MiB / 64MiB
|
||||
2026-10-15T18:55:08Z,mtusi-messenger-lab3-postgres-1,58.50%,354.4MiB / 512MiB
|
||||
2026-10-15T18:55:08Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:12Z,mtusi-messenger-lab3-api-13,19.96%,11.36MiB / 384MiB
|
||||
2026-10-15T18:55:12Z,mtusi-messenger-lab3-api-12,20.16%,11.39MiB / 384MiB
|
||||
2026-10-15T18:55:12Z,mtusi-messenger-lab3-lb-1,11.96%,5.164MiB / 64MiB
|
||||
2026-10-15T18:55:12Z,mtusi-messenger-lab3-postgres-1,58.69%,354.6MiB / 512MiB
|
||||
2026-10-15T18:55:12Z,mtusi-messenger-lab3-redis-1,0.75%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:15Z,mtusi-messenger-lab3-api-13,20.69%,11.26MiB / 384MiB
|
||||
2026-10-15T18:55:15Z,mtusi-messenger-lab3-api-12,20.84%,11.45MiB / 384MiB
|
||||
2026-10-15T18:55:15Z,mtusi-messenger-lab3-lb-1,12.41%,5.227MiB / 64MiB
|
||||
2026-10-15T18:55:15Z,mtusi-messenger-lab3-postgres-1,58.04%,354.7MiB / 512MiB
|
||||
2026-10-15T18:55:15Z,mtusi-messenger-lab3-redis-1,0.26%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:18Z,mtusi-messenger-lab3-api-13,20.08%,11.35MiB / 384MiB
|
||||
2026-10-15T18:55:18Z,mtusi-messenger-lab3-api-12,19.76%,11.49MiB / 384MiB
|
||||
2026-10-15T18:55:18Z,mtusi-messenger-lab3-lb-1,12.25%,5.195MiB / 64MiB
|
||||
2026-10-15T18:55:18Z,mtusi-messenger-lab3-postgres-1,58.87%,358MiB / 512MiB
|
||||
2026-10-15T18:55:18Z,mtusi-messenger-lab3-redis-1,0.22%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:21Z,mtusi-messenger-lab3-api-13,19.94%,11.35MiB / 384MiB
|
||||
2026-10-15T18:55:21Z,mtusi-messenger-lab3-api-12,20.18%,11.48MiB / 384MiB
|
||||
2026-10-15T18:55:21Z,mtusi-messenger-lab3-lb-1,12.28%,5.242MiB / 64MiB
|
||||
2026-10-15T18:55:21Z,mtusi-messenger-lab3-postgres-1,57.59%,363.8MiB / 512MiB
|
||||
2026-10-15T18:55:21Z,mtusi-messenger-lab3-redis-1,0.77%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:24Z,mtusi-messenger-lab3-api-13,20.24%,11.36MiB / 384MiB
|
||||
2026-10-15T18:55:24Z,mtusi-messenger-lab3-api-12,19.69%,11.41MiB / 384MiB
|
||||
2026-10-15T18:55:24Z,mtusi-messenger-lab3-lb-1,12.22%,5.234MiB / 64MiB
|
||||
2026-10-15T18:55:24Z,mtusi-messenger-lab3-postgres-1,57.87%,364.3MiB / 512MiB
|
||||
2026-10-15T18:55:24Z,mtusi-messenger-lab3-redis-1,0.24%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:27Z,mtusi-messenger-lab3-api-13,19.88%,11.35MiB / 384MiB
|
||||
2026-10-15T18:55:27Z,mtusi-messenger-lab3-api-12,20.60%,11.41MiB / 384MiB
|
||||
2026-10-15T18:55:27Z,mtusi-messenger-lab3-lb-1,12.10%,5.23MiB / 64MiB
|
||||
2026-10-15T18:55:27Z,mtusi-messenger-lab3-postgres-1,57.80%,363.9MiB / 512MiB
|
||||
2026-10-15T18:55:27Z,mtusi-messenger-lab3-redis-1,0.23%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:30Z,mtusi-messenger-lab3-api-13,21.21%,11.32MiB / 384MiB
|
||||
2026-10-15T18:55:30Z,mtusi-messenger-lab3-api-12,20.41%,11.54MiB / 384MiB
|
||||
2026-10-15T18:55:30Z,mtusi-messenger-lab3-lb-1,12.58%,5.207MiB / 64MiB
|
||||
2026-10-15T18:55:30Z,mtusi-messenger-lab3-postgres-1,60.08%,364MiB / 512MiB
|
||||
2026-10-15T18:55:30Z,mtusi-messenger-lab3-redis-1,0.25%,8.898MiB / 192MiB
|
||||
2026-10-15T18:55:33Z,mtusi-messenger-lab3-api-13,15.03%,11.37MiB / 384MiB
|
||||
2026-10-15T18:55:33Z,mtusi-messenger-lab3-api-12,14.66%,11.37MiB / 384MiB
|
||||
2026-10-15T18:55:33Z,mtusi-messenger-lab3-lb-1,9.08%,5.09MiB / 64MiB
|
||||
2026-10-15T18:55:33Z,mtusi-messenger-lab3-postgres-1,56.39%,370.4MiB / 512MiB
|
||||
2026-10-15T18:55:33Z,mtusi-messenger-lab3-redis-1,0.21%,8.898MiB / 192MiB
|
||||
|
@@ -0,0 +1,137 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-api-13,11.04%,81.5MiB / 192MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-api-14,11.07%,145.3MiB / 192MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-api-12,11.06%,136.8MiB / 192MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-api-15,10.88%,79.09MiB / 192MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-lb-1,12.23%,5.258MiB / 64MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-postgres-1,57.96%,380.1MiB / 512MiB
|
||||
2026-10-15T18:55:53Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-api-13,11.35%,110.2MiB / 192MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-api-14,11.18%,174.2MiB / 192MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-api-12,10.76%,137.4MiB / 192MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-api-15,10.55%,108.6MiB / 192MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-lb-1,12.05%,5.219MiB / 64MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-postgres-1,57.60%,381.7MiB / 512MiB
|
||||
2026-10-15T18:55:56Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-api-13,13.18%,32.17MiB / 192MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-api-12,12.54%,43.71MiB / 192MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-api-15,12.03%,76.38MiB / 192MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-lb-1,9.59%,5.266MiB / 64MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-postgres-1,45.14%,365.3MiB / 512MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:55:59Z,mtusi-messenger-lab3-api-14,11.40%,7.75MiB / 192MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-api-13,10.98%,11.86MiB / 192MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-api-14,11.12%,7.891MiB / 192MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-api-12,11.37%,12.48MiB / 192MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-api-15,11.31%,10.68MiB / 192MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-lb-1,12.30%,5.262MiB / 64MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-postgres-1,57.63%,366.4MiB / 512MiB
|
||||
2026-10-15T18:56:03Z,mtusi-messenger-lab3-redis-1,0.27%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-api-13,10.62%,11.62MiB / 192MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-api-14,11.23%,7.945MiB / 192MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-api-12,11.65%,13.04MiB / 192MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-api-15,10.85%,10.66MiB / 192MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-lb-1,12.33%,5.203MiB / 64MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-postgres-1,57.04%,366.6MiB / 512MiB
|
||||
2026-10-15T18:56:06Z,mtusi-messenger-lab3-redis-1,0.24%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-api-13,11.23%,11.5MiB / 192MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-api-14,10.92%,7.953MiB / 192MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-api-12,12.07%,13.64MiB / 192MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-api-15,11.16%,10.48MiB / 192MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-lb-1,11.84%,5.238MiB / 64MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-postgres-1,55.49%,367MiB / 512MiB
|
||||
2026-10-15T18:56:09Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-api-13,11.41%,11.58MiB / 192MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-api-14,11.37%,7.957MiB / 192MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-api-12,11.71%,13.48MiB / 192MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-api-15,10.87%,10.5MiB / 192MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-lb-1,12.21%,5.223MiB / 64MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-postgres-1,57.77%,367.1MiB / 512MiB
|
||||
2026-10-15T18:56:12Z,mtusi-messenger-lab3-redis-1,0.74%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-api-13,11.24%,11.52MiB / 192MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-api-14,11.33%,8.027MiB / 192MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-api-12,11.38%,12.31MiB / 192MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-api-15,11.29%,10.43MiB / 192MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-lb-1,12.13%,5.234MiB / 64MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-postgres-1,56.57%,369.9MiB / 512MiB
|
||||
2026-10-15T18:56:16Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-api-13,12.01%,11.64MiB / 192MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-api-14,11.18%,8.027MiB / 192MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-api-12,11.97%,13.04MiB / 192MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-api-15,11.61%,10.45MiB / 192MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-lb-1,12.42%,5.23MiB / 64MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-postgres-1,58.12%,370.1MiB / 512MiB
|
||||
2026-10-15T18:56:19Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-api-13,11.25%,11.41MiB / 192MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-api-14,10.50%,8.051MiB / 192MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-api-12,11.10%,13.36MiB / 192MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-api-15,11.06%,10.51MiB / 192MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-lb-1,12.12%,5.227MiB / 64MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-postgres-1,55.54%,370.7MiB / 512MiB
|
||||
2026-10-15T18:56:22Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-api-13,11.53%,11.34MiB / 192MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-api-14,11.65%,8.059MiB / 192MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-api-12,11.51%,12.31MiB / 192MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-api-15,10.78%,10.45MiB / 192MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-lb-1,12.30%,5.234MiB / 64MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-postgres-1,57.33%,371.1MiB / 512MiB
|
||||
2026-10-15T18:56:25Z,mtusi-messenger-lab3-redis-1,0.23%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-api-13,11.14%,11.39MiB / 192MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-api-14,10.97%,8.102MiB / 192MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-api-12,11.09%,13.06MiB / 192MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-api-15,11.50%,10.45MiB / 192MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-lb-1,11.76%,5.258MiB / 64MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-postgres-1,56.41%,370.9MiB / 512MiB
|
||||
2026-10-15T18:56:28Z,mtusi-messenger-lab3-redis-1,0.80%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-api-13,11.13%,11.35MiB / 192MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-api-14,10.62%,8.102MiB / 192MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-api-12,11.07%,13.04MiB / 192MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-api-15,11.03%,10.45MiB / 192MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-lb-1,11.51%,5.258MiB / 64MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-postgres-1,54.85%,371.2MiB / 512MiB
|
||||
2026-10-15T18:56:31Z,mtusi-messenger-lab3-redis-1,0.24%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-api-13,11.28%,11.34MiB / 192MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-api-14,10.86%,8.102MiB / 192MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-api-12,12.07%,13.32MiB / 192MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-api-15,11.38%,10.44MiB / 192MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-lb-1,11.98%,5.254MiB / 64MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-postgres-1,56.72%,371.4MiB / 512MiB
|
||||
2026-10-15T18:56:34Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-api-13,11.38%,11.27MiB / 192MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-api-14,11.33%,8.16MiB / 192MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-api-12,11.45%,13.32MiB / 192MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-api-15,11.28%,10.42MiB / 192MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-lb-1,12.00%,5.238MiB / 64MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-postgres-1,57.85%,371.5MiB / 512MiB
|
||||
2026-10-15T18:56:37Z,mtusi-messenger-lab3-redis-1,0.77%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-api-13,10.95%,11.27MiB / 192MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-api-14,11.66%,8.152MiB / 192MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-api-12,10.89%,13.27MiB / 192MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-api-15,11.32%,10.42MiB / 192MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-lb-1,12.28%,5.219MiB / 64MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-postgres-1,58.07%,371.5MiB / 512MiB
|
||||
2026-10-15T18:56:40Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-api-13,11.29%,11.27MiB / 192MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-api-14,11.79%,8.164MiB / 192MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-api-12,11.40%,13.02MiB / 192MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-api-15,11.14%,10.39MiB / 192MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-lb-1,11.94%,5.238MiB / 64MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-postgres-1,57.12%,371.5MiB / 512MiB
|
||||
2026-10-15T18:56:43Z,mtusi-messenger-lab3-redis-1,0.26%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-api-13,11.37%,11.3MiB / 192MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-api-14,11.49%,8.164MiB / 192MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-api-12,11.39%,13.02MiB / 192MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-api-15,11.13%,10.37MiB / 192MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-lb-1,12.26%,5.223MiB / 64MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-postgres-1,58.23%,371.6MiB / 512MiB
|
||||
2026-10-15T18:56:46Z,mtusi-messenger-lab3-redis-1,0.26%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-api-13,11.87%,11.3MiB / 192MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-api-14,10.70%,8.199MiB / 192MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-api-12,12.04%,13.15MiB / 192MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-api-15,11.43%,10.37MiB / 192MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-lb-1,11.71%,5.223MiB / 64MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-postgres-1,56.42%,371.6MiB / 512MiB
|
||||
2026-10-15T18:56:50Z,mtusi-messenger-lab3-redis-1,0.23%,8.902MiB / 192MiB
|
||||
2026-10-15T18:56:53Z,mtusi-messenger-lab3-lb-1,2.04%,5.023MiB / 64MiB
|
||||
2026-10-15T18:56:53Z,mtusi-messenger-lab3-postgres-1,38.32%,335.8MiB / 512MiB
|
||||
2026-10-15T18:56:53Z,mtusi-messenger-lab3-redis-1,0.73%,8.902MiB / 192MiB
|
||||
|
@@ -0,0 +1,148 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-api-14,0.00%,73.72MiB / 192MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-api-12,9.24%,74.29MiB / 192MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-api-13,13.94%,138.7MiB / 192MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-api-15,7.76%,118.3MiB / 192MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-lb-1,0.07%,5.094MiB / 64MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-postgres-1,1.82%,368.3MiB / 512MiB
|
||||
2026-10-15T18:57:12Z,mtusi-messenger-lab3-redis-1,1.61%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-api-14,11.86%,93.47MiB / 192MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-api-12,10.97%,93.16MiB / 192MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-api-13,11.50%,158.1MiB / 192MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-api-15,11.01%,157.8MiB / 192MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-lb-1,12.23%,5.223MiB / 64MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-postgres-1,56.00%,369.1MiB / 512MiB
|
||||
2026-10-15T18:57:15Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-api-14,11.51%,120.2MiB / 192MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-api-12,11.54%,120MiB / 192MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-api-13,11.49%,185MiB / 192MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-api-15,11.97%,184.9MiB / 192MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-lb-1,12.08%,5.23MiB / 64MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-postgres-1,56.97%,368.4MiB / 512MiB
|
||||
2026-10-15T18:57:19Z,mtusi-messenger-lab3-redis-1,0.23%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-api-14,11.18%,11.17MiB / 192MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-api-12,12.23%,10.99MiB / 192MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-api-13,11.61%,7.734MiB / 192MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-api-15,11.54%,7.703MiB / 192MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-lb-1,11.98%,5.273MiB / 64MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-postgres-1,55.64%,368.4MiB / 512MiB
|
||||
2026-10-15T18:57:22Z,mtusi-messenger-lab3-redis-1,0.25%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-api-14,11.75%,11.12MiB / 192MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-api-12,11.04%,10.98MiB / 192MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-api-13,12.29%,7.867MiB / 192MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-api-15,10.75%,7.992MiB / 192MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-lb-1,12.24%,5.238MiB / 64MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-postgres-1,56.73%,368.6MiB / 512MiB
|
||||
2026-10-15T18:57:25Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-api-14,10.95%,11MiB / 192MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-api-12,11.40%,10.91MiB / 192MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-api-13,11.22%,7.969MiB / 192MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-api-15,11.38%,8.043MiB / 192MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-lb-1,12.19%,5.207MiB / 64MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-postgres-1,56.99%,373.9MiB / 512MiB
|
||||
2026-10-15T18:57:28Z,mtusi-messenger-lab3-redis-1,0.24%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-api-14,10.98%,10.88MiB / 192MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-api-12,11.19%,10.79MiB / 192MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-api-13,11.61%,7.973MiB / 192MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-api-15,10.35%,8.109MiB / 192MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-lb-1,11.84%,5.238MiB / 64MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-postgres-1,55.60%,374.4MiB / 512MiB
|
||||
2026-10-15T18:57:31Z,mtusi-messenger-lab3-redis-1,0.24%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-api-14,11.33%,10.71MiB / 192MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-api-12,11.12%,10.79MiB / 192MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-api-13,10.73%,8.008MiB / 192MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-api-15,11.07%,8.113MiB / 192MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-lb-1,11.94%,5.219MiB / 64MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-postgres-1,57.04%,374.8MiB / 512MiB
|
||||
2026-10-15T18:57:34Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-api-14,11.17%,10.71MiB / 192MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-api-12,11.53%,10.78MiB / 192MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-api-13,10.99%,8.012MiB / 192MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-api-15,11.45%,8.113MiB / 192MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-lb-1,12.00%,5.262MiB / 64MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-postgres-1,56.21%,375.2MiB / 512MiB
|
||||
2026-10-15T18:57:37Z,mtusi-messenger-lab3-redis-1,0.72%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-api-14,11.37%,10.74MiB / 192MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-api-12,12.16%,10.82MiB / 192MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-api-13,11.42%,8.012MiB / 192MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-api-15,11.23%,8.109MiB / 192MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-lb-1,12.41%,5.227MiB / 64MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-postgres-1,58.84%,375.2MiB / 512MiB
|
||||
2026-10-15T18:57:40Z,mtusi-messenger-lab3-redis-1,0.27%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-api-14,11.68%,10.74MiB / 192MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-api-12,11.09%,10.7MiB / 192MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-api-13,11.18%,8.012MiB / 192MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-api-15,11.29%,8.113MiB / 192MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-lb-1,12.02%,5.254MiB / 64MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-postgres-1,56.89%,375.2MiB / 512MiB
|
||||
2026-10-15T18:57:43Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-api-14,11.33%,10.74MiB / 192MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-api-12,10.95%,10.68MiB / 192MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-api-13,11.35%,7.98MiB / 192MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-api-15,11.22%,8.117MiB / 192MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-lb-1,12.18%,5.211MiB / 64MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-postgres-1,56.31%,375.3MiB / 512MiB
|
||||
2026-10-15T18:57:46Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-api-14,12.25%,10.77MiB / 192MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-api-12,11.52%,10.67MiB / 192MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-api-13,10.86%,7.98MiB / 192MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-api-15,11.16%,8.129MiB / 192MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-lb-1,12.07%,5.234MiB / 64MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-postgres-1,57.45%,375.6MiB / 512MiB
|
||||
2026-10-15T18:57:50Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-api-14,10.93%,10.64MiB / 192MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-api-12,11.22%,10.61MiB / 192MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-api-13,10.72%,7.98MiB / 192MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-api-15,10.13%,8.125MiB / 192MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-lb-1,11.38%,5.227MiB / 64MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-postgres-1,64.93%,376.7MiB / 512MiB
|
||||
2026-10-15T18:57:53Z,mtusi-messenger-lab3-redis-1,0.74%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-api-14,9.79%,10.76MiB / 192MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-api-12,10.31%,10.54MiB / 192MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-api-13,10.61%,7.977MiB / 192MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-api-15,10.44%,8.164MiB / 192MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-lb-1,10.97%,5.215MiB / 64MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-postgres-1,59.73%,400.8MiB / 512MiB
|
||||
2026-10-15T18:57:56Z,mtusi-messenger-lab3-redis-1,0.21%,8.902MiB / 192MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-api-14,11.41%,10.67MiB / 192MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-api-12,11.64%,10.52MiB / 192MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-api-13,11.26%,7.98MiB / 192MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-api-15,11.14%,8.133MiB / 192MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-lb-1,11.72%,5.16MiB / 64MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-postgres-1,59.47%,374.6MiB / 512MiB
|
||||
2026-10-15T18:57:59Z,mtusi-messenger-lab3-redis-1,0.21%,8.902MiB / 192MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-api-14,11.13%,10.67MiB / 192MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-api-12,11.24%,10.64MiB / 192MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-api-13,11.16%,7.984MiB / 192MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-api-15,11.33%,8.133MiB / 192MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-lb-1,11.92%,5.277MiB / 64MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-postgres-1,56.04%,375.2MiB / 512MiB
|
||||
2026-10-15T18:58:02Z,mtusi-messenger-lab3-redis-1,0.79%,8.902MiB / 192MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-api-14,11.31%,10.68MiB / 192MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-api-12,11.53%,10.64MiB / 192MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-api-13,11.23%,7.98MiB / 192MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-api-15,10.91%,8.129MiB / 192MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-lb-1,12.27%,5.215MiB / 64MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-postgres-1,57.13%,374.8MiB / 512MiB
|
||||
2026-10-15T18:58:05Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-api-14,11.45%,10.68MiB / 192MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-api-12,10.75%,10.68MiB / 192MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-api-13,11.08%,7.984MiB / 192MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-api-15,11.10%,8.133MiB / 192MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-lb-1,12.17%,5.254MiB / 64MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-postgres-1,58.10%,374.8MiB / 512MiB
|
||||
2026-10-15T18:58:08Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-api-14,11.56%,10.68MiB / 192MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-api-12,11.41%,10.68MiB / 192MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-api-13,11.35%,7.984MiB / 192MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-api-15,11.07%,8.133MiB / 192MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-lb-1,12.28%,5.238MiB / 64MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-postgres-1,56.66%,375.5MiB / 512MiB
|
||||
2026-10-15T18:58:11Z,mtusi-messenger-lab3-redis-1,0.22%,8.902MiB / 192MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-api-14,0.00%,10.64MiB / 192MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-api-12,0.00%,10.54MiB / 192MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-api-13,0.00%,7.969MiB / 192MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-api-15,0.00%,8.117MiB / 192MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-lb-1,5.89%,5.09MiB / 64MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-postgres-1,0.69%,397.3MiB / 512MiB
|
||||
2026-10-15T18:58:14Z,mtusi-messenger-lab3-redis-1,0.53%,8.902MiB / 192MiB
|
||||
|
@@ -0,0 +1,81 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:47:53Z,mtusi-messenger-lab3-api-12,34.03%,43.53MiB / 768MiB
|
||||
2026-10-15T18:47:53Z,mtusi-messenger-lab3-lb-1,8.17%,5.148MiB / 64MiB
|
||||
2026-10-15T18:47:53Z,mtusi-messenger-lab3-postgres-1,62.49%,200.3MiB / 512MiB
|
||||
2026-10-15T18:47:53Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:47:56Z,mtusi-messenger-lab3-api-12,35.63%,12.06MiB / 768MiB
|
||||
2026-10-15T18:47:56Z,mtusi-messenger-lab3-lb-1,12.65%,5.219MiB / 64MiB
|
||||
2026-10-15T18:47:56Z,mtusi-messenger-lab3-postgres-1,62.03%,200.4MiB / 512MiB
|
||||
2026-10-15T18:47:56Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:47:59Z,mtusi-messenger-lab3-api-12,33.94%,12.25MiB / 768MiB
|
||||
2026-10-15T18:47:59Z,mtusi-messenger-lab3-lb-1,12.23%,5.223MiB / 64MiB
|
||||
2026-10-15T18:47:59Z,mtusi-messenger-lab3-postgres-1,59.32%,200.8MiB / 512MiB
|
||||
2026-10-15T18:47:59Z,mtusi-messenger-lab3-redis-1,0.26%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:02Z,mtusi-messenger-lab3-api-12,35.16%,11.56MiB / 768MiB
|
||||
2026-10-15T18:48:02Z,mtusi-messenger-lab3-lb-1,12.27%,5.23MiB / 64MiB
|
||||
2026-10-15T18:48:02Z,mtusi-messenger-lab3-postgres-1,58.94%,201.5MiB / 512MiB
|
||||
2026-10-15T18:48:02Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:05Z,mtusi-messenger-lab3-api-12,32.84%,11.99MiB / 768MiB
|
||||
2026-10-15T18:48:05Z,mtusi-messenger-lab3-lb-1,12.75%,5.254MiB / 64MiB
|
||||
2026-10-15T18:48:05Z,mtusi-messenger-lab3-postgres-1,57.71%,201.4MiB / 512MiB
|
||||
2026-10-15T18:48:05Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:08Z,mtusi-messenger-lab3-api-12,35.02%,11.9MiB / 768MiB
|
||||
2026-10-15T18:48:08Z,mtusi-messenger-lab3-lb-1,12.15%,5.223MiB / 64MiB
|
||||
2026-10-15T18:48:08Z,mtusi-messenger-lab3-postgres-1,59.55%,201.4MiB / 512MiB
|
||||
2026-10-15T18:48:08Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:11Z,mtusi-messenger-lab3-api-12,34.26%,11.89MiB / 768MiB
|
||||
2026-10-15T18:48:11Z,mtusi-messenger-lab3-lb-1,12.68%,5.242MiB / 64MiB
|
||||
2026-10-15T18:48:11Z,mtusi-messenger-lab3-postgres-1,61.05%,201.6MiB / 512MiB
|
||||
2026-10-15T18:48:11Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:14Z,mtusi-messenger-lab3-api-12,33.43%,12.06MiB / 768MiB
|
||||
2026-10-15T18:48:14Z,mtusi-messenger-lab3-lb-1,12.22%,5.203MiB / 64MiB
|
||||
2026-10-15T18:48:14Z,mtusi-messenger-lab3-postgres-1,58.64%,201.6MiB / 512MiB
|
||||
2026-10-15T18:48:14Z,mtusi-messenger-lab3-redis-1,0.69%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:17Z,mtusi-messenger-lab3-api-12,35.60%,11.98MiB / 768MiB
|
||||
2026-10-15T18:48:17Z,mtusi-messenger-lab3-lb-1,12.79%,5.227MiB / 64MiB
|
||||
2026-10-15T18:48:17Z,mtusi-messenger-lab3-postgres-1,58.58%,201.8MiB / 512MiB
|
||||
2026-10-15T18:48:17Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:20Z,mtusi-messenger-lab3-api-12,35.81%,12.09MiB / 768MiB
|
||||
2026-10-15T18:48:20Z,mtusi-messenger-lab3-lb-1,13.59%,5.211MiB / 64MiB
|
||||
2026-10-15T18:48:20Z,mtusi-messenger-lab3-postgres-1,59.69%,201.8MiB / 512MiB
|
||||
2026-10-15T18:48:20Z,mtusi-messenger-lab3-redis-1,0.25%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:24Z,mtusi-messenger-lab3-api-12,34.89%,12.11MiB / 768MiB
|
||||
2026-10-15T18:48:24Z,mtusi-messenger-lab3-lb-1,13.21%,5.234MiB / 64MiB
|
||||
2026-10-15T18:48:24Z,mtusi-messenger-lab3-postgres-1,59.59%,201.6MiB / 512MiB
|
||||
2026-10-15T18:48:24Z,mtusi-messenger-lab3-redis-1,0.89%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:27Z,mtusi-messenger-lab3-api-12,35.18%,11.83MiB / 768MiB
|
||||
2026-10-15T18:48:27Z,mtusi-messenger-lab3-lb-1,12.88%,5.219MiB / 64MiB
|
||||
2026-10-15T18:48:27Z,mtusi-messenger-lab3-postgres-1,58.39%,201.6MiB / 512MiB
|
||||
2026-10-15T18:48:27Z,mtusi-messenger-lab3-redis-1,0.24%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:30Z,mtusi-messenger-lab3-api-12,34.20%,11.85MiB / 768MiB
|
||||
2026-10-15T18:48:30Z,mtusi-messenger-lab3-lb-1,12.83%,5.262MiB / 64MiB
|
||||
2026-10-15T18:48:30Z,mtusi-messenger-lab3-postgres-1,57.98%,201.9MiB / 512MiB
|
||||
2026-10-15T18:48:30Z,mtusi-messenger-lab3-redis-1,0.87%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:33Z,mtusi-messenger-lab3-api-12,34.70%,12.09MiB / 768MiB
|
||||
2026-10-15T18:48:33Z,mtusi-messenger-lab3-lb-1,12.71%,5.203MiB / 64MiB
|
||||
2026-10-15T18:48:33Z,mtusi-messenger-lab3-postgres-1,59.42%,201.9MiB / 512MiB
|
||||
2026-10-15T18:48:33Z,mtusi-messenger-lab3-redis-1,0.25%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:36Z,mtusi-messenger-lab3-api-12,35.79%,12.21MiB / 768MiB
|
||||
2026-10-15T18:48:36Z,mtusi-messenger-lab3-lb-1,12.85%,5.234MiB / 64MiB
|
||||
2026-10-15T18:48:36Z,mtusi-messenger-lab3-postgres-1,59.84%,204.3MiB / 512MiB
|
||||
2026-10-15T18:48:36Z,mtusi-messenger-lab3-redis-1,0.26%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:39Z,mtusi-messenger-lab3-api-12,33.87%,12.23MiB / 768MiB
|
||||
2026-10-15T18:48:39Z,mtusi-messenger-lab3-lb-1,12.54%,5.219MiB / 64MiB
|
||||
2026-10-15T18:48:39Z,mtusi-messenger-lab3-postgres-1,61.40%,204.3MiB / 512MiB
|
||||
2026-10-15T18:48:39Z,mtusi-messenger-lab3-redis-1,0.74%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:42Z,mtusi-messenger-lab3-api-12,35.42%,12.21MiB / 768MiB
|
||||
2026-10-15T18:48:42Z,mtusi-messenger-lab3-lb-1,13.30%,5.25MiB / 64MiB
|
||||
2026-10-15T18:48:42Z,mtusi-messenger-lab3-postgres-1,60.56%,204.3MiB / 512MiB
|
||||
2026-10-15T18:48:42Z,mtusi-messenger-lab3-redis-1,0.24%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:45Z,mtusi-messenger-lab3-api-12,34.88%,12.2MiB / 768MiB
|
||||
2026-10-15T18:48:45Z,mtusi-messenger-lab3-lb-1,12.89%,5.266MiB / 64MiB
|
||||
2026-10-15T18:48:45Z,mtusi-messenger-lab3-postgres-1,59.24%,204.5MiB / 512MiB
|
||||
2026-10-15T18:48:45Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:48Z,mtusi-messenger-lab3-api-12,34.41%,12.45MiB / 768MiB
|
||||
2026-10-15T18:48:48Z,mtusi-messenger-lab3-lb-1,12.72%,5.266MiB / 64MiB
|
||||
2026-10-15T18:48:48Z,mtusi-messenger-lab3-postgres-1,61.24%,204.4MiB / 512MiB
|
||||
2026-10-15T18:48:48Z,mtusi-messenger-lab3-redis-1,0.21%,8.785MiB / 192MiB
|
||||
2026-10-15T18:48:51Z,mtusi-messenger-lab3-api-12,30.12%,12.04MiB / 768MiB
|
||||
2026-10-15T18:48:51Z,mtusi-messenger-lab3-lb-1,10.95%,5.09MiB / 64MiB
|
||||
2026-10-15T18:48:51Z,mtusi-messenger-lab3-postgres-1,61.53%,206MiB / 512MiB
|
||||
2026-10-15T18:48:51Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
|
@@ -0,0 +1,101 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:49:09Z,mtusi-messenger-lab3-api-12,19.78%,169.6MiB / 384MiB
|
||||
2026-10-15T18:49:09Z,mtusi-messenger-lab3-api-13,18.91%,137.6MiB / 384MiB
|
||||
2026-10-15T18:49:09Z,mtusi-messenger-lab3-lb-1,12.50%,5.23MiB / 64MiB
|
||||
2026-10-15T18:49:09Z,mtusi-messenger-lab3-postgres-1,58.06%,219.3MiB / 512MiB
|
||||
2026-10-15T18:49:09Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:12Z,mtusi-messenger-lab3-api-12,20.42%,11.84MiB / 384MiB
|
||||
2026-10-15T18:49:12Z,mtusi-messenger-lab3-api-13,20.61%,10.52MiB / 384MiB
|
||||
2026-10-15T18:49:12Z,mtusi-messenger-lab3-lb-1,12.35%,5.215MiB / 64MiB
|
||||
2026-10-15T18:49:12Z,mtusi-messenger-lab3-postgres-1,58.24%,219.9MiB / 512MiB
|
||||
2026-10-15T18:49:12Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:15Z,mtusi-messenger-lab3-api-12,20.19%,11.6MiB / 384MiB
|
||||
2026-10-15T18:49:15Z,mtusi-messenger-lab3-api-13,20.58%,10.54MiB / 384MiB
|
||||
2026-10-15T18:49:15Z,mtusi-messenger-lab3-lb-1,12.49%,5.227MiB / 64MiB
|
||||
2026-10-15T18:49:15Z,mtusi-messenger-lab3-postgres-1,59.29%,220MiB / 512MiB
|
||||
2026-10-15T18:49:15Z,mtusi-messenger-lab3-redis-1,0.75%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:19Z,mtusi-messenger-lab3-api-12,20.70%,11.54MiB / 384MiB
|
||||
2026-10-15T18:49:19Z,mtusi-messenger-lab3-api-13,20.54%,10.47MiB / 384MiB
|
||||
2026-10-15T18:49:19Z,mtusi-messenger-lab3-lb-1,12.54%,5.211MiB / 64MiB
|
||||
2026-10-15T18:49:19Z,mtusi-messenger-lab3-postgres-1,57.77%,220.6MiB / 512MiB
|
||||
2026-10-15T18:49:19Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:22Z,mtusi-messenger-lab3-api-12,20.49%,11.72MiB / 384MiB
|
||||
2026-10-15T18:49:22Z,mtusi-messenger-lab3-api-13,20.19%,10.38MiB / 384MiB
|
||||
2026-10-15T18:49:22Z,mtusi-messenger-lab3-lb-1,12.47%,5.223MiB / 64MiB
|
||||
2026-10-15T18:49:22Z,mtusi-messenger-lab3-postgres-1,57.24%,220.8MiB / 512MiB
|
||||
2026-10-15T18:49:22Z,mtusi-messenger-lab3-redis-1,0.24%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:25Z,mtusi-messenger-lab3-api-12,19.98%,11.73MiB / 384MiB
|
||||
2026-10-15T18:49:25Z,mtusi-messenger-lab3-api-13,20.01%,10.38MiB / 384MiB
|
||||
2026-10-15T18:49:25Z,mtusi-messenger-lab3-lb-1,12.21%,5.254MiB / 64MiB
|
||||
2026-10-15T18:49:25Z,mtusi-messenger-lab3-postgres-1,57.31%,221.2MiB / 512MiB
|
||||
2026-10-15T18:49:25Z,mtusi-messenger-lab3-redis-1,0.77%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:28Z,mtusi-messenger-lab3-api-12,20.14%,11.59MiB / 384MiB
|
||||
2026-10-15T18:49:28Z,mtusi-messenger-lab3-api-13,20.19%,10.51MiB / 384MiB
|
||||
2026-10-15T18:49:28Z,mtusi-messenger-lab3-lb-1,12.22%,5.242MiB / 64MiB
|
||||
2026-10-15T18:49:28Z,mtusi-messenger-lab3-postgres-1,57.38%,221MiB / 512MiB
|
||||
2026-10-15T18:49:28Z,mtusi-messenger-lab3-redis-1,0.24%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:31Z,mtusi-messenger-lab3-api-12,19.90%,11.73MiB / 384MiB
|
||||
2026-10-15T18:49:31Z,mtusi-messenger-lab3-api-13,19.76%,10.48MiB / 384MiB
|
||||
2026-10-15T18:49:31Z,mtusi-messenger-lab3-lb-1,12.04%,5.137MiB / 64MiB
|
||||
2026-10-15T18:49:31Z,mtusi-messenger-lab3-postgres-1,57.33%,221.6MiB / 512MiB
|
||||
2026-10-15T18:49:31Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:34Z,mtusi-messenger-lab3-api-12,20.30%,11.74MiB / 384MiB
|
||||
2026-10-15T18:49:34Z,mtusi-messenger-lab3-api-13,20.00%,10.51MiB / 384MiB
|
||||
2026-10-15T18:49:34Z,mtusi-messenger-lab3-lb-1,12.24%,5.262MiB / 64MiB
|
||||
2026-10-15T18:49:34Z,mtusi-messenger-lab3-postgres-1,58.70%,223MiB / 512MiB
|
||||
2026-10-15T18:49:34Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:37Z,mtusi-messenger-lab3-api-12,20.80%,11.75MiB / 384MiB
|
||||
2026-10-15T18:49:37Z,mtusi-messenger-lab3-api-13,20.51%,10.38MiB / 384MiB
|
||||
2026-10-15T18:49:37Z,mtusi-messenger-lab3-lb-1,12.14%,5.262MiB / 64MiB
|
||||
2026-10-15T18:49:37Z,mtusi-messenger-lab3-postgres-1,57.95%,224.3MiB / 512MiB
|
||||
2026-10-15T18:49:37Z,mtusi-messenger-lab3-redis-1,0.25%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:40Z,mtusi-messenger-lab3-api-12,20.00%,11.78MiB / 384MiB
|
||||
2026-10-15T18:49:40Z,mtusi-messenger-lab3-api-13,20.04%,10.43MiB / 384MiB
|
||||
2026-10-15T18:49:40Z,mtusi-messenger-lab3-lb-1,12.20%,5.219MiB / 64MiB
|
||||
2026-10-15T18:49:40Z,mtusi-messenger-lab3-postgres-1,58.68%,224.6MiB / 512MiB
|
||||
2026-10-15T18:49:40Z,mtusi-messenger-lab3-redis-1,0.22%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:43Z,mtusi-messenger-lab3-api-12,20.31%,11.56MiB / 384MiB
|
||||
2026-10-15T18:49:43Z,mtusi-messenger-lab3-api-13,20.66%,10.54MiB / 384MiB
|
||||
2026-10-15T18:49:43Z,mtusi-messenger-lab3-lb-1,12.71%,5.27MiB / 64MiB
|
||||
2026-10-15T18:49:43Z,mtusi-messenger-lab3-postgres-1,59.62%,224.6MiB / 512MiB
|
||||
2026-10-15T18:49:43Z,mtusi-messenger-lab3-redis-1,0.24%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:46Z,mtusi-messenger-lab3-api-12,20.07%,11.44MiB / 384MiB
|
||||
2026-10-15T18:49:46Z,mtusi-messenger-lab3-api-13,19.94%,10.42MiB / 384MiB
|
||||
2026-10-15T18:49:46Z,mtusi-messenger-lab3-lb-1,12.64%,5.211MiB / 64MiB
|
||||
2026-10-15T18:49:46Z,mtusi-messenger-lab3-postgres-1,58.70%,235.3MiB / 512MiB
|
||||
2026-10-15T18:49:46Z,mtusi-messenger-lab3-redis-1,0.21%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:49Z,mtusi-messenger-lab3-api-12,21.10%,11.56MiB / 384MiB
|
||||
2026-10-15T18:49:49Z,mtusi-messenger-lab3-api-13,20.33%,10.41MiB / 384MiB
|
||||
2026-10-15T18:49:49Z,mtusi-messenger-lab3-lb-1,12.39%,5.211MiB / 64MiB
|
||||
2026-10-15T18:49:49Z,mtusi-messenger-lab3-postgres-1,59.80%,235.1MiB / 512MiB
|
||||
2026-10-15T18:49:49Z,mtusi-messenger-lab3-redis-1,0.21%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:52Z,mtusi-messenger-lab3-api-12,19.94%,11.56MiB / 384MiB
|
||||
2026-10-15T18:49:52Z,mtusi-messenger-lab3-api-13,18.43%,10.51MiB / 384MiB
|
||||
2026-10-15T18:49:52Z,mtusi-messenger-lab3-lb-1,11.02%,5.227MiB / 64MiB
|
||||
2026-10-15T18:49:52Z,mtusi-messenger-lab3-postgres-1,70.40%,252.3MiB / 512MiB
|
||||
2026-10-15T18:49:52Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:55Z,mtusi-messenger-lab3-api-12,21.55%,11.56MiB / 384MiB
|
||||
2026-10-15T18:49:55Z,mtusi-messenger-lab3-api-13,21.09%,10.44MiB / 384MiB
|
||||
2026-10-15T18:49:55Z,mtusi-messenger-lab3-lb-1,12.84%,5.23MiB / 64MiB
|
||||
2026-10-15T18:49:55Z,mtusi-messenger-lab3-postgres-1,59.42%,240.2MiB / 512MiB
|
||||
2026-10-15T18:49:55Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:49:59Z,mtusi-messenger-lab3-api-12,21.17%,11.43MiB / 384MiB
|
||||
2026-10-15T18:49:59Z,mtusi-messenger-lab3-api-13,20.65%,10.5MiB / 384MiB
|
||||
2026-10-15T18:49:59Z,mtusi-messenger-lab3-lb-1,12.96%,5.277MiB / 64MiB
|
||||
2026-10-15T18:49:59Z,mtusi-messenger-lab3-postgres-1,60.85%,240.2MiB / 512MiB
|
||||
2026-10-15T18:49:59Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
2026-10-15T18:50:02Z,mtusi-messenger-lab3-api-12,20.45%,11.68MiB / 384MiB
|
||||
2026-10-15T18:50:02Z,mtusi-messenger-lab3-api-13,19.61%,10.49MiB / 384MiB
|
||||
2026-10-15T18:50:02Z,mtusi-messenger-lab3-lb-1,12.55%,5.227MiB / 64MiB
|
||||
2026-10-15T18:50:02Z,mtusi-messenger-lab3-postgres-1,58.17%,240.3MiB / 512MiB
|
||||
2026-10-15T18:50:02Z,mtusi-messenger-lab3-redis-1,0.25%,8.785MiB / 192MiB
|
||||
2026-10-15T18:50:05Z,mtusi-messenger-lab3-api-12,20.51%,11.59MiB / 384MiB
|
||||
2026-10-15T18:50:05Z,mtusi-messenger-lab3-api-13,19.89%,10.51MiB / 384MiB
|
||||
2026-10-15T18:50:05Z,mtusi-messenger-lab3-lb-1,12.50%,5.242MiB / 64MiB
|
||||
2026-10-15T18:50:05Z,mtusi-messenger-lab3-postgres-1,59.90%,240.3MiB / 512MiB
|
||||
2026-10-15T18:50:05Z,mtusi-messenger-lab3-redis-1,0.77%,8.785MiB / 192MiB
|
||||
2026-10-15T18:50:08Z,mtusi-messenger-lab3-api-12,18.64%,11.56MiB / 384MiB
|
||||
2026-10-15T18:50:08Z,mtusi-messenger-lab3-api-13,17.88%,10.54MiB / 384MiB
|
||||
2026-10-15T18:50:08Z,mtusi-messenger-lab3-lb-1,10.92%,5.094MiB / 64MiB
|
||||
2026-10-15T18:50:08Z,mtusi-messenger-lab3-postgres-1,51.77%,240.5MiB / 512MiB
|
||||
2026-10-15T18:50:08Z,mtusi-messenger-lab3-redis-1,0.23%,8.785MiB / 192MiB
|
||||
|
@@ -0,0 +1,141 @@
|
||||
timestamp,container,cpu_percent,mem_usage
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-api-14,0.88%,73.6MiB / 192MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-api-12,2.22%,74.57MiB / 192MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-api-13,11.81%,137.7MiB / 192MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-api-15,15.53%,137.8MiB / 192MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-lb-1,0.96%,5.227MiB / 64MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-postgres-1,4.74%,233.7MiB / 512MiB
|
||||
2026-10-15T18:50:28Z,mtusi-messenger-lab3-redis-1,0.40%,8.914MiB / 192MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-api-14,12.00%,94.01MiB / 192MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-api-12,11.00%,93.99MiB / 192MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-api-13,11.24%,158.4MiB / 192MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-api-15,11.72%,158.4MiB / 192MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-lb-1,12.47%,5.168MiB / 64MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-postgres-1,57.38%,234.9MiB / 512MiB
|
||||
2026-10-15T18:50:31Z,mtusi-messenger-lab3-redis-1,0.94%,8.914MiB / 192MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-api-14,11.38%,116.2MiB / 192MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-api-12,11.82%,115.7MiB / 192MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-api-13,11.65%,180.1MiB / 192MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-api-15,11.78%,180MiB / 192MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-lb-1,11.55%,5.223MiB / 64MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-postgres-1,53.31%,234.3MiB / 512MiB
|
||||
2026-10-15T18:50:34Z,mtusi-messenger-lab3-redis-1,0.24%,8.914MiB / 192MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-api-14,14.56%,11.51MiB / 192MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-api-12,14.93%,11.57MiB / 192MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-lb-1,9.90%,5.289MiB / 64MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-postgres-1,40.70%,235.1MiB / 512MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-redis-1,0.23%,8.836MiB / 192MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-api-15,5.16%,7.41MiB / 192MiB
|
||||
2026-10-15T18:50:37Z,mtusi-messenger-lab3-api-13,10.58%,7.609MiB / 192MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-api-14,10.46%,11.5MiB / 192MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-api-12,12.08%,11.59MiB / 192MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-api-13,11.31%,8.086MiB / 192MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-api-15,11.27%,8.395MiB / 192MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-lb-1,11.90%,5.199MiB / 64MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-postgres-1,55.13%,237.3MiB / 512MiB
|
||||
2026-10-15T18:50:41Z,mtusi-messenger-lab3-redis-1,0.26%,8.832MiB / 192MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-api-14,10.76%,11.34MiB / 192MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-api-12,11.70%,11.48MiB / 192MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-api-13,10.29%,8.047MiB / 192MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-api-15,10.09%,10.81MiB / 192MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-lb-1,11.30%,5.246MiB / 64MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-postgres-1,52.60%,237.5MiB / 512MiB
|
||||
2026-10-15T18:50:44Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-api-14,11.38%,11.28MiB / 192MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-api-12,11.33%,11.37MiB / 192MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-api-13,11.57%,8.062MiB / 192MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-api-15,11.07%,10.82MiB / 192MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-lb-1,12.37%,5.121MiB / 64MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-postgres-1,58.03%,237.9MiB / 512MiB
|
||||
2026-10-15T18:50:48Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-api-14,11.30%,11.36MiB / 192MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-api-12,11.19%,11.4MiB / 192MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-api-13,11.42%,8.062MiB / 192MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-api-15,11.13%,10.82MiB / 192MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-lb-1,12.39%,5.238MiB / 64MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-postgres-1,57.05%,237.9MiB / 512MiB
|
||||
2026-10-15T18:50:51Z,mtusi-messenger-lab3-redis-1,0.22%,8.832MiB / 192MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-api-14,11.27%,11.52MiB / 192MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-api-12,11.58%,11.41MiB / 192MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-api-13,10.49%,8.062MiB / 192MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-api-15,10.82%,10.89MiB / 192MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-lb-1,11.54%,5.219MiB / 64MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-postgres-1,55.31%,251.3MiB / 512MiB
|
||||
2026-10-15T18:50:54Z,mtusi-messenger-lab3-redis-1,0.21%,8.832MiB / 192MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-api-14,11.24%,11.33MiB / 192MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-api-12,11.61%,11.43MiB / 192MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-api-13,11.05%,8.379MiB / 192MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-api-15,10.87%,10.89MiB / 192MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-lb-1,12.12%,5.223MiB / 64MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-postgres-1,56.32%,251.3MiB / 512MiB
|
||||
2026-10-15T18:50:57Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-api-14,11.18%,11.47MiB / 192MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-api-12,10.97%,11.48MiB / 192MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-api-13,11.05%,8.191MiB / 192MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-api-15,11.08%,10.89MiB / 192MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-lb-1,11.87%,5.23MiB / 64MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-postgres-1,56.71%,251.5MiB / 512MiB
|
||||
2026-10-15T18:51:00Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-api-14,11.21%,11.31MiB / 192MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-api-12,11.19%,11.46MiB / 192MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-api-13,11.30%,8.168MiB / 192MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-api-15,10.90%,10.89MiB / 192MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-lb-1,11.80%,5.207MiB / 64MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-postgres-1,56.75%,253.6MiB / 512MiB
|
||||
2026-10-15T18:51:03Z,mtusi-messenger-lab3-redis-1,0.22%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-api-14,11.04%,11.18MiB / 192MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-api-12,11.46%,11.4MiB / 192MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-api-13,11.10%,8.105MiB / 192MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-api-15,10.99%,10.9MiB / 192MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-lb-1,11.79%,5.254MiB / 64MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-postgres-1,59.05%,256.3MiB / 512MiB
|
||||
2026-10-15T18:51:06Z,mtusi-messenger-lab3-redis-1,0.24%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-api-14,11.09%,11.26MiB / 192MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-api-12,11.75%,11.02MiB / 192MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-api-13,10.91%,8.227MiB / 192MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-api-15,10.73%,10.93MiB / 192MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-lb-1,11.73%,5.223MiB / 64MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-postgres-1,56.01%,254.8MiB / 512MiB
|
||||
2026-10-15T18:51:09Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-api-14,11.43%,11.25MiB / 192MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-api-12,11.16%,11.32MiB / 192MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-api-13,11.60%,8.352MiB / 192MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-api-15,11.03%,10.9MiB / 192MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-lb-1,11.70%,5.234MiB / 64MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-postgres-1,56.18%,255.3MiB / 512MiB
|
||||
2026-10-15T18:51:12Z,mtusi-messenger-lab3-redis-1,0.24%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-api-14,11.10%,11.25MiB / 192MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-api-12,10.99%,11.32MiB / 192MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-api-13,11.22%,8.207MiB / 192MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-api-15,10.42%,10.9MiB / 192MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-lb-1,11.73%,5.227MiB / 64MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-postgres-1,56.27%,255.7MiB / 512MiB
|
||||
2026-10-15T18:51:15Z,mtusi-messenger-lab3-redis-1,0.24%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-api-14,11.73%,11.25MiB / 192MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-api-12,11.93%,11.14MiB / 192MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-api-13,11.25%,8.164MiB / 192MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-api-15,10.55%,10.93MiB / 192MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-lb-1,11.94%,5.219MiB / 64MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-postgres-1,57.76%,258.4MiB / 512MiB
|
||||
2026-10-15T18:51:18Z,mtusi-messenger-lab3-redis-1,0.23%,8.832MiB / 192MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-api-14,11.11%,11.37MiB / 192MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-api-12,11.29%,11.12MiB / 192MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-api-13,11.07%,8.164MiB / 192MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-api-15,11.31%,10.93MiB / 192MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-lb-1,11.94%,5.254MiB / 64MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-postgres-1,56.94%,259.1MiB / 512MiB
|
||||
2026-10-15T18:51:22Z,mtusi-messenger-lab3-redis-1,0.22%,8.906MiB / 192MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-api-14,11.12%,11.37MiB / 192MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-api-12,11.82%,11.08MiB / 192MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-api-13,10.33%,8.137MiB / 192MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-api-15,10.75%,10.93MiB / 192MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-lb-1,11.60%,5.238MiB / 64MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-postgres-1,54.92%,264.6MiB / 512MiB
|
||||
2026-10-15T18:51:25Z,mtusi-messenger-lab3-redis-1,0.25%,8.906MiB / 192MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-api-14,9.16%,11.36MiB / 192MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-api-12,9.40%,11.11MiB / 192MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-api-13,8.80%,8.152MiB / 192MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-api-15,9.24%,10.95MiB / 192MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-lb-1,9.74%,5.086MiB / 64MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-postgres-1,50.77%,276.2MiB / 512MiB
|
||||
2026-10-15T18:51:28Z,mtusi-messenger-lab3-redis-1,0.24%,8.906MiB / 192MiB
|
||||
|
@@ -0,0 +1,13 @@
|
||||
# Трек 1: цена масштабирования
|
||||
|
||||
| профиль | реплик | бюджет CPU | CPU/реплика | успешный RPS | p50 мс | p95 мс | p99 мс | ошибки | API CPU (сумма) | API RAM max (сумма, MiB) | PG CPU | LB CPU |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| db1cpu | 2 | 1.0 | 0.5 | 1961.212 | 3.984 | 6.09 | 8.13 | 0 | 40.15 | 340.9 | 57.12 | 12.32 |
|
||||
| g05 | 2 | 0.5 | 0.25 | 1905.841 | 4.032 | 6.456 | 9.098 | 340 | 39.74 | 389.9 | 55.19 | 11.25 |
|
||||
| g10 | 2 | 1.0 | 0.5 | 1953.781 | 3.923 | 6.062 | 8.041 | 1984 | 38.43 | 341.9 | 56.17 | 11.77 |
|
||||
| g15 | 2 | 1.5 | 0.75 | 1856.809 | 4.132 | 6.761 | 9.34 | 0 | 39.95 | 344.1 | 59.21 | 11.92 |
|
||||
| pool10 | 4 | 1.0 | 0.25 | 1890.142 | 4.133 | 6.416 | 8.487 | 0 | 45.25 | 530.4 | 55.51 | 11.45 |
|
||||
| pool5 | 4 | 1.0 | 0.25 | 1817.2 | 4.258 | 6.758 | 9.171 | 0 | 42.14 | 610.1 | 52.15 | 11.14 |
|
||||
| r1 | 1 | 1.0 | 1.0 | 1895.027 | 4.031 | 6.507 | 8.906 | 0 | 34.46 | 43.5 | 59.86 | 12.42 |
|
||||
| r2 | 2 | 1.0 | 0.5 | 1956.481 | 3.957 | 6.18 | 8.499 | 0 | 40.31 | 307.2 | 58.83 | 12.3 |
|
||||
| r4 | 4 | 1.0 | 0.25 | 1786.838 | 4.288 | 7.051 | 10.001 | 0 | 43.67 | 592.0 | 52.6 | 11.12 |
|
||||
@@ -0,0 +1,234 @@
|
||||
# Track 1: the price of scaling
|
||||
# generated: 2026-10-15T18:47:12Z
|
||||
# host: Darwin arm64
|
||||
# cpu: Apple M5 Pro
|
||||
# ram bytes: 51539607552
|
||||
# load: tests/load.py closed loop; postgres/redis/lb limits are fixed in compose.yaml
|
||||
# each profile line below records the budget it was run with
|
||||
docker engine 29.5.2
|
||||
Docker Compose version 5.5.1
|
||||
|
||||
=== invocation 2026-10-15T18:47:12Z: REPLICAS="1 2 4" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=r1 replicas=1 cpu=1.00 mem=768M ===
|
||||
=== invocation 2026-10-15T18:47:37Z: REPLICAS="1 2 4" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=r1 replicas=1 cpu=1.00 mem=768M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 113740,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1895.027,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.031,
|
||||
"p95": 6.507,
|
||||
"p99": 8.906
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=19
|
||||
postgres_max_connections=100
|
||||
messages_rows=368298
|
||||
idempotency_rows=368298
|
||||
|
||||
=== profile label=r2 replicas=2 cpu=0.50 mem=384M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117433,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1956.481,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.957,
|
||||
"p95": 6.18,
|
||||
"p99": 8.499
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=23
|
||||
postgres_max_connections=100
|
||||
messages_rows=516197
|
||||
idempotency_rows=516197
|
||||
|
||||
=== profile label=r4 replicas=4 cpu=0.25 mem=192M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.014,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 107236,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1786.838,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.288,
|
||||
"p95": 7.051,
|
||||
"p99": 10.001
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=23
|
||||
postgres_max_connections=100
|
||||
messages_rows=652759
|
||||
idempotency_rows=652759
|
||||
|
||||
=== invocation 2026-10-15T18:51:38Z: REPLICAS="2" TOTAL_CPU=0.5 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=g05 replicas=2 cpu=0.25 mem=384M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 114389,
|
||||
"failed_requests": 340,
|
||||
"error_ratio": 0.002964,
|
||||
"successful_rps": 1905.841,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.032,
|
||||
"p95": 6.456,
|
||||
"p99": 9.098
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=19
|
||||
postgres_max_connections=100
|
||||
messages_rows=797321
|
||||
idempotency_rows=797321
|
||||
|
||||
=== invocation 2026-10-15T18:53:02Z: REPLICAS="2" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=g10 replicas=2 cpu=0.50 mem=384M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117266,
|
||||
"failed_requests": 1984,
|
||||
"error_ratio": 0.016637,
|
||||
"successful_rps": 1953.781,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.923,
|
||||
"p95": 6.062,
|
||||
"p99": 8.041
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=19
|
||||
postgres_max_connections=100
|
||||
messages_rows=944961
|
||||
idempotency_rows=944961
|
||||
|
||||
=== invocation 2026-10-15T18:54:19Z: REPLICAS="2" TOTAL_CPU=1.5 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=g15 replicas=2 cpu=0.75 mem=384M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.018,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 111442,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1856.809,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.132,
|
||||
"p95": 6.761,
|
||||
"p99": 9.34
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=19
|
||||
postgres_max_connections=100
|
||||
messages_rows=1086579
|
||||
idempotency_rows=1086579
|
||||
|
||||
=== invocation 2026-10-15T18:55:35Z: REPLICAS="4" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=pool10 replicas=4 cpu=0.25 mem=192M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.016,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 113438,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1890.142,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.133,
|
||||
"p95": 6.416,
|
||||
"p99": 8.487
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=23
|
||||
postgres_max_connections=100
|
||||
messages_rows=1229412
|
||||
idempotency_rows=1229412
|
||||
|
||||
=== invocation 2026-10-15T18:56:54Z: REPLICAS="4" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=pool5 replicas=4 cpu=0.25 mem=192M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.023,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 109073,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1817.2,
|
||||
"successful_latency_ms": {
|
||||
"p50": 4.258,
|
||||
"p95": 6.758,
|
||||
"p99": 9.171
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=23
|
||||
postgres_max_connections=100
|
||||
messages_rows=1366625
|
||||
idempotency_rows=1366625
|
||||
|
||||
=== invocation 2026-10-15T19:05:27Z: REPLICAS="2" TOTAL_CPU=1.0 TOTAL_MEM_MB=768 DURATION=60 CONCURRENCY=8 WARMUP=15 ===
|
||||
|
||||
=== profile label=db1cpu replicas=2 cpu=0.50 mem=384M ===
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "closed-loop POST messages; no automatic retries",
|
||||
"requested_duration_seconds": 60.0,
|
||||
"elapsed_seconds": 60.02,
|
||||
"concurrency": 8,
|
||||
"successful_requests": 117712,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 1961.212,
|
||||
"successful_latency_ms": {
|
||||
"p50": 3.984,
|
||||
"p95": 6.09,
|
||||
"p99": 8.13
|
||||
},
|
||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||
}
|
||||
postgres_connections=19
|
||||
postgres_max_connections=100
|
||||
messages_rows=1722748
|
||||
idempotency_rows=1722748
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# Load balancer for the lab3 stand (HAProxy, container `lb`).
|
||||
#
|
||||
# Почему активные проверки, а не пассивные: nginx OSS умел только пассивные, и
|
||||
# реплика, которая осталась доступной по сети, но потеряла БД, продолжала получать
|
||||
# трафик и отвечала 503 (измерено: 20 из 40 запросов /health/live). HAProxy сам
|
||||
# опрашивает /health/ready и полностью убирает неготовую реплику из ротации.
|
||||
#
|
||||
# Почему повторы безопасны: `retry-on conn-failure` — повтор только когда
|
||||
# соединение не установилось и запрос НЕ ушёл. Если запрос уже передан серверу,
|
||||
# повтора нет, поэтому прозрачного дублирования POST (создание чата, сообщения)
|
||||
# балансировщик не делает. Неопределённый результат повторяет клиент, а сообщение
|
||||
# защищено обязательным Idempotency-Key (контракт 1.3.0).
|
||||
|
||||
global
|
||||
log stdout format raw local0
|
||||
maxconn 2048
|
||||
|
||||
defaults
|
||||
mode http
|
||||
log global
|
||||
option httplog
|
||||
option dontlognull
|
||||
timeout connect 1s
|
||||
timeout client 30s
|
||||
timeout server 5s
|
||||
retry-on conn-failure
|
||||
retries 2
|
||||
option redispatch
|
||||
|
||||
resolvers docker
|
||||
nameserver dns 127.0.0.11:53
|
||||
resolve_retries 3
|
||||
timeout resolve 1s
|
||||
timeout retry 1s
|
||||
hold valid 5s
|
||||
hold nx 2s
|
||||
hold timeout 1s
|
||||
hold refused 1s
|
||||
hold obsolete 5s
|
||||
|
||||
backend api_backend
|
||||
balance leastconn
|
||||
# Период проверки 2 с; реплика исключается после 2 неудач (<=4 с) и
|
||||
# возвращается в ротацию после 2 успехов (<=4 с).
|
||||
option httpchk
|
||||
http-check send meth GET uri /health/ready
|
||||
http-check expect status 200
|
||||
# Одно имя -> все адреса реплик (общий network alias в compose.yaml),
|
||||
# адреса переразрешаются каждые 5 с: масштабирование и замена контейнеров
|
||||
# не зависят от их номеров и IP.
|
||||
default-server check inter 2s fall 2 rise 2 resolvers docker resolve-prefer ipv4 init-addr none
|
||||
server-template api 4 api-replica:8080
|
||||
|
||||
frontend http_front
|
||||
bind *:80
|
||||
default_backend api_backend
|
||||
|
||||
frontend stats_front
|
||||
# Только для оператора и доказательств: видно, какие реплики UP/DOWN и почему.
|
||||
bind *:8404
|
||||
stats enable
|
||||
stats uri /stats
|
||||
stats refresh 2s
|
||||
monitor-uri /healthz
|
||||
@@ -28,19 +28,26 @@ const (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Env string `mapstructure:"env" validate:"omitempty,eq=dev"`
|
||||
Server Server `mapstructure:"server"`
|
||||
Log Log `mapstructure:"log"`
|
||||
Postgres Postgres `mapstructure:"postgres"`
|
||||
Redis Redis `mapstructure:"redis"`
|
||||
Cache Cache `mapstructure:"cache"`
|
||||
Session Session `mapstructure:"session"`
|
||||
Env string `mapstructure:"env" validate:"omitempty,eq=dev"`
|
||||
Server Server `mapstructure:"server"`
|
||||
Log Log `mapstructure:"log"`
|
||||
Postgres Postgres `mapstructure:"postgres"`
|
||||
Redis Redis `mapstructure:"redis"`
|
||||
Cache Cache `mapstructure:"cache"`
|
||||
Session Session `mapstructure:"session"`
|
||||
Idempotency Idempotency `mapstructure:"idempotency"`
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
TTLSeconds int `mapstructure:"ttl_seconds" validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
// Idempotency holds the retention window of a message Idempotency-Key (contract
|
||||
// 1.3.0 requires at least 24 hours).
|
||||
type Idempotency struct {
|
||||
TTLSeconds int `mapstructure:"ttl_seconds" validate:"required,gt=0"`
|
||||
}
|
||||
|
||||
type Redis struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Host string `mapstructure:"host" validate:"omitempty,hostname|ip"`
|
||||
@@ -117,6 +124,7 @@ var defaults = map[string]any{
|
||||
"log.level": "info",
|
||||
"log.format": "json",
|
||||
"session.ttl_seconds": 3600,
|
||||
"idempotency.ttl_seconds": 86400,
|
||||
"redis.enabled": false,
|
||||
"redis.host": "localhost",
|
||||
"redis.port": 6379,
|
||||
|
||||
@@ -9,6 +9,7 @@ var (
|
||||
ErrValidation = errors.New("validation failed")
|
||||
ErrInvalidCursor = errors.New("invalid cursor")
|
||||
ErrConflict = errors.New("conflict")
|
||||
ErrIdempotency = errors.New("idempotency key already used with another payload")
|
||||
ErrUnauthenticated = errors.New("unauthenticated")
|
||||
ErrUnavailable = errors.New("temporarily unavailable")
|
||||
)
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
@@ -14,12 +16,29 @@ type Message struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
// MessageIdempotency is the client Idempotency-Key together with the fingerprint
|
||||
// of the payload it was first used with. The same key and fingerprint replay the
|
||||
// stored message; the same key with another payload is a conflict.
|
||||
type MessageIdempotency struct {
|
||||
Key string
|
||||
RequestHash [sha256.Size]byte
|
||||
}
|
||||
|
||||
type MessageDraft struct {
|
||||
ChatID uuid.UUID
|
||||
SenderID uuid.UUID
|
||||
Text string
|
||||
ChatID uuid.UUID
|
||||
SenderID uuid.UUID
|
||||
Text string
|
||||
Idempotency MessageIdempotency
|
||||
}
|
||||
|
||||
func (d MessageDraft) Validate() error {
|
||||
return validateNotBlank("text", d.Text)
|
||||
if err := validateNotBlank("text", d.Text); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if d.Idempotency.Key == "" {
|
||||
return fmt.Errorf("idempotency key is missing: %w", ErrValidation)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -88,20 +88,34 @@ func TestMessageDraftRejectsBlankText(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
draft := domain.MessageDraft{
|
||||
ChatID: uuid.New(),
|
||||
SenderID: uuid.New(),
|
||||
Text: strings.Repeat(" ", 10),
|
||||
ChatID: uuid.New(),
|
||||
SenderID: uuid.New(),
|
||||
Text: strings.Repeat(" ", 10),
|
||||
Idempotency: domain.MessageIdempotency{Key: "key-1"},
|
||||
}
|
||||
require.ErrorIs(t, draft.Validate(), domain.ErrValidation)
|
||||
}
|
||||
|
||||
func TestMessageDraftRejectsMissingIdempotencyKey(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
draft := domain.MessageDraft{
|
||||
ChatID: uuid.New(),
|
||||
SenderID: uuid.New(),
|
||||
Text: "привет",
|
||||
}
|
||||
require.ErrorIs(t, draft.Validate(), domain.ErrValidation,
|
||||
"с lab3 отправка сообщения невозможна без Idempotency-Key")
|
||||
}
|
||||
|
||||
func TestMessageDraftAcceptsTextWithSurroundingSpaces(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
draft := domain.MessageDraft{
|
||||
ChatID: uuid.New(),
|
||||
SenderID: uuid.New(),
|
||||
Text: " привет ",
|
||||
ChatID: uuid.New(),
|
||||
SenderID: uuid.New(),
|
||||
Text: " привет ",
|
||||
Idempotency: domain.MessageIdempotency{Key: "key-1"},
|
||||
}
|
||||
assert.NoError(t, draft.Validate(), "контракт запрещает только полностью пробельный текст")
|
||||
}
|
||||
|
||||
@@ -40,9 +40,10 @@ func (s *ServiceSuite) SetupTest() {
|
||||
|
||||
func (s *ServiceSuite) draft() domain.MessageDraft {
|
||||
return domain.MessageDraft{
|
||||
ChatID: s.chatID,
|
||||
SenderID: s.caller,
|
||||
Text: "Привет, Боб!",
|
||||
ChatID: s.chatID,
|
||||
SenderID: s.caller,
|
||||
Text: "Привет, Боб!",
|
||||
Idempotency: domain.MessageIdempotency{Key: "service-suite-key"},
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
//go:build integration
|
||||
|
||||
package postgres_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
"mtusi-messenger/internal/domain"
|
||||
)
|
||||
|
||||
type IdempotencySuite struct {
|
||||
BaseSuite
|
||||
}
|
||||
|
||||
func TestIdempotencySuite(t *testing.T) {
|
||||
suite.Run(t, new(IdempotencySuite))
|
||||
}
|
||||
|
||||
func messageDraft(chat domain.Chat, sender domain.User, key, text string) domain.MessageDraft {
|
||||
return domain.MessageDraft{
|
||||
ChatID: chat.ID,
|
||||
SenderID: sender.ID,
|
||||
Text: text,
|
||||
Idempotency: domain.MessageIdempotency{
|
||||
Key: key,
|
||||
RequestHash: sha256.Sum256([]byte(text)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) history(chat domain.Chat, actor domain.User) []domain.Message {
|
||||
s.T().Helper()
|
||||
|
||||
page, err := s.store.Messages().ListVisible(s.T().Context(), chat.ID, actor.ID, nil, 100)
|
||||
s.Require().NoError(err)
|
||||
|
||||
return page.Items
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestReplayReturnsStoredMessage() {
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
chat := s.createChat(alice, bob)
|
||||
draft := messageDraft(chat, alice, "key-1", "привет")
|
||||
|
||||
created, err := s.store.Messages().Create(s.T().Context(), draft)
|
||||
s.Require().NoError(err)
|
||||
|
||||
replayed, err := s.store.Messages().Create(s.T().Context(), draft)
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.Equal(created, replayed, "повтор с тем же ключом и payload возвращает исходное сообщение")
|
||||
s.Len(s.history(chat, bob), 1, "повтор не создаёт дубль")
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestSameKeyWithAnotherPayloadConflicts() {
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
chat := s.createChat(alice, bob)
|
||||
|
||||
created, err := s.store.Messages().Create(s.T().Context(), messageDraft(chat, alice, "key-1", "привет"))
|
||||
s.Require().NoError(err)
|
||||
|
||||
_, err = s.store.Messages().Create(s.T().Context(), messageDraft(chat, alice, "key-1", "другое"))
|
||||
s.Require().ErrorIs(err, domain.ErrIdempotency)
|
||||
|
||||
history := s.history(chat, bob)
|
||||
s.Require().Len(history, 1, "конфликт не создаёт сообщение")
|
||||
s.Equal(created.ID, history[0].ID, "исходное сообщение не изменено")
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestConcurrentReplaysCreateOneMessage() {
|
||||
const callers = 8
|
||||
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
chat := s.createChat(alice, bob)
|
||||
draft := messageDraft(chat, alice, "key-concurrent", "конкурентный повтор")
|
||||
|
||||
ctx := s.T().Context()
|
||||
results := make([]domain.Message, callers)
|
||||
errs := make([]error, callers)
|
||||
|
||||
start := make(chan struct{})
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
for i := range callers {
|
||||
wg.Add(1)
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
|
||||
<-start
|
||||
|
||||
results[i], errs[i] = s.store.Messages().Create(ctx, draft)
|
||||
}()
|
||||
}
|
||||
|
||||
close(start)
|
||||
wg.Wait()
|
||||
|
||||
for i := range callers {
|
||||
s.Require().NoError(errs[i], "caller %d", i)
|
||||
s.Equal(results[0].ID, results[i].ID, "все одновременные повторы получают одно сообщение")
|
||||
}
|
||||
|
||||
s.Len(s.history(chat, bob), 1, "конкурентный повтор создаёт ровно одно сообщение")
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestKeyIsScopedToActorAndChat() {
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
carol := s.createUser("carol")
|
||||
|
||||
first := s.createChat(alice, bob)
|
||||
second := s.createChat(alice, carol)
|
||||
|
||||
mine, err := s.store.Messages().Create(s.T().Context(), messageDraft(first, alice, "shared-key", "от Алисы"))
|
||||
s.Require().NoError(err)
|
||||
|
||||
byBob, err := s.store.Messages().Create(s.T().Context(), messageDraft(first, bob, "shared-key", "от Боба"))
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.NotEqual(mine.ID, byBob.ID, "одинаковый ключ разных пользователей независим")
|
||||
|
||||
another, err := s.store.Messages().Create(s.T().Context(), messageDraft(second, alice, "shared-key", "в другом чате"))
|
||||
s.Require().NoError(err)
|
||||
|
||||
s.NotEqual(mine.ID, another.ID, "одинаковый ключ в другом чате независим")
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestExpiredKeyIsReplaced() {
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
chat := s.createChat(alice, bob)
|
||||
draft := messageDraft(chat, alice, "key-expiring", "первое")
|
||||
|
||||
// Отрицательный TTL: записи идемпотентности истекают сразу.
|
||||
expiring := openStoreWithTTL(s.T(), s.db, -time.Second, nil)
|
||||
s.T().Cleanup(expiring.Close)
|
||||
|
||||
created, err := expiring.Messages().Create(s.T().Context(), draft)
|
||||
s.Require().NoError(err)
|
||||
|
||||
replaced, err := expiring.Messages().Create(s.T().Context(), messageDraft(chat, alice, "key-expiring", "второе"))
|
||||
s.Require().NoError(err, "истёкший ключ можно использовать с другим payload")
|
||||
s.NotEqual(created.ID, replaced.ID)
|
||||
}
|
||||
|
||||
func (s *IdempotencySuite) TestFailedAttemptLeavesNoClaim() {
|
||||
alice := s.createUser("alice")
|
||||
outsider := s.createUser("outsider")
|
||||
chat := s.createChat(alice)
|
||||
|
||||
_, err := s.store.Messages().Create(s.T().Context(), messageDraft(chat, outsider, "key-1", "привет"))
|
||||
s.Require().ErrorIs(err, domain.ErrNotFound)
|
||||
|
||||
var claims int
|
||||
|
||||
s.Require().NoError(
|
||||
s.pool.QueryRow(s.T().Context(), "SELECT count(*) FROM message_idempotency").Scan(&claims),
|
||||
)
|
||||
s.Zero(claims, "отклонённая попытка не оставляет claim: транзакция откатывается целиком")
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.31.1
|
||||
// source: idempotency.sql
|
||||
|
||||
package sqlcgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
const claimMessageIdempotency = `-- name: ClaimMessageIdempotency :one
|
||||
INSERT INTO message_idempotency (actor_id, chat_id, key, request_hash, expires_at)
|
||||
VALUES (
|
||||
$1,
|
||||
$2,
|
||||
$3,
|
||||
$4,
|
||||
$5
|
||||
)
|
||||
ON CONFLICT (actor_id, chat_id, key) DO UPDATE
|
||||
SET request_hash = EXCLUDED.request_hash,
|
||||
expires_at = EXCLUDED.expires_at,
|
||||
message_id = NULL
|
||||
WHERE message_idempotency.expires_at <= now()
|
||||
RETURNING key
|
||||
`
|
||||
|
||||
type ClaimMessageIdempotencyParams struct {
|
||||
ActorID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
Key string
|
||||
RequestHash []byte
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
// Claims the key for this actor/chat and returns whether this request owns it.
|
||||
// A live record wins: the statement returns nothing and the caller replays the
|
||||
// stored message. An expired record is replaced in place.
|
||||
func (q *Queries) ClaimMessageIdempotency(ctx context.Context, arg ClaimMessageIdempotencyParams) (string, error) {
|
||||
row := q.db.QueryRow(ctx, claimMessageIdempotency,
|
||||
arg.ActorID,
|
||||
arg.ChatID,
|
||||
arg.Key,
|
||||
arg.RequestHash,
|
||||
arg.ExpiresAt,
|
||||
)
|
||||
var key string
|
||||
err := row.Scan(&key)
|
||||
return key, err
|
||||
}
|
||||
|
||||
const completeMessageIdempotency = `-- name: CompleteMessageIdempotency :exec
|
||||
UPDATE message_idempotency
|
||||
SET message_id = $1
|
||||
WHERE actor_id = $2
|
||||
AND chat_id = $3
|
||||
AND key = $4
|
||||
`
|
||||
|
||||
type CompleteMessageIdempotencyParams struct {
|
||||
MessageID pgtype.UUID
|
||||
ActorID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
Key string
|
||||
}
|
||||
|
||||
func (q *Queries) CompleteMessageIdempotency(ctx context.Context, arg CompleteMessageIdempotencyParams) error {
|
||||
_, err := q.db.Exec(ctx, completeMessageIdempotency,
|
||||
arg.MessageID,
|
||||
arg.ActorID,
|
||||
arg.ChatID,
|
||||
arg.Key,
|
||||
)
|
||||
return err
|
||||
}
|
||||
|
||||
const getMessageByID = `-- name: GetMessageByID :one
|
||||
SELECT id, chat_id, sender_id, text, created_at
|
||||
FROM messages
|
||||
WHERE id = $1
|
||||
`
|
||||
|
||||
func (q *Queries) GetMessageByID(ctx context.Context, id uuid.UUID) (Message, error) {
|
||||
row := q.db.QueryRow(ctx, getMessageByID, id)
|
||||
var i Message
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.ChatID,
|
||||
&i.SenderID,
|
||||
&i.Text,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getMessageIdempotency = `-- name: GetMessageIdempotency :one
|
||||
SELECT message_id, request_hash
|
||||
FROM message_idempotency
|
||||
WHERE actor_id = $1
|
||||
AND chat_id = $2
|
||||
AND key = $3
|
||||
FOR UPDATE
|
||||
`
|
||||
|
||||
type GetMessageIdempotencyParams struct {
|
||||
ActorID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
Key string
|
||||
}
|
||||
|
||||
type GetMessageIdempotencyRow struct {
|
||||
MessageID pgtype.UUID
|
||||
RequestHash []byte
|
||||
}
|
||||
|
||||
// Concurrent duplicates block here until the owner commits, then read the
|
||||
// result it stored in the same transaction.
|
||||
func (q *Queries) GetMessageIdempotency(ctx context.Context, arg GetMessageIdempotencyParams) (GetMessageIdempotencyRow, error) {
|
||||
row := q.db.QueryRow(ctx, getMessageIdempotency, arg.ActorID, arg.ChatID, arg.Key)
|
||||
var i GetMessageIdempotencyRow
|
||||
err := row.Scan(&i.MessageID, &i.RequestHash)
|
||||
return i, err
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
)
|
||||
|
||||
type Chat struct {
|
||||
@@ -30,6 +31,16 @@ type Message struct {
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type MessageIdempotency struct {
|
||||
ActorID uuid.UUID
|
||||
ChatID uuid.UUID
|
||||
Key string
|
||||
RequestHash []byte
|
||||
MessageID pgtype.UUID
|
||||
CreatedAt time.Time
|
||||
ExpiresAt time.Time
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
TokenHash []byte
|
||||
UserID uuid.UUID
|
||||
|
||||
@@ -227,9 +227,22 @@ func (s *BaseSuite) TearDownTest() {
|
||||
}
|
||||
}
|
||||
|
||||
const testIdempotencyTTL = 24 * time.Hour
|
||||
|
||||
func openStore(t *testing.T, database string, override func(*config.Postgres)) *postgres.Store {
|
||||
t.Helper()
|
||||
|
||||
return openStoreWithTTL(t, database, testIdempotencyTTL, override)
|
||||
}
|
||||
|
||||
func openStoreWithTTL(
|
||||
t *testing.T,
|
||||
database string,
|
||||
idempotencyTTL time.Duration,
|
||||
override func(*config.Postgres),
|
||||
) *postgres.Store {
|
||||
t.Helper()
|
||||
|
||||
cfg := testConfig()
|
||||
cfg.Database = database
|
||||
|
||||
@@ -237,7 +250,7 @@ func openStore(t *testing.T, database string, override func(*config.Postgres)) *
|
||||
override(&cfg)
|
||||
}
|
||||
|
||||
store, err := postgres.New(t.Context(), cfg)
|
||||
store, err := postgres.New(t.Context(), cfg, idempotencyTTL)
|
||||
require.NoError(t, err)
|
||||
|
||||
return store
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
|
||||
"mtusi-messenger/internal/domain"
|
||||
"mtusi-messenger/internal/storage/postgres/internal/sqlcgen"
|
||||
@@ -16,16 +20,98 @@ type MessageRepository struct {
|
||||
}
|
||||
|
||||
func (r *MessageRepository) Create(ctx context.Context, draft domain.MessageDraft) (domain.Message, error) {
|
||||
ctx, cancel := r.store.timeout(ctx)
|
||||
defer cancel()
|
||||
var created domain.Message
|
||||
|
||||
row, err := r.store.queries.CreateMessage(ctx, sqlcgen.CreateMessageParams{
|
||||
err := r.store.RunInTx(ctx, func(queries *sqlcgen.Queries) error {
|
||||
message, err := createIdempotent(ctx, queries, draft, r.store.idempotencyTTL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
created = message
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return domain.Message{}, fmt.Errorf("create message: %w", err)
|
||||
}
|
||||
|
||||
return created, nil
|
||||
}
|
||||
|
||||
// createIdempotent stores the message and its Idempotency-Key in one
|
||||
// transaction: either both are committed or neither, so a replay never observes
|
||||
// a claimed key whose message is missing. Claiming is a single statement, so
|
||||
// concurrent duplicates with the same key wait for the winner and then replay
|
||||
// the message it stored.
|
||||
func createIdempotent(
|
||||
ctx context.Context,
|
||||
queries *sqlcgen.Queries,
|
||||
draft domain.MessageDraft,
|
||||
ttl time.Duration,
|
||||
) (domain.Message, error) {
|
||||
_, err := queries.ClaimMessageIdempotency(ctx, sqlcgen.ClaimMessageIdempotencyParams{
|
||||
ActorID: draft.SenderID,
|
||||
ChatID: draft.ChatID,
|
||||
Key: draft.Idempotency.Key,
|
||||
RequestHash: draft.Idempotency.RequestHash[:],
|
||||
ExpiresAt: time.Now().Add(ttl),
|
||||
})
|
||||
|
||||
switch {
|
||||
case errors.Is(err, pgx.ErrNoRows): // the key is still live: replay it
|
||||
return replayIdempotent(ctx, queries, draft)
|
||||
case err != nil:
|
||||
return domain.Message{}, mapError(err)
|
||||
default:
|
||||
return createClaimed(ctx, queries, draft)
|
||||
}
|
||||
}
|
||||
|
||||
func createClaimed(ctx context.Context, queries *sqlcgen.Queries, draft domain.MessageDraft) (domain.Message, error) {
|
||||
row, err := queries.CreateMessage(ctx, sqlcgen.CreateMessageParams{
|
||||
ChatID: draft.ChatID,
|
||||
SenderID: draft.SenderID,
|
||||
Text: draft.Text,
|
||||
})
|
||||
if err != nil {
|
||||
return domain.Message{}, fmt.Errorf("create message: %w", mapError(err))
|
||||
return domain.Message{}, mapError(err)
|
||||
}
|
||||
|
||||
err = queries.CompleteMessageIdempotency(ctx, sqlcgen.CompleteMessageIdempotencyParams{
|
||||
MessageID: pgtype.UUID{Bytes: row.ID, Valid: true},
|
||||
ActorID: draft.SenderID,
|
||||
ChatID: draft.ChatID,
|
||||
Key: draft.Idempotency.Key,
|
||||
})
|
||||
if err != nil {
|
||||
return domain.Message{}, mapError(err)
|
||||
}
|
||||
|
||||
return mapMessage(row.ID, row.ChatID, row.SenderID, row.Text, row.CreatedAt), nil
|
||||
}
|
||||
|
||||
func replayIdempotent(ctx context.Context, queries *sqlcgen.Queries, draft domain.MessageDraft) (domain.Message, error) {
|
||||
stored, err := queries.GetMessageIdempotency(ctx, sqlcgen.GetMessageIdempotencyParams{
|
||||
ActorID: draft.SenderID,
|
||||
ChatID: draft.ChatID,
|
||||
Key: draft.Idempotency.Key,
|
||||
})
|
||||
if err != nil {
|
||||
return domain.Message{}, mapError(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(stored.RequestHash, draft.Idempotency.RequestHash[:]) {
|
||||
return domain.Message{}, domain.ErrIdempotency
|
||||
}
|
||||
|
||||
if !stored.MessageID.Valid {
|
||||
return domain.Message{}, errors.New("idempotency record without a message")
|
||||
}
|
||||
|
||||
row, err := queries.GetMessageByID(ctx, uuid.UUID(stored.MessageID.Bytes))
|
||||
if err != nil {
|
||||
return domain.Message{}, mapError(err)
|
||||
}
|
||||
|
||||
return mapMessage(row.ID, row.ChatID, row.SenderID, row.Text, row.CreatedAt), nil
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package postgres_test
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"sync"
|
||||
"testing"
|
||||
@@ -21,6 +22,23 @@ func TestMessageRepositorySuite(t *testing.T) {
|
||||
suite.Run(t, new(MessageRepositorySuite))
|
||||
}
|
||||
|
||||
// draft builds a message draft with a fresh Idempotency-Key (lab3 contract).
|
||||
func (s *MessageRepositorySuite) draft(chatID, senderID uuid.UUID, text string) domain.MessageDraft {
|
||||
s.T().Helper()
|
||||
|
||||
key := uuid.NewString()
|
||||
|
||||
return domain.MessageDraft{
|
||||
ChatID: chatID,
|
||||
SenderID: senderID,
|
||||
Text: text,
|
||||
Idempotency: domain.MessageIdempotency{
|
||||
Key: key,
|
||||
RequestHash: sha256.Sum256([]byte(key + text)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MessageRepositorySuite) TestCreateAndPagination() {
|
||||
alice := s.createUser("alice")
|
||||
bob := s.createUser("bob")
|
||||
@@ -29,11 +47,7 @@ func (s *MessageRepositorySuite) TestCreateAndPagination() {
|
||||
|
||||
const total = 5
|
||||
for i := range total {
|
||||
message, err := s.store.Messages().Create(s.T().Context(), domain.MessageDraft{
|
||||
ChatID: chat.ID,
|
||||
SenderID: alice.ID,
|
||||
Text: fmt.Sprintf("сообщение %d", i),
|
||||
})
|
||||
message, err := s.store.Messages().Create(s.T().Context(), s.draft(chat.ID, alice.ID, fmt.Sprintf("сообщение %d", i)))
|
||||
s.Require().NoError(err)
|
||||
s.Equal(uuid.Version(7), message.ID.Version())
|
||||
s.False(message.CreatedAt.IsZero())
|
||||
@@ -69,9 +83,7 @@ func (s *MessageRepositorySuite) TestPaginationWithSharedTimestamp() {
|
||||
chat := s.createChat(alice)
|
||||
|
||||
for range 5 {
|
||||
_, err := s.store.Messages().Create(s.T().Context(), domain.MessageDraft{
|
||||
ChatID: chat.ID, SenderID: alice.ID, Text: "same timestamp",
|
||||
})
|
||||
_, err := s.store.Messages().Create(s.T().Context(), s.draft(chat.ID, alice.ID, "same timestamp"))
|
||||
s.Require().NoError(err)
|
||||
}
|
||||
|
||||
@@ -108,11 +120,7 @@ func (s *MessageRepositorySuite) TestAccessIsRestricted() {
|
||||
|
||||
chat := s.createChat(alice)
|
||||
|
||||
_, err := s.store.Messages().Create(s.T().Context(), domain.MessageDraft{
|
||||
ChatID: chat.ID,
|
||||
SenderID: bob.ID,
|
||||
Text: "чужое",
|
||||
})
|
||||
_, err := s.store.Messages().Create(s.T().Context(), s.draft(chat.ID, bob.ID, "чужое"))
|
||||
s.Require().ErrorIs(err, domain.ErrNotFound, "не участник не может писать в чат")
|
||||
|
||||
_, err = s.store.Messages().ListVisible(s.T().Context(), chat.ID, bob.ID, nil, 50)
|
||||
@@ -136,11 +144,7 @@ func (s *MessageRepositorySuite) TestFinishedMessageSurvivesConcurrentReads() {
|
||||
|
||||
wg.Go(func() {
|
||||
for i := range total {
|
||||
_, err := s.store.Messages().Create(s.T().Context(), domain.MessageDraft{
|
||||
ChatID: chat.ID,
|
||||
SenderID: alice.ID,
|
||||
Text: fmt.Sprintf("message %d", i),
|
||||
})
|
||||
_, err := s.store.Messages().Create(s.T().Context(), s.draft(chat.ID, alice.ID, fmt.Sprintf("message %d", i)))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
-- +goose Up
|
||||
-- Версия 3, а не 2: в базе, перенесённой из лабораторной 2, goose уже содержит
|
||||
-- запись версии 2 (другая миграция того же репозитория), и одноимённый номер был
|
||||
-- бы молча пропущен при обновлении существующего стенда до ЛР3.
|
||||
|
||||
CREATE TABLE message_idempotency (
|
||||
actor_id uuid NOT NULL REFERENCES users (id) ON DELETE CASCADE,
|
||||
chat_id uuid NOT NULL REFERENCES chats (id) ON DELETE CASCADE,
|
||||
key text NOT NULL,
|
||||
request_hash bytea NOT NULL,
|
||||
message_id uuid REFERENCES messages (id) ON DELETE CASCADE,
|
||||
created_at timestamptz NOT NULL DEFAULT now(),
|
||||
expires_at timestamptz NOT NULL,
|
||||
|
||||
PRIMARY KEY (actor_id, chat_id, key),
|
||||
CONSTRAINT message_idempotency_key_length CHECK (char_length(key) BETWEEN 1 AND 128)
|
||||
);
|
||||
|
||||
-- Expired records are replaced lazily by a new claim, the index keeps that
|
||||
-- lookup and a future sweep cheap.
|
||||
CREATE INDEX message_idempotency_expires_at_idx ON message_idempotency (expires_at);
|
||||
|
||||
-- +goose Down
|
||||
|
||||
DROP TABLE message_idempotency;
|
||||
@@ -0,0 +1,40 @@
|
||||
-- Claims the key for this actor/chat and returns whether this request owns it.
|
||||
-- A live record wins: the statement returns nothing and the caller replays the
|
||||
-- stored message. An expired record is replaced in place.
|
||||
-- name: ClaimMessageIdempotency :one
|
||||
INSERT INTO message_idempotency (actor_id, chat_id, key, request_hash, expires_at)
|
||||
VALUES (
|
||||
sqlc.arg(actor_id),
|
||||
sqlc.arg(chat_id),
|
||||
sqlc.arg(key),
|
||||
sqlc.arg(request_hash),
|
||||
sqlc.arg(expires_at)
|
||||
)
|
||||
ON CONFLICT (actor_id, chat_id, key) DO UPDATE
|
||||
SET request_hash = EXCLUDED.request_hash,
|
||||
expires_at = EXCLUDED.expires_at,
|
||||
message_id = NULL
|
||||
WHERE message_idempotency.expires_at <= now()
|
||||
RETURNING key;
|
||||
|
||||
-- Concurrent duplicates block here until the owner commits, then read the
|
||||
-- result it stored in the same transaction.
|
||||
-- name: GetMessageIdempotency :one
|
||||
SELECT message_id, request_hash
|
||||
FROM message_idempotency
|
||||
WHERE actor_id = sqlc.arg(actor_id)
|
||||
AND chat_id = sqlc.arg(chat_id)
|
||||
AND key = sqlc.arg(key)
|
||||
FOR UPDATE;
|
||||
|
||||
-- name: CompleteMessageIdempotency :exec
|
||||
UPDATE message_idempotency
|
||||
SET message_id = sqlc.arg(message_id)
|
||||
WHERE actor_id = sqlc.arg(actor_id)
|
||||
AND chat_id = sqlc.arg(chat_id)
|
||||
AND key = sqlc.arg(key);
|
||||
|
||||
-- name: GetMessageByID :one
|
||||
SELECT id, chat_id, sender_id, text, created_at
|
||||
FROM messages
|
||||
WHERE id = sqlc.arg(id);
|
||||
@@ -12,9 +12,10 @@ import (
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
pool *pgxpool.Pool
|
||||
queries *sqlcgen.Queries
|
||||
queryTimeout time.Duration
|
||||
pool *pgxpool.Pool
|
||||
queries *sqlcgen.Queries
|
||||
queryTimeout time.Duration
|
||||
idempotencyTTL time.Duration
|
||||
|
||||
users *UserRepository
|
||||
chats *ChatRepository
|
||||
@@ -22,7 +23,7 @@ type Store struct {
|
||||
sessions *SessionRepository
|
||||
}
|
||||
|
||||
func New(ctx context.Context, cfg config.Postgres) (*Store, error) {
|
||||
func New(ctx context.Context, cfg config.Postgres, idempotencyTTL time.Duration) (*Store, error) {
|
||||
cfg, err := normalize(cfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("normalize database config: %w", err)
|
||||
@@ -54,9 +55,10 @@ func New(ctx context.Context, cfg config.Postgres) (*Store, error) {
|
||||
}
|
||||
|
||||
store := &Store{
|
||||
pool: pool,
|
||||
queries: sqlcgen.New(pool),
|
||||
queryTimeout: cfg.QueryTimeout,
|
||||
pool: pool,
|
||||
queries: sqlcgen.New(pool),
|
||||
queryTimeout: cfg.QueryTimeout,
|
||||
idempotencyTTL: idempotencyTTL,
|
||||
}
|
||||
|
||||
store.users = &UserRepository{store: store}
|
||||
|
||||
@@ -52,7 +52,8 @@ func statusForDomainError(err error) int {
|
||||
case errors.Is(err, domain.ErrNotFound):
|
||||
return http.StatusNotFound
|
||||
case errors.Is(err, domain.ErrUsernameTaken),
|
||||
errors.Is(err, domain.ErrConflict):
|
||||
errors.Is(err, domain.ErrConflict),
|
||||
errors.Is(err, domain.ErrIdempotency):
|
||||
return http.StatusConflict
|
||||
case errors.Is(err, domain.ErrValidation),
|
||||
errors.Is(err, domain.ErrUnknownMember),
|
||||
|
||||
@@ -3,6 +3,7 @@ package rest
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -231,10 +232,19 @@ func (h *Handler) CreateMessage(
|
||||
) (oas.CreateMessageRes, error) {
|
||||
callerID := caller(ctx)
|
||||
|
||||
fingerprint, err := messageFingerprint(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
message, err := h.messages.Send(ctx, domain.MessageDraft{
|
||||
ChatID: params.ChatID,
|
||||
SenderID: callerID,
|
||||
Text: req.Text,
|
||||
Idempotency: domain.MessageIdempotency{
|
||||
Key: params.IdempotencyKey,
|
||||
RequestHash: fingerprint,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -246,6 +256,20 @@ func (h *Handler) CreateMessage(
|
||||
}, nil
|
||||
}
|
||||
|
||||
// messageFingerprint canonicalises the create-message payload so that the key
|
||||
// order of the client JSON cannot change the fingerprint, while a different
|
||||
// payload with the same Idempotency-Key can (contract 1.3.0).
|
||||
func messageFingerprint(req *oas.CreateMessage) ([sha256.Size]byte, error) {
|
||||
payload, err := json.Marshal(struct {
|
||||
Text string `json:"text"`
|
||||
}{Text: req.Text})
|
||||
if err != nil {
|
||||
return [sha256.Size]byte{}, fmt.Errorf("encode message payload: %w", err)
|
||||
}
|
||||
|
||||
return sha256.Sum256(payload), nil
|
||||
}
|
||||
|
||||
func (h *Handler) ListMessages(ctx context.Context, params oas.ListMessagesParams) (oas.ListMessagesRes, error) {
|
||||
callerID := caller(ctx)
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
instanceIDEnv = "INSTANCE_ID"
|
||||
instanceIDHeader = "X-Instance-Id"
|
||||
)
|
||||
|
||||
// InstanceID is the alias of this API process reported in the X-Instance-Id
|
||||
// response header (contract 1.3.0). INSTANCE_ID wins when set; otherwise the
|
||||
// hostname is used, which inside a container is the short container id the
|
||||
// stand maps back to the replica that served the request.
|
||||
func InstanceID() string {
|
||||
if id := os.Getenv(instanceIDEnv); id != "" {
|
||||
return id
|
||||
}
|
||||
|
||||
if host, err := os.Hostname(); err == nil && host != "" {
|
||||
return host
|
||||
}
|
||||
|
||||
return "unknown"
|
||||
}
|
||||
|
||||
// instanceIDWriter injects the header on the first write of the response, so
|
||||
// every API-generated response carries it — including errors produced by the
|
||||
// router, the security handler and the error handler rather than by a handler.
|
||||
// A value already set by the transport is never overwritten.
|
||||
type instanceIDWriter struct {
|
||||
http.ResponseWriter
|
||||
|
||||
id string
|
||||
sealed bool
|
||||
}
|
||||
|
||||
func (w *instanceIDWriter) inject() {
|
||||
if w.sealed {
|
||||
return
|
||||
}
|
||||
|
||||
w.sealed = true
|
||||
|
||||
if w.Header().Get(instanceIDHeader) == "" {
|
||||
w.Header().Set(instanceIDHeader, w.id)
|
||||
}
|
||||
}
|
||||
|
||||
func (w *instanceIDWriter) WriteHeader(status int) {
|
||||
w.inject()
|
||||
w.ResponseWriter.WriteHeader(status)
|
||||
}
|
||||
|
||||
func (w *instanceIDWriter) Write(body []byte) (int, error) {
|
||||
w.inject()
|
||||
|
||||
return w.ResponseWriter.Write(body)
|
||||
}
|
||||
|
||||
func instanceIDMiddleware(id string, next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
next.ServeHTTP(&instanceIDWriter{ResponseWriter: w, id: id}, r)
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package rest
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestInstanceIDPrefersEnvironment(t *testing.T) {
|
||||
t.Setenv(instanceIDEnv, "api-7")
|
||||
|
||||
assert.Equal(t, "api-7", InstanceID())
|
||||
}
|
||||
|
||||
func TestInstanceIDFallsBackToHostname(t *testing.T) {
|
||||
t.Setenv(instanceIDEnv, "")
|
||||
|
||||
host, err := os.Hostname()
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, host, InstanceID())
|
||||
}
|
||||
|
||||
func TestInstanceIDMiddleware(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
handler http.HandlerFunc
|
||||
wantID string
|
||||
wantCode int
|
||||
}{
|
||||
{
|
||||
name: "handler response",
|
||||
handler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusCreated) },
|
||||
wantID: "api-1",
|
||||
wantCode: http.StatusCreated,
|
||||
},
|
||||
{
|
||||
name: "response without explicit status",
|
||||
handler: func(w http.ResponseWriter, _ *http.Request) { _, _ = w.Write([]byte("ok")) },
|
||||
wantID: "api-1",
|
||||
wantCode: http.StatusOK,
|
||||
},
|
||||
{
|
||||
name: "error produced outside a handler",
|
||||
handler: func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusMethodNotAllowed) },
|
||||
wantID: "api-1",
|
||||
wantCode: http.StatusMethodNotAllowed,
|
||||
},
|
||||
{
|
||||
name: "header set by the transport is not overwritten",
|
||||
handler: func(w http.ResponseWriter, _ *http.Request) {
|
||||
w.Header().Set(instanceIDHeader, "explicit")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
},
|
||||
wantID: "explicit",
|
||||
wantCode: http.StatusOK,
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
instanceIDMiddleware("api-1", test.handler).ServeHTTP(
|
||||
recorder,
|
||||
httptest.NewRequest(http.MethodGet, "/api/v1/users/me", nil),
|
||||
)
|
||||
|
||||
assert.Equal(t, test.wantID, recorder.Header().Get(instanceIDHeader))
|
||||
assert.Equal(t, test.wantCode, recorder.Code)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,8 @@ import (
|
||||
)
|
||||
|
||||
var regexMap = map[string]ogenregex.Regexp{
|
||||
"^[a-z0-9_]{3,32}$": ogenregex.MustCompile("^[a-z0-9_]{3,32}$"),
|
||||
"^[A-Za-z0-9._:-]+$": ogenregex.MustCompile("^[A-Za-z0-9._:-]+$"),
|
||||
"^[a-z0-9_]{3,32}$": ogenregex.MustCompile("^[a-z0-9_]{3,32}$"),
|
||||
}
|
||||
|
||||
type (
|
||||
|
||||
@@ -259,6 +259,10 @@ func (s *Server) handleCreateMessageRequest(args [1]string, argsEscaped bool, w
|
||||
Name: "chat_id",
|
||||
In: "path",
|
||||
}: params.ChatID,
|
||||
{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}: params.IdempotencyKey,
|
||||
},
|
||||
Raw: r,
|
||||
}
|
||||
|
||||
@@ -18,6 +18,11 @@ import (
|
||||
// CreateMessageParams is parameters of createMessage operation.
|
||||
type CreateMessageParams struct {
|
||||
ChatID uuid.UUID
|
||||
// Обязателен с lab3. Область: пользователь + метод + путь +
|
||||
// ключ; хранить результат не менее 24 ч. Повтор того же JSON
|
||||
// возвращает исходный 201 и то же сообщение, другой JSON —
|
||||
// 409.
|
||||
IdempotencyKey string
|
||||
}
|
||||
|
||||
func unpackCreateMessageParams(packed middleware.Parameters) (params CreateMessageParams) {
|
||||
@@ -28,10 +33,18 @@ func unpackCreateMessageParams(packed middleware.Parameters) (params CreateMessa
|
||||
}
|
||||
params.ChatID = packed[key].(uuid.UUID)
|
||||
}
|
||||
{
|
||||
key := middleware.ParameterKey{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
}
|
||||
params.IdempotencyKey = packed[key].(string)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func decodeCreateMessageParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateMessageParams, _ error) {
|
||||
h := uri.NewHeaderDecoder(r.Header)
|
||||
// Decode path: chat_id.
|
||||
if err := func() error {
|
||||
param := args[0]
|
||||
@@ -77,6 +90,60 @@ func decodeCreateMessageParams(args [1]string, argsEscaped bool, r *http.Request
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
// Decode header: Idempotency-Key.
|
||||
if err := func() error {
|
||||
cfg := uri.HeaderParameterDecodingConfig{
|
||||
Name: "Idempotency-Key",
|
||||
Explode: false,
|
||||
}
|
||||
if err := h.HasParam(cfg); err == nil {
|
||||
if err := h.DecodeParam(cfg, func(d uri.Decoder) error {
|
||||
val, err := d.DecodeValue()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c, err := conv.ToString(val)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.IdempotencyKey = c
|
||||
return nil
|
||||
}); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 128,
|
||||
MaxLengthSet: true,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: regexMap["^[A-Za-z0-9._:-]+$"],
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(params.IdempotencyKey)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return params, &ogenerrors.DecodeParamError{
|
||||
Name: "Idempotency-Key",
|
||||
In: "header",
|
||||
Err: err,
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,7 +26,7 @@ var (
|
||||
}
|
||||
rn4AllowedHeaders = map[string]string{
|
||||
"GET": "Authorization",
|
||||
"POST": "Authorization,Content-Type",
|
||||
"POST": "Authorization,Content-Type,Idempotency-Key",
|
||||
}
|
||||
rn12AllowedHeaders = map[string]string{
|
||||
"POST": "Content-Type",
|
||||
|
||||
@@ -120,8 +120,14 @@ func (s *Chat) SetCreatedAt(val time.Time) {
|
||||
|
||||
// ChatHeaders wraps Chat with response headers.
|
||||
type ChatHeaders struct {
|
||||
XRequestID OptString
|
||||
Response Chat
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Chat
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *ChatHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -134,6 +140,11 @@ func (s *ChatHeaders) GetResponse() Chat {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *ChatHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *ChatHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -175,8 +186,14 @@ func (s *ChatPage) SetNextCursor(val NilString) {
|
||||
|
||||
// ChatPageHeaders wraps ChatPage with response headers.
|
||||
type ChatPageHeaders struct {
|
||||
XRequestID OptString
|
||||
Response ChatPage
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response ChatPage
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *ChatPageHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -189,6 +206,11 @@ func (s *ChatPageHeaders) GetResponse() ChatPage {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *ChatPageHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *ChatPageHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -296,9 +318,10 @@ func (*CreateSessionServiceUnavailable) createSessionRes() {}
|
||||
|
||||
// CreateSessionTooManyRequestsHeaders wraps Error with response headers.
|
||||
type CreateSessionTooManyRequestsHeaders struct {
|
||||
RetryAfter OptInt
|
||||
XRequestID OptString
|
||||
Response Error
|
||||
RetryAfter OptInt
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Error
|
||||
}
|
||||
|
||||
// GetRetryAfter returns the value of RetryAfter.
|
||||
@@ -306,6 +329,11 @@ func (s *CreateSessionTooManyRequestsHeaders) GetRetryAfter() OptInt {
|
||||
return s.RetryAfter
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *CreateSessionTooManyRequestsHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
func (s *CreateSessionTooManyRequestsHeaders) GetXRequestID() OptString {
|
||||
return s.XRequestID
|
||||
@@ -321,6 +349,11 @@ func (s *CreateSessionTooManyRequestsHeaders) SetRetryAfter(val OptInt) {
|
||||
s.RetryAfter = val
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *CreateSessionTooManyRequestsHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *CreateSessionTooManyRequestsHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -344,6 +377,7 @@ func (*CreateSessionTooManyRequestsHeaders) revokeSessionRes() {}
|
||||
// CreateSessionUnauthorizedHeaders wraps Error with response headers.
|
||||
type CreateSessionUnauthorizedHeaders struct {
|
||||
WWWAuthenticate OptString
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Error
|
||||
}
|
||||
@@ -353,6 +387,11 @@ func (s *CreateSessionUnauthorizedHeaders) GetWWWAuthenticate() OptString {
|
||||
return s.WWWAuthenticate
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *CreateSessionUnauthorizedHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
func (s *CreateSessionUnauthorizedHeaders) GetXRequestID() OptString {
|
||||
return s.XRequestID
|
||||
@@ -368,6 +407,11 @@ func (s *CreateSessionUnauthorizedHeaders) SetWWWAuthenticate(val OptString) {
|
||||
s.WWWAuthenticate = val
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *CreateSessionUnauthorizedHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *CreateSessionUnauthorizedHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -587,8 +631,14 @@ func (s *ErrorErrorCode) UnmarshalText(data []byte) error {
|
||||
|
||||
// ErrorHeaders wraps Error with response headers.
|
||||
type ErrorHeaders struct {
|
||||
XRequestID OptString
|
||||
Response Error
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Error
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *ErrorHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -601,6 +651,11 @@ func (s *ErrorHeaders) GetResponse() Error {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *ErrorHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *ErrorHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -650,8 +705,14 @@ func (s *Health) SetStatus(val HealthStatus) {
|
||||
|
||||
// HealthHeaders wraps Health with response headers.
|
||||
type HealthHeaders struct {
|
||||
XRequestID OptString
|
||||
Response Health
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Health
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *HealthHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -664,6 +725,11 @@ func (s *HealthHeaders) GetResponse() Health {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *HealthHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *HealthHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -812,8 +878,14 @@ func (s *Message) SetCreatedAt(val time.Time) {
|
||||
|
||||
// MessageHeaders wraps Message with response headers.
|
||||
type MessageHeaders struct {
|
||||
XRequestID OptString
|
||||
Response Message
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Message
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *MessageHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -826,6 +898,11 @@ func (s *MessageHeaders) GetResponse() Message {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *MessageHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *MessageHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -866,8 +943,14 @@ func (s *MessagePage) SetNextCursor(val NilString) {
|
||||
|
||||
// MessagePageHeaders wraps MessagePage with response headers.
|
||||
type MessagePageHeaders struct {
|
||||
XRequestID OptString
|
||||
Response MessagePage
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response MessagePage
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *MessagePageHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -880,6 +963,11 @@ func (s *MessagePageHeaders) GetResponse() MessagePage {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *MessagePageHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *MessagePageHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -1059,7 +1147,13 @@ func (*RevokeSessionInternalServerError) revokeSessionRes() {}
|
||||
|
||||
// RevokeSessionNoContent is response for RevokeSession operation.
|
||||
type RevokeSessionNoContent struct {
|
||||
XRequestID OptString
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *RevokeSessionNoContent) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -1067,6 +1161,11 @@ func (s *RevokeSessionNoContent) GetXRequestID() OptString {
|
||||
return s.XRequestID
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *RevokeSessionNoContent) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *RevokeSessionNoContent) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -1128,8 +1227,14 @@ func (s *Session) SetUser(val User) {
|
||||
|
||||
// SessionHeaders wraps Session with response headers.
|
||||
type SessionHeaders struct {
|
||||
XRequestID OptString
|
||||
Response Session
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response Session
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *SessionHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -1142,6 +1247,11 @@ func (s *SessionHeaders) GetResponse() Session {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *SessionHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *SessionHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
@@ -1204,8 +1314,14 @@ func (s *User) SetCreatedAt(val time.Time) {
|
||||
|
||||
// UserHeaders wraps User with response headers.
|
||||
type UserHeaders struct {
|
||||
XRequestID OptString
|
||||
Response User
|
||||
XInstanceID OptString
|
||||
XRequestID OptString
|
||||
Response User
|
||||
}
|
||||
|
||||
// GetXInstanceID returns the value of XInstanceID.
|
||||
func (s *UserHeaders) GetXInstanceID() OptString {
|
||||
return s.XInstanceID
|
||||
}
|
||||
|
||||
// GetXRequestID returns the value of XRequestID.
|
||||
@@ -1218,6 +1334,11 @@ func (s *UserHeaders) GetResponse() User {
|
||||
return s.Response
|
||||
}
|
||||
|
||||
// SetXInstanceID sets the value of XInstanceID.
|
||||
func (s *UserHeaders) SetXInstanceID(val OptString) {
|
||||
s.XInstanceID = val
|
||||
}
|
||||
|
||||
// SetXRequestID sets the value of XRequestID.
|
||||
func (s *UserHeaders) SetXRequestID(val OptString) {
|
||||
s.XRequestID = val
|
||||
|
||||
@@ -72,6 +72,36 @@ func (s *ChatHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -165,6 +195,36 @@ func (s *ChatPageHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -442,6 +502,36 @@ func (s *CreateSessionTooManyRequestsHeaders) Validate() error {
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -495,6 +585,36 @@ func (s *CreateSessionUnauthorizedHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -786,6 +906,36 @@ func (s *ErrorHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -902,6 +1052,36 @@ func (s *HealthHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -1079,6 +1259,36 @@ func (s *MessageHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -1172,6 +1382,36 @@ func (s *MessagePageHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -1281,6 +1521,36 @@ func (s *RevokeSessionNoContent) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -1377,6 +1647,36 @@ func (s *SessionHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
@@ -1488,6 +1788,36 @@ func (s *UserHeaders) Validate() error {
|
||||
}
|
||||
|
||||
var failures []validate.FieldError
|
||||
if err := func() error {
|
||||
if value, ok := s.XInstanceID.Get(); ok {
|
||||
if err := func() error {
|
||||
if err := (validate.String{
|
||||
MinLength: 1,
|
||||
MinLengthSet: true,
|
||||
MaxLength: 0,
|
||||
MaxLengthSet: false,
|
||||
Email: false,
|
||||
Hostname: false,
|
||||
Regex: nil,
|
||||
MinNumeric: 0,
|
||||
MinNumericSet: false,
|
||||
MaxNumeric: 0,
|
||||
MaxNumericSet: false,
|
||||
}).Validate(string(value)); err != nil {
|
||||
return errors.Wrap(err, "string")
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}(); err != nil {
|
||||
failures = append(failures, validate.FieldError{
|
||||
Name: "XInstanceID",
|
||||
Error: err,
|
||||
})
|
||||
}
|
||||
if err := func() error {
|
||||
if value, ok := s.XRequestID.Get(); ok {
|
||||
if err := func() error {
|
||||
|
||||
@@ -24,5 +24,5 @@ func NewRouter(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return requestIDMiddleware(server), nil
|
||||
return requestIDMiddleware(instanceIDMiddleware(InstanceID(), server)), nil
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package rest_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@@ -22,7 +23,10 @@ import (
|
||||
"mtusi-messenger/internal/transport/rest/mocks"
|
||||
)
|
||||
|
||||
const requestIDHeader = "X-Request-ID"
|
||||
const (
|
||||
requestIDHeader = "X-Request-ID"
|
||||
instanceIDHeader = "X-Instance-Id"
|
||||
)
|
||||
|
||||
func basic(username, password string) string {
|
||||
return base64.StdEncoding.EncodeToString([]byte(username + ":" + password))
|
||||
@@ -324,3 +328,114 @@ func TestNotFoundAndMethodNotAllowed(t *testing.T) {
|
||||
result = fixture.do(t, http.MethodDelete, "/health/live", nil, nil)
|
||||
require.Equal(t, http.StatusMethodNotAllowed, result.status)
|
||||
}
|
||||
|
||||
func TestCreateMessageRequiresIdempotencyKey(t *testing.T) {
|
||||
fixture := newRouterFixture(t)
|
||||
|
||||
user := domain.User{ID: uuid.New(), Username: "alice", DisplayName: "Алиса", CreatedAt: time.Now().UTC()}
|
||||
fixture.sessions.EXPECT().Resolve(mock.Anything, "opaque-token").Return(user, nil).Maybe()
|
||||
|
||||
result := fixture.do(
|
||||
t,
|
||||
http.MethodPost,
|
||||
"/api/v1/chats/"+uuid.NewString()+"/messages",
|
||||
[]byte(`{"text":"привет"}`),
|
||||
map[string]string{"Authorization": "Bearer opaque-token"},
|
||||
)
|
||||
require.Equal(t, http.StatusBadRequest, result.status)
|
||||
require.NotEmpty(t, result.header.Get(instanceIDHeader), "ответ об ошибке тоже помечен репликой")
|
||||
}
|
||||
|
||||
func TestCreateMessageFingerprintIgnoresJSONFormatting(t *testing.T) {
|
||||
fixture := newRouterFixture(t)
|
||||
|
||||
user := domain.User{ID: uuid.New(), Username: "alice", DisplayName: "Алиса", CreatedAt: time.Now().UTC()}
|
||||
chatID := uuid.New()
|
||||
message := domain.Message{ID: uuid.New(), ChatID: chatID, SenderID: user.ID, Text: "привет", CreatedAt: time.Now().UTC()}
|
||||
fixture.sessions.EXPECT().Resolve(mock.Anything, "opaque-token").Return(user, nil).Maybe()
|
||||
|
||||
var fingerprints [][sha256.Size]byte
|
||||
|
||||
fixture.messages.EXPECT().
|
||||
Send(mock.Anything, mock.MatchedBy(func(draft domain.MessageDraft) bool {
|
||||
if draft.ChatID != chatID || draft.SenderID != user.ID || draft.Idempotency.Key != "key-1" {
|
||||
return false
|
||||
}
|
||||
|
||||
fingerprints = append(fingerprints, draft.Idempotency.RequestHash)
|
||||
|
||||
return true
|
||||
})).
|
||||
Return(message, nil)
|
||||
|
||||
headers := map[string]string{"Authorization": "Bearer opaque-token", "Idempotency-Key": "key-1"}
|
||||
path := "/api/v1/chats/" + chatID.String() + "/messages"
|
||||
|
||||
first := fixture.do(t, http.MethodPost, path, []byte(`{"text":"привет"}`), headers)
|
||||
replay := fixture.do(t, http.MethodPost, path, []byte(`{ "text" : "привет" }`), headers)
|
||||
other := fixture.do(t, http.MethodPost, path, []byte(`{"text":"другое"}`), headers)
|
||||
|
||||
require.Equal(t, http.StatusCreated, first.status)
|
||||
require.Equal(t, http.StatusCreated, replay.status)
|
||||
require.Equal(t, http.StatusCreated, other.status)
|
||||
require.NotEmpty(t, first.header.Get(instanceIDHeader))
|
||||
require.Len(t, fingerprints, 3)
|
||||
require.Equal(t, fingerprints[0], fingerprints[1],
|
||||
"порядок ключей и пробелы в JSON не меняют отпечаток payload")
|
||||
require.NotEqual(t, fingerprints[0], fingerprints[2],
|
||||
"другой payload с тем же ключом — это конфликт, отпечатки обязаны различаться")
|
||||
}
|
||||
|
||||
func TestCreateMessageReplayConflictIsReportedAsConflict(t *testing.T) {
|
||||
fixture := newRouterFixture(t)
|
||||
|
||||
user := domain.User{ID: uuid.New(), Username: "alice", DisplayName: "Алиса", CreatedAt: time.Now().UTC()}
|
||||
fixture.sessions.EXPECT().Resolve(mock.Anything, "opaque-token").Return(user, nil).Maybe()
|
||||
fixture.messages.EXPECT().
|
||||
Send(mock.Anything, mock.Anything).
|
||||
Return(domain.Message{}, domain.ErrIdempotency).
|
||||
Once()
|
||||
|
||||
result := fixture.do(
|
||||
t,
|
||||
http.MethodPost,
|
||||
"/api/v1/chats/"+uuid.NewString()+"/messages",
|
||||
[]byte(`{"text":"другой"}`),
|
||||
map[string]string{"Authorization": "Bearer opaque-token", "Idempotency-Key": "key-1"},
|
||||
)
|
||||
require.Equal(t, http.StatusConflict, result.status)
|
||||
|
||||
var body struct {
|
||||
Error struct {
|
||||
Code string `json:"code"`
|
||||
} `json:"error"`
|
||||
}
|
||||
require.NoError(t, json.Unmarshal(result.body, &body))
|
||||
require.Equal(t, "conflict", body.Error.Code)
|
||||
}
|
||||
|
||||
func TestEveryResponseCarriesInstanceID(t *testing.T) {
|
||||
fixture := newRouterFixture(t)
|
||||
|
||||
user := domain.User{ID: uuid.New(), Username: "alice", DisplayName: "Алиса", CreatedAt: time.Now().UTC()}
|
||||
fixture.sessions.EXPECT().Resolve(mock.Anything, "opaque-token").Return(user, nil).Maybe()
|
||||
|
||||
tests := map[string]httpResult{
|
||||
"успешный ответ": fixture.do(t, http.MethodGet, "/health/live", nil, nil),
|
||||
"неизвестный маршрут": fixture.do(t, http.MethodGet, "/nope", nil, nil),
|
||||
"неподдерживаемый метод": fixture.do(t, http.MethodDelete, "/health/live", nil, nil),
|
||||
"ошибка валидации схемы": fixture.do(
|
||||
t,
|
||||
http.MethodPost,
|
||||
"/api/v1/chats/"+uuid.NewString()+"/messages",
|
||||
[]byte(`{"text":"привет"}`),
|
||||
map[string]string{"Authorization": "Bearer opaque-token"},
|
||||
),
|
||||
}
|
||||
|
||||
for name, result := range tests {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
require.NotEmpty(t, result.header.Get(instanceIDHeader))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Executable
+177
@@ -0,0 +1,177 @@
|
||||
#!/bin/sh
|
||||
# Проверка критерия «LB исключает неготовую реплику» (lab3).
|
||||
#
|
||||
# Рядом с рабочими репликами поднимается третья с тем же сетевым alias, но её
|
||||
# доступ к БД идёт через временный TCP-прокси. Пока прокси жив, реплика готова и
|
||||
# получает трафик через LB. После остановки прокси реплика остаётся доступной по
|
||||
# сети (процесс жив, порт открыт), но /health/ready отвечает 503 — и балансировщик
|
||||
# обязан убрать её из ротации и не отправлять ей ни одного запроса.
|
||||
#
|
||||
# scripts/lb_readiness_check.sh # стенд поднят (make up)
|
||||
# OUT=evidence/lb-readiness.txt scripts/lb_readiness_check.sh
|
||||
set -eu
|
||||
|
||||
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
OUT=${OUT:-evidence/lb-readiness.txt}
|
||||
PROJECT=${COMPOSE_PROJECT_NAME:-mtusi-messenger-lab3}
|
||||
NET=${PROJECT}_default
|
||||
IMAGE=${IMAGE:-mtusi-messenger:lab3}
|
||||
STATS=${STATS:-http://127.0.0.1:8404/stats;csv}
|
||||
BASE_URL=${BASE_URL:-http://localhost:8080}
|
||||
CANDIDATE=lb-readiness-candidate
|
||||
PROXY=lb-readiness-pgproxy
|
||||
REQUESTS=${REQUESTS:-40}
|
||||
|
||||
NO_PROXY_ENV="env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy"
|
||||
NO_PROXY_ENV="$NO_PROXY_ENV NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1"
|
||||
|
||||
cleanup() {
|
||||
docker rm -f "$CANDIDATE" "$PROXY" >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
trap cleanup EXIT INT TERM
|
||||
cleanup
|
||||
|
||||
instances() {
|
||||
tries=${1:-$REQUESTS}
|
||||
i=0
|
||||
|
||||
while [ "$i" -lt "$tries" ]; do
|
||||
curl -fsS --noproxy '*' -D - -o /dev/null "$BASE_URL/health/live" 2>/dev/null \
|
||||
| awk 'tolower($1) == "x-instance-id:" { print $2 }'
|
||||
i=$((i + 1))
|
||||
done | sort | uniq -c
|
||||
}
|
||||
|
||||
stats() {
|
||||
curl -s --noproxy '*' "$STATS" | awk -F, '$1 ~ /^api/ { printf "%s=%s ", $2, $18 }'
|
||||
}
|
||||
|
||||
readiness() {
|
||||
docker exec "$CANDIDATE" wget -qO- -S -T 3 http://127.0.0.1:8080/health/ready 2>&1 \
|
||||
| awk '/^ HTTP\//{print $2; exit}'
|
||||
}
|
||||
|
||||
wait_readiness() {
|
||||
want=$1
|
||||
attempt=0
|
||||
|
||||
while [ "$attempt" -lt 30 ]; do
|
||||
[ "$(readiness)" = "$want" ] && return 0
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
up_slots() {
|
||||
curl -s --noproxy '*' "$STATS" | awk -F, '$1 ~ /^api/ && $18 == "UP" && $2 != "BACKEND" { printf "%s ", $2 }'
|
||||
}
|
||||
|
||||
wait_new_up_slot() {
|
||||
before=$1
|
||||
attempt=0
|
||||
|
||||
while [ "$attempt" -lt 30 ]; do
|
||||
for slot in $(up_slots); do
|
||||
case " $before " in
|
||||
*" $slot "*) ;;
|
||||
*) echo "$slot"; return 0 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
wait_slot_status() {
|
||||
slot=$1
|
||||
want=$2
|
||||
attempt=0
|
||||
|
||||
while [ "$attempt" -lt 30 ]; do
|
||||
status=$(curl -s --noproxy '*' "$STATS" | awk -F, -v s="$slot" '$1 ~ /^api/ && $2 == s { print $18; exit }')
|
||||
[ "$status" = "$want" ] && return 0
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
{
|
||||
echo "# LB excludes a not-ready but reachable replica (lab3)"
|
||||
echo "# generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "# lb: $(docker inspect -f '{{.Config.Image}}' "$(docker ps -q --filter label=com.docker.compose.service=lb)" 2>/dev/null)"
|
||||
echo
|
||||
echo "## 1. baseline: requests through LB by replica"
|
||||
instances
|
||||
baseline_slots=$(up_slots)
|
||||
echo " stats: $(stats)"
|
||||
echo
|
||||
echo "## 2. start a temporary TCP proxy to postgres and a candidate replica behind the same network alias"
|
||||
docker run -d --name "$PROXY" --network "$NET" alpine/socat \
|
||||
tcp-listen:5432,fork,reuseaddr tcp-connect:postgres:5432 >/dev/null
|
||||
docker run -d --name "$CANDIDATE" --network "$NET" --network-alias api-replica \
|
||||
-e APP_CONFIG=/etc/messenger/dev/config.yaml \
|
||||
-e POSTGRES_HOST="$PROXY" -e POSTGRES_PORT=5432 \
|
||||
-e POSTGRES_DATABASE=messenger -e POSTGRES_USER=messenger \
|
||||
-e POSTGRES_PASSWORD=messenger -e POSTGRES_SSL_MODE=disable \
|
||||
-e REDIS_ENABLED=true -e REDIS_HOST=redis -e CACHE_ENABLED=true \
|
||||
"$IMAGE" >/dev/null
|
||||
|
||||
if ! wait_readiness 200; then
|
||||
echo " candidate did not become ready" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " instance-id: $(docker inspect -f '{{.Config.Hostname}}' "$CANDIDATE"), readiness while its database is reachable: 200"
|
||||
|
||||
slot=$(wait_new_up_slot "$baseline_slots" || true)
|
||||
if [ -z "$slot" ]; then
|
||||
echo " candidate did not appear UP in the load balancer" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " load balancer slot for the candidate: $slot, stats: $(stats)"
|
||||
echo
|
||||
echo "## 3. cut the candidate's database access (stop only the TCP proxy)"
|
||||
docker stop "$PROXY" >/dev/null
|
||||
|
||||
if ! wait_readiness 503; then
|
||||
echo " candidate readiness did not become 503" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo " candidate is still running: $(docker inspect -f '{{.State.Status}}' "$CANDIDATE"), readiness: 503"
|
||||
echo " waiting for the load balancer to mark $slot DOWN"
|
||||
|
||||
if ! wait_slot_status "$slot" DOWN; then
|
||||
echo " WARNING: $slot is still not DOWN" >&2
|
||||
fi
|
||||
|
||||
echo " stats after failure: $(stats)"
|
||||
echo
|
||||
echo "## 4. ${REQUESTS} requests through LB while the candidate is not ready"
|
||||
instances
|
||||
echo " (the candidate must not appear above)"
|
||||
echo
|
||||
echo "## 5. business writes through LB during the exclusion"
|
||||
# shellcheck disable=SC2086
|
||||
$NO_PROXY_ENV python3 tests/load.py --base-url "$BASE_URL" --duration 5 --concurrency 2 \
|
||||
| grep -E '"successful_rps"|"failed_requests"|"error_ratio"'
|
||||
echo
|
||||
echo "## 6. cleanup"
|
||||
cleanup
|
||||
sleep 5
|
||||
echo " stats after cleanup: $(stats)"
|
||||
} > "$OUT" 2>&1
|
||||
|
||||
cat "$OUT"
|
||||
printf 'lb_readiness_check.sh: evidence in %s\n' "$OUT"
|
||||
Regular → Executable
+44
-6
@@ -1,11 +1,49 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
# Restart hook: bounce API replicas and every state store of the lab3 stand.
|
||||
#
|
||||
# scripts/restart.sh
|
||||
#
|
||||
# Persistent volumes are kept: no `down -v`, no flush, no re-seed. The one-shot
|
||||
# `migrate` service is not re-run (schema stays as it is, data and sessions
|
||||
# survive). The script exits 0 only after /health/ready answers through the LB.
|
||||
# No credentials are printed.
|
||||
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
COMPOSE_BIN=${COMPOSE_BIN:-docker-compose}
|
||||
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
"$COMPOSE_BIN" -f docker-compose.local.yaml restart postgres redis
|
||||
"$COMPOSE_BIN" -f docker-compose.local.yaml up -d --wait postgres redis
|
||||
"$COMPOSE_BIN" -f docker-compose.local.yaml up -d --force-recreate api
|
||||
COMPOSE_BIN=${COMPOSE_BIN:-docker compose}
|
||||
PORT=${SERVER_PORT:-8080}
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
compose() {
|
||||
# shellcheck disable=SC2086
|
||||
$COMPOSE_BIN --env-file .env -f compose.yaml "$@"
|
||||
}
|
||||
|
||||
# 1. State stores: restart the running ones, then make sure they are healthy.
|
||||
# Volumes are attached as before, nothing is dropped or re-seeded.
|
||||
compose up -d --wait postgres redis
|
||||
compose restart postgres redis
|
||||
compose up -d --wait postgres redis
|
||||
|
||||
# 2. API replicas: restart in place (same containers, same addresses) and bring
|
||||
# back any replica that was stopped by the fault-injection hook.
|
||||
compose restart api
|
||||
compose up -d --wait --no-deps api
|
||||
|
||||
# 3. Load balancer keeps its upstream; re-resolve in case addresses changed.
|
||||
compose restart lb
|
||||
|
||||
# 4. Wait for readiness through the public entry point.
|
||||
attempt=0
|
||||
while [ "$attempt" -lt 60 ]; do
|
||||
if curl -fsS --noproxy '*' -o /dev/null "http://127.0.0.1:${PORT}/health/ready"; then
|
||||
printf 'restart.sh: stack restarted, http://127.0.0.1:%s/health/ready is ready\n' "$PORT"
|
||||
exit 0
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
printf 'restart.sh: /health/ready did not become ready through the LB\n' >&2
|
||||
exit 1
|
||||
|
||||
Executable
+141
@@ -0,0 +1,141 @@
|
||||
#!/bin/sh
|
||||
# Rolling update of the API replicas under load (lab3, level 4).
|
||||
#
|
||||
# The image is rebuilt, then every replica is deleted and recreated one at a
|
||||
# time. Between the steps the script waits until the replacement is healthy and
|
||||
# until the load balancer really serves through the declared number of replicas,
|
||||
# so two replicas are never replaced at once. Nginx resolves the shared network
|
||||
# alias `api-replica`, therefore recreated containers may get new names and IPs.
|
||||
#
|
||||
# scripts/rolling_update.sh # requires a running stand (make up)
|
||||
# DURATION=45 CONCURRENCY=8 scripts/rolling_update.sh
|
||||
set -eu
|
||||
|
||||
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
COMPOSE_BIN=${COMPOSE_BIN:-docker compose}
|
||||
PYTHON=${PYTHON:-python3}
|
||||
DURATION=${DURATION:-60}
|
||||
CONCURRENCY=${CONCURRENCY:-8}
|
||||
BASE_URL=${BASE_URL:-http://localhost:8080}
|
||||
OUT=${OUT:-evidence/rolling-update}
|
||||
# Профиль без насыщения: 2 реплики по 1 CPU. На насыщающем профиле (0.5 CPU на
|
||||
# реплику) проба готовности сама подходит к таймауту, и «unhealthy» перестаёт
|
||||
# означать «сломан».
|
||||
API_REPLICAS=${API_REPLICAS:-2}
|
||||
API_CPU_LIMIT=${API_CPU_LIMIT:-1.0}
|
||||
API_MEM_LIMIT=${API_MEM_LIMIT:-512M}
|
||||
export API_REPLICAS API_CPU_LIMIT API_MEM_LIMIT
|
||||
|
||||
NO_PROXY_ENV="env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy"
|
||||
NO_PROXY_ENV="$NO_PROXY_ENV NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1"
|
||||
|
||||
mkdir -p "$OUT"
|
||||
rm -f "$OUT/load.json" "$OUT/load.txt"
|
||||
|
||||
compose() {
|
||||
# shellcheck disable=SC2086
|
||||
$COMPOSE_BIN --env-file .env -f compose.yaml "$@"
|
||||
}
|
||||
|
||||
api_containers() {
|
||||
docker ps -q --filter 'label=com.docker.compose.service=api'
|
||||
}
|
||||
|
||||
healthy_replicas() {
|
||||
docker ps -q --filter 'label=com.docker.compose.service=api' --filter health=healthy | wc -l | tr -d ' '
|
||||
}
|
||||
|
||||
lb_container() {
|
||||
docker ps -q --filter 'label=com.docker.compose.service=lb' | head -n 1
|
||||
}
|
||||
|
||||
observe_instances() {
|
||||
tries=${1:-10}
|
||||
attempt=0
|
||||
while [ "$attempt" -lt "$tries" ]; do
|
||||
curl -fsS --noproxy '*' -D - -o /dev/null "$BASE_URL/health/live" 2>/dev/null \
|
||||
| awk 'tolower($1) == "x-instance-id:" { print $2 }'
|
||||
attempt=$((attempt + 1))
|
||||
done | sort -u | wc -l | tr -d ' '
|
||||
}
|
||||
|
||||
wait_for() {
|
||||
# wait_for <expected replicas>: healthy containers and LB-visible replicas
|
||||
want=$1
|
||||
attempt=0
|
||||
while [ "$attempt" -lt 60 ]; do
|
||||
if [ "$(healthy_replicas)" -ge "$want" ] && [ "$(observe_instances 10)" -ge "$want" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
{
|
||||
echo "# Rolling update under load"
|
||||
echo "# generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "# load: tests/load.py duration=${DURATION}s concurrency=${CONCURRENCY} (closed loop)"
|
||||
echo "# steps: delete one replica, recreate it from the freshly built image, wait for health + LB"
|
||||
echo
|
||||
|
||||
compose build api
|
||||
compose up -d --no-deps api
|
||||
|
||||
replicas=$(api_containers | wc -l | tr -d ' ')
|
||||
if ! wait_for "$replicas"; then
|
||||
echo "stand is not ready on the declared profile" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "replicas before: ${replicas}; instances seen through LB: $(observe_instances 20)"
|
||||
|
||||
lb_5xx_before=$(docker logs "$(lb_container)" 2>&1 | grep -c '" 50[0-9] ' || true)
|
||||
|
||||
# Load keeps writing while replicas are replaced one by one. The tolerant
|
||||
# generator counts transitional errors instead of failing on them.
|
||||
# shellcheck disable=SC2086
|
||||
$NO_PROXY_ENV $PYTHON student-tests/rolling_update_load.py --base-url "$BASE_URL" \
|
||||
--duration "$DURATION" --concurrency "$CONCURRENCY" \
|
||||
--output "$OUT/load.json" > "$OUT/load.txt" 2>&1 &
|
||||
load_pid=$!
|
||||
|
||||
step=0
|
||||
for container in $(api_containers); do
|
||||
step=$((step + 1))
|
||||
instance=$(docker inspect --format '{{.Config.Hostname}}' "$container")
|
||||
started=$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
||||
|
||||
docker rm -f "$container" >/dev/null
|
||||
compose up -d --no-deps api >/dev/null
|
||||
|
||||
if ! wait_for "$replicas"; then
|
||||
echo " step ${step}: replacement of ${instance} did not become ready" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf ' step %s: removed %s at %s, %s healthy replicas served again at %s\n' \
|
||||
"$step" "$instance" "$started" "$(healthy_replicas)" "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
done
|
||||
|
||||
wait "$load_pid" || true
|
||||
|
||||
lb_5xx_after=$(docker logs "$(lb_container)" 2>&1 | grep -c '" 50[0-9] ' || true)
|
||||
|
||||
echo
|
||||
echo "load summary (tolerant generator):"
|
||||
cat "$OUT/load.txt"
|
||||
echo
|
||||
echo "LB responses with 5xx during the update: $((lb_5xx_after - lb_5xx_before))"
|
||||
echo
|
||||
echo "API containers after the update:"
|
||||
docker ps --format '{{.Names}} {{.Status}}' --filter 'label=com.docker.compose.service=api'
|
||||
} > "$OUT/rolling-update.txt" 2>&1
|
||||
|
||||
cat "$OUT/rolling-update.txt"
|
||||
printf 'rolling_update.sh: evidence in %s\n' "$OUT"
|
||||
Executable
+72
@@ -0,0 +1,72 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
# Fault-injection hook: stop exactly ONE api replica of the lab3 stand.
|
||||
#
|
||||
# TARGET_INSTANCE_ID=<hostname|container name|short id> scripts/stop-one.sh
|
||||
#
|
||||
# The task value is the instance alias the API reports in X-Instance-Id, i.e.
|
||||
# the container hostname (docker's default = short container id). Container
|
||||
# names of the api service are matched too. The container is only stopped
|
||||
# (docker stop); databases, the load balancer and volumes are left untouched,
|
||||
# and the replica stays down until it is started again explicitly, e.g.
|
||||
# docker compose --env-file .env up -d --no-deps api
|
||||
# No credentials are printed.
|
||||
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
||||
|
||||
PROJECT=${COMPOSE_PROJECT_NAME:-mtusi-messenger-lab3}
|
||||
|
||||
candidates=$(docker ps -q \
|
||||
--filter "label=com.docker.compose.project=${PROJECT}" \
|
||||
--filter "label=com.docker.compose.service=api")
|
||||
|
||||
if [ -z "$candidates" ]; then
|
||||
printf 'stop-one.sh: no api containers of project %s are running\n' "$PROJECT" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Matches the requested alias against every reasonable identifier of a replica:
|
||||
# container hostname (= X-Instance-Id), full/short container id, full container
|
||||
# name (mtusi-messenger-lab3-api-1) and the service-local suffix (api-1).
|
||||
match_replica() {
|
||||
target=$1
|
||||
full_id=$2
|
||||
short_id=$3
|
||||
name=$4
|
||||
hostname=$5
|
||||
suffix=${name#${PROJECT}-}
|
||||
|
||||
[ "$target" = "$hostname" ] && return 0
|
||||
[ "$target" = "$full_id" ] && return 0
|
||||
[ "$target" = "$short_id" ] && return 0
|
||||
[ "$target" = "$name" ] && return 0
|
||||
[ "$target" = "$suffix" ] && return 0
|
||||
return 1
|
||||
}
|
||||
|
||||
matched=""
|
||||
matched_names=""
|
||||
for id in $candidates; do
|
||||
info=$(docker inspect --format '{{.Id}} {{.Name}} {{.Config.Hostname}}' "$id")
|
||||
full_id=$(printf '%s' "$info" | cut -d' ' -f1)
|
||||
name=$(printf '%s' "$info" | cut -d' ' -f2 | sed 's|^/||')
|
||||
hostname=$(printf '%s' "$info" | cut -d' ' -f3)
|
||||
short_id=$(printf '%s' "$full_id" | cut -c1-12)
|
||||
|
||||
if match_replica "$TARGET_INSTANCE_ID" "$full_id" "$short_id" "$name" "$hostname"; then
|
||||
matched="$matched $id"
|
||||
matched_names="$matched_names $name"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$matched" ]; then
|
||||
printf 'stop-one.sh: no api replica matches TARGET_INSTANCE_ID=%s\n' "$TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Shut down cleanly (SIGTERM) but never hang the caller for long.
|
||||
for id in $matched; do
|
||||
docker stop --time 5 "$id" >/dev/null
|
||||
done
|
||||
|
||||
printf 'stop-one.sh: stopped api replica(s):%s\n' "$matched_names"
|
||||
exit 0
|
||||
@@ -1,267 +0,0 @@
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import signal
|
||||
import socket
|
||||
import subprocess
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
import uuid
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
FAST_PATH = """\tif len(history) == 0 || compareKeyset(
|
||||
\t\thistory[len(history)-1].CreatedAt,
|
||||
\t\thistory[len(history)-1].ID,
|
||||
\t\tmessage.CreatedAt,
|
||||
\t\tmessage.ID,
|
||||
\t) < 0 {
|
||||
\t\ts.messagesByChat[message.ChatID] = append(history, message)
|
||||
|
||||
\t\treturn message, nil
|
||||
\t}
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def request(opener, base, method, path, body=None, user=None):
|
||||
data = json.dumps(body, ensure_ascii=False).encode() if body is not None else None
|
||||
headers = {}
|
||||
if data is not None:
|
||||
headers["Content-Type"] = "application/json"
|
||||
if user is not None:
|
||||
headers["X-User-Id"] = user
|
||||
req = urllib.request.Request(base + path, data=data, headers=headers, method=method)
|
||||
with opener.open(req, timeout=10) as response:
|
||||
return json.loads(response.read())
|
||||
|
||||
|
||||
def available_port():
|
||||
with socket.socket() as listener:
|
||||
listener.bind(("127.0.0.1", 0))
|
||||
return listener.getsockname()[1]
|
||||
|
||||
|
||||
def descendants(root_pid):
|
||||
result = subprocess.run(
|
||||
["ps", "-axo", "pid=,ppid=,rss=,command="],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
entries = []
|
||||
for line in result.stdout.splitlines():
|
||||
fields = line.strip().split(None, 3)
|
||||
if len(fields) == 4:
|
||||
try:
|
||||
entries.append((int(fields[0]), int(fields[1]), int(fields[2]), fields[3]))
|
||||
except ValueError:
|
||||
continue
|
||||
children = {root_pid}
|
||||
while True:
|
||||
discovered = children | {pid for pid, ppid, _, _ in entries if ppid in children}
|
||||
if discovered == children:
|
||||
break
|
||||
children = discovered
|
||||
return [entry for entry in entries if entry[0] in children and entry[0] != root_pid]
|
||||
|
||||
|
||||
def server_rss_kib(go_run_pid):
|
||||
servers = [rss for _, _, rss, command in descendants(go_run_pid) if command.rstrip().endswith("/messenger")]
|
||||
if not servers:
|
||||
raise RuntimeError("go run server process was not found")
|
||||
return max(servers)
|
||||
|
||||
|
||||
def wait_ready(process, opener, base):
|
||||
deadline = time.monotonic() + 60
|
||||
while time.monotonic() < deadline:
|
||||
if process.poll() is not None:
|
||||
raise RuntimeError(f"go run exited with code {process.returncode}")
|
||||
try:
|
||||
request(opener, base, "GET", "/health/live")
|
||||
server_rss_kib(process.pid)
|
||||
return
|
||||
except (OSError, RuntimeError):
|
||||
time.sleep(0.1)
|
||||
raise RuntimeError("go run server did not become ready")
|
||||
|
||||
|
||||
def percentile(latencies, fraction):
|
||||
ordered = sorted(latencies)
|
||||
index = max(0, min(len(ordered) - 1, (len(ordered) * int(fraction * 100) + 99) // 100 - 1))
|
||||
return round(ordered[index] * 1000, 3)
|
||||
|
||||
|
||||
def setup(opener, base, history):
|
||||
users = []
|
||||
for _ in range(10):
|
||||
user = request(opener, base, "POST", "/api/v1/users", {
|
||||
"username": "b" + uuid.uuid4().hex[:20],
|
||||
"display_name": "Benchmark",
|
||||
})
|
||||
users.append(user)
|
||||
|
||||
chat = request(opener, base, "POST", "/api/v1/chats", {
|
||||
"title": "Benchmark",
|
||||
"member_ids": [user["id"] for user in users],
|
||||
}, users[0]["id"])
|
||||
|
||||
for index in range(history):
|
||||
request(opener, base, "POST", f"/api/v1/chats/{chat['id']}/messages", {
|
||||
"text": f"history-{index}",
|
||||
}, users[index % len(users)]["id"])
|
||||
|
||||
return chat, users
|
||||
|
||||
|
||||
def launch(mode, port, overlay):
|
||||
command = ["go", "run"]
|
||||
if mode == "baseline":
|
||||
command.extend(["-overlay", str(overlay)])
|
||||
command.append("./cmd/messenger")
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
cwd=ROOT,
|
||||
env={**os.environ, "APP_HOST": "127.0.0.1", "APP_PORT": str(port)},
|
||||
stdout=subprocess.DEVNULL,
|
||||
stderr=subprocess.PIPE,
|
||||
start_new_session=True,
|
||||
)
|
||||
return process, command
|
||||
|
||||
|
||||
def run_case(mode, history, concurrency, requests, overlay):
|
||||
port = available_port()
|
||||
base = f"http://127.0.0.1:{port}"
|
||||
opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))
|
||||
process, command = launch(mode, port, overlay)
|
||||
try:
|
||||
wait_ready(process, opener, base)
|
||||
chat, users = setup(opener, base, history)
|
||||
rss = []
|
||||
stop_sampling = threading.Event()
|
||||
sampling_errors = []
|
||||
|
||||
def sample():
|
||||
while not stop_sampling.is_set():
|
||||
try:
|
||||
rss.append(server_rss_kib(process.pid))
|
||||
except RuntimeError as exc:
|
||||
sampling_errors.append(str(exc))
|
||||
stop_sampling.wait(0.1)
|
||||
|
||||
sampler = threading.Thread(target=sample)
|
||||
sampler.start()
|
||||
warmup = min(100, max(10, requests // 100))
|
||||
|
||||
for index in range(warmup):
|
||||
request(opener, base, "POST", f"/api/v1/chats/{chat['id']}/messages", {
|
||||
"text": f"warmup-{index}",
|
||||
}, users[index % len(users)]["id"])
|
||||
|
||||
started = time.monotonic()
|
||||
|
||||
def worker(worker_id):
|
||||
latencies = []
|
||||
failures = 0
|
||||
worker_requests = requests // concurrency + (1 if worker_id < requests % concurrency else 0)
|
||||
for index in range(worker_requests):
|
||||
request_started = time.perf_counter()
|
||||
try:
|
||||
request(opener, base, "POST", f"/api/v1/chats/{chat['id']}/messages", {
|
||||
"text": f"load-{worker_id}-{index}",
|
||||
}, users[worker_id % len(users)]["id"])
|
||||
latencies.append(time.perf_counter() - request_started)
|
||||
except (OSError, ValueError, urllib.error.HTTPError):
|
||||
failures += 1
|
||||
index += 1
|
||||
return latencies, failures
|
||||
|
||||
try:
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=concurrency) as pool:
|
||||
results = list(pool.map(worker, range(concurrency)))
|
||||
finally:
|
||||
elapsed = time.monotonic() - started
|
||||
stop_sampling.set()
|
||||
sampler.join()
|
||||
|
||||
latencies = [value for values, _ in results for value in values]
|
||||
failures = sum(value for _, value in results)
|
||||
if not latencies or not rss or sampling_errors:
|
||||
raise RuntimeError(f"invalid sample: successes={len(latencies)} rss={len(rss)} errors={sampling_errors}")
|
||||
|
||||
return {
|
||||
"history": history,
|
||||
"concurrency": concurrency,
|
||||
"duration_seconds": round(elapsed, 3),
|
||||
"requested_requests": requests,
|
||||
"warmup_requests": warmup,
|
||||
"successful_requests": len(latencies),
|
||||
"failed_requests": failures,
|
||||
"rps": round(len(latencies) / elapsed, 3),
|
||||
"p50_ms": percentile(latencies, 0.50),
|
||||
"p95_ms": percentile(latencies, 0.95),
|
||||
"p99_ms": percentile(latencies, 0.99),
|
||||
"rss_min_kib": min(rss),
|
||||
"rss_max_kib": max(rss),
|
||||
"rss_delta_kib": max(rss) - min(rss),
|
||||
}, command
|
||||
finally:
|
||||
os.killpg(process.pid, signal.SIGTERM)
|
||||
try:
|
||||
process.wait(timeout=10)
|
||||
except subprocess.TimeoutExpired:
|
||||
os.killpg(process.pid, signal.SIGKILL)
|
||||
process.wait()
|
||||
|
||||
|
||||
def baseline_overlay(directory):
|
||||
source = (ROOT / "internal/storage/memory/message_repository.go").resolve()
|
||||
content = source.read_text()
|
||||
if content.count(FAST_PATH) != 1:
|
||||
raise RuntimeError("expected exactly one optimized append block")
|
||||
replacement = directory / "message_repository_baseline.go"
|
||||
replacement.write_text(content.replace(FAST_PATH, "", 1))
|
||||
overlay = directory / "overlay.json"
|
||||
overlay.write_text(json.dumps({"Replace": {str(source): str(replacement)}}))
|
||||
return overlay
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--mode", choices=("baseline", "optimized"), required=True)
|
||||
parser.add_argument("--requests", type=int, default=10000)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
if args.requests <= 0:
|
||||
parser.error("--requests must be positive")
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="messenger-track1-") as temp_dir:
|
||||
overlay = baseline_overlay(Path(temp_dir))
|
||||
rows = []
|
||||
for history in (1000, 10000, 50000):
|
||||
for concurrency in (1, 4, 16, 32):
|
||||
row, command = run_case(args.mode, history, concurrency, args.requests, overlay)
|
||||
rows.append(row)
|
||||
print(json.dumps(row, ensure_ascii=False), flush=True)
|
||||
result = {
|
||||
"mode": args.mode,
|
||||
"command": command,
|
||||
"go_version": subprocess.check_output(["go", "version"], text=True).strip(),
|
||||
"os_arch": subprocess.check_output(["go", "env", "GOOS", "GOARCH"], text=True).split(),
|
||||
"requests_per_case": args.requests,
|
||||
"rss_source": "ps RSS of go run child executable, KiB; sampled every 100 ms",
|
||||
"rows": rows,
|
||||
}
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(json.dumps(result, ensure_ascii=False, indent=2) + "\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+189
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Сводка трека 1: артефакты `evidence/track1/*` -> таблица и графики.
|
||||
|
||||
Читает `load-<label>.json` (tests/load.py) и `stats-<label>.csv` (docker stats)
|
||||
и печатает метрики профиля: успешный RPS, p50/p95/p99 успешных запросов, доля
|
||||
ошибок, суммарный CPU API, максимум памяти API, CPU PostgreSQL и LB.
|
||||
|
||||
.venv/bin/python scripts/track1_report.py
|
||||
|
||||
Графики (PNG) требуют matplotlib; без него печатается только таблица.
|
||||
"""
|
||||
import argparse
|
||||
import csv
|
||||
import json
|
||||
import re
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
DEFAULT_DIR = ROOT / 'evidence/track1'
|
||||
MEMORY_UNITS = {'B': 1 / 1024 / 1024, 'KiB': 1 / 1024, 'MiB': 1, 'GiB': 1024}
|
||||
|
||||
|
||||
def parse_cpu(value):
|
||||
return float(value.rstrip('%')) if value else 0.0
|
||||
|
||||
|
||||
def parse_memory(value):
|
||||
"""'123.4MiB / 256MiB' -> 123.4 MiB."""
|
||||
match = re.match(r'([\d.]+)\s*([KMG]?i?B)', value.strip())
|
||||
|
||||
if not match:
|
||||
return 0.0
|
||||
|
||||
return float(match.group(1)) * MEMORY_UNITS.get(match.group(2), 1)
|
||||
|
||||
|
||||
def service_of(container):
|
||||
"""mtusi-messenger-lab3-api-12 -> api"""
|
||||
return container.rsplit('-', 1)[0].split('-')[-1] if '-' in container else container
|
||||
|
||||
|
||||
def read_stats(path):
|
||||
"""Профиль -> агрегаты по сервисам.
|
||||
|
||||
Внутри одного timestamp значения всех контейнеров сервиса складываются: две-три
|
||||
реплики — это общий ресурс профиля, а не выборка. Затем CPU усредняется по
|
||||
timestamp'ам, а память берётся пиковой (сумма по репликам).
|
||||
"""
|
||||
samples = defaultdict(lambda: defaultdict(lambda: {'cpu': 0.0, 'mem': 0.0}))
|
||||
|
||||
with path.open() as handle:
|
||||
for row in csv.DictReader(handle):
|
||||
service = service_of(row['container'])
|
||||
bucket = samples[service][row['timestamp']]
|
||||
bucket['cpu'] += parse_cpu(row['cpu_percent'])
|
||||
bucket['mem'] += parse_memory(row['mem_usage'])
|
||||
|
||||
cpu = {service: [values['cpu'] for values in by_timestamp.values()] for service, by_timestamp in samples.items()}
|
||||
memory = {service: max(values['mem'] for values in by_timestamp.values()) for service, by_timestamp in samples.items()}
|
||||
|
||||
return cpu, memory
|
||||
|
||||
|
||||
def aggregate(label, directory):
|
||||
load_path = directory / f'load-{label}.json'
|
||||
stats_path = directory / f'stats-{label}.csv'
|
||||
profile_path = directory / f'profile-{label}.json'
|
||||
|
||||
if not load_path.is_file() or not stats_path.is_file():
|
||||
return None
|
||||
|
||||
report = json.loads(load_path.read_text())
|
||||
profile = json.loads(profile_path.read_text()) if profile_path.is_file() else {}
|
||||
cpu, memory = read_stats(stats_path)
|
||||
|
||||
api_cpu = cpu.get('api', [])
|
||||
api_memory = memory.get('api', 0.0)
|
||||
|
||||
def average(values):
|
||||
return round(sum(values) / len(values), 2) if values else None
|
||||
|
||||
sampled = max((len(values) for values in cpu.values()), default=0)
|
||||
|
||||
return {
|
||||
'label': label,
|
||||
'replicas': profile.get('replicas', 0),
|
||||
'total_cpu': profile.get('total_cpu'),
|
||||
'cpu_per_replica': round(profile['total_cpu'] / max(1, profile['replicas']), 2)
|
||||
if profile.get('total_cpu') else None,
|
||||
'successful_rps': report['successful_rps'],
|
||||
'p50_ms': report['successful_latency_ms']['p50'],
|
||||
'p95_ms': report['successful_latency_ms']['p95'],
|
||||
'p99_ms': report['successful_latency_ms']['p99'],
|
||||
'errors': report['failed_requests'],
|
||||
'error_ratio': report['error_ratio'],
|
||||
'api_cpu_sum': average(api_cpu),
|
||||
'api_cpu_per_replica': round(average(api_cpu) / max(1, profile.get('replicas') or 1), 2)
|
||||
if api_cpu else None,
|
||||
'api_memory_max_sum_mib': round(api_memory, 1) if api_memory else None,
|
||||
'postgres_cpu': average(cpu.get('postgres', [])),
|
||||
'lb_cpu': average(cpu.get('lb', [])),
|
||||
'stats_samples': sampled,
|
||||
'load_seconds': report['elapsed_seconds'],
|
||||
}
|
||||
|
||||
|
||||
def markdown(rows):
|
||||
header = (
|
||||
'| профиль | реплик | бюджет CPU | CPU/реплика | успешный RPS | p50 мс | p95 мс | p99 мс | ошибки | '
|
||||
'API CPU (сумма) | API RAM max (сумма, MiB) | PG CPU | LB CPU |\n'
|
||||
'| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |\n'
|
||||
)
|
||||
|
||||
lines = [
|
||||
'| {label} | {replicas} | {total_cpu} | {cpu_per_replica} | {successful_rps} | {p50_ms} | {p95_ms} | {p99_ms} | '
|
||||
'{errors} | {api_cpu_sum} | {api_memory_max_sum_mib} | {postgres_cpu} | {lb_cpu} |'.format(**row)
|
||||
for row in rows
|
||||
]
|
||||
|
||||
return header + '\n'.join(lines) + '\n'
|
||||
|
||||
|
||||
def plot(rows, directory):
|
||||
try:
|
||||
import matplotlib
|
||||
matplotlib.use('Agg')
|
||||
import matplotlib.pyplot as plt
|
||||
except ImportError:
|
||||
print('matplotlib недоступен: графики не построены (pip install matplotlib)')
|
||||
return
|
||||
|
||||
series = {
|
||||
'fixed-budget': [row for row in rows if row['label'].startswith('r') and row['total_cpu']],
|
||||
'growth': [row for row in rows if row['label'].startswith('g') and row['total_cpu']],
|
||||
}
|
||||
|
||||
for name, points in series.items():
|
||||
if len(points) < 2:
|
||||
continue
|
||||
|
||||
axis = 'replicas' if name == 'fixed-budget' else 'total_cpu'
|
||||
points = sorted(points, key=lambda row: row[axis])
|
||||
ticks = [str(row[axis]) for row in points]
|
||||
|
||||
figure, (left, right) = plt.subplots(1, 2, figsize=(10, 4))
|
||||
|
||||
left.plot(ticks, [row['successful_rps'] for row in points], marker='o')
|
||||
left.set_xlabel('API реплик' if axis == 'replicas' else 'суммарный бюджет CPU')
|
||||
left.set_ylabel('успешный RPS')
|
||||
left.grid(True)
|
||||
left.set_title('Пропускная способность')
|
||||
|
||||
right.plot(ticks, [row['p95_ms'] for row in points], marker='o', color='tab:red')
|
||||
right.set_xlabel('API реплик' if axis == 'replicas' else 'суммарный бюджет CPU')
|
||||
right.set_ylabel('p95 успешных, мс')
|
||||
right.grid(True)
|
||||
right.set_title('Задержка p95')
|
||||
|
||||
figure.suptitle(('Фиксированный бюджет' if name == 'fixed-budget' else 'Рост ресурсов') + ' (трек 1)')
|
||||
figure.tight_layout()
|
||||
target = directory / ('scaling-' + name + '.png')
|
||||
figure.savefig(target, dpi=120)
|
||||
print('график:', target)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Сводка трека 1 по артефактам стенда')
|
||||
parser.add_argument('--dir', type=Path, default=DEFAULT_DIR)
|
||||
args = parser.parse_args()
|
||||
|
||||
labels = sorted(
|
||||
path.stem.removeprefix('load-') for path in args.dir.glob('load-*.json')
|
||||
)
|
||||
|
||||
rows = [row for row in (aggregate(label, args.dir) for label in labels) if row]
|
||||
|
||||
if not rows:
|
||||
raise SystemExit('нет артефактов в ' + str(args.dir))
|
||||
|
||||
table = markdown(rows)
|
||||
print(table)
|
||||
(args.dir / 'summary.md').write_text('# Трек 1: цена масштабирования\n\n' + table)
|
||||
|
||||
plot(rows, args.dir)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Executable
+140
@@ -0,0 +1,140 @@
|
||||
#!/bin/sh
|
||||
# Track 1: the price of scaling. Runs one and the same closed-loop write profile
|
||||
# against 1/2/4 API replicas while the TOTAL API budget stays fixed, and records
|
||||
# raw metrics. The stand has to be built already (make up).
|
||||
#
|
||||
# scripts/track1_scaling.sh
|
||||
# REPLICAS="2 4" DURATION=30 CONCURRENCY=8 scripts/track1_scaling.sh
|
||||
#
|
||||
# Artifacts: evidence/track1/{load,stats}-r<N>.json|csv plus summary.txt
|
||||
set -eu
|
||||
|
||||
ROOT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
COMPOSE_BIN=${COMPOSE_BIN:-docker compose}
|
||||
PYTHON=${PYTHON:-python3}
|
||||
REPLICAS=${REPLICAS:-"1 2 4"}
|
||||
TOTAL_CPU=${TOTAL_CPU:-2.0}
|
||||
TOTAL_MEM_MB=${TOTAL_MEM_MB:-1024}
|
||||
DURATION=${DURATION:-60}
|
||||
CONCURRENCY=${CONCURRENCY:-16}
|
||||
WARMUP=${WARMUP:-15}
|
||||
BASE_URL=${BASE_URL:-http://localhost:8080}
|
||||
LABEL=${LABEL:-}
|
||||
OUT=evidence/track1
|
||||
|
||||
# The author's shell exports HTTP(S)_PROXY, which breaks localhost clients.
|
||||
NO_PROXY_ENV="env -u HTTP_PROXY -u HTTPS_PROXY -u ALL_PROXY -u http_proxy -u https_proxy -u all_proxy"
|
||||
NO_PROXY_ENV="$NO_PROXY_ENV NO_PROXY=localhost,127.0.0.1,::1 no_proxy=localhost,127.0.0.1,::1"
|
||||
|
||||
mkdir -p "$OUT"
|
||||
|
||||
compose() {
|
||||
# shellcheck disable=SC2086
|
||||
$COMPOSE_BIN --env-file .env -f compose.yaml "$@"
|
||||
}
|
||||
|
||||
wait_ready() {
|
||||
attempt=0
|
||||
while [ "$attempt" -lt 90 ]; do
|
||||
if curl -fsS --noproxy '*' -o /dev/null "$BASE_URL/health/ready"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
attempt=$((attempt + 1))
|
||||
sleep 1
|
||||
done
|
||||
|
||||
printf 'track1_scaling.sh: %s/health/ready did not become ready\n' "$BASE_URL" >&2
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
per_replica_cpu() {
|
||||
awk "BEGIN{printf \"%.2f\", $TOTAL_CPU/$1}"
|
||||
}
|
||||
|
||||
per_replica_mem() {
|
||||
awk "BEGIN{printf \"%.0fM\", $TOTAL_MEM_MB/$1}"
|
||||
}
|
||||
|
||||
SUMMARY="$OUT/summary.txt"
|
||||
|
||||
if [ ! -f "$SUMMARY" ]; then
|
||||
{
|
||||
echo "# Track 1: the price of scaling"
|
||||
echo "# generated: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
||||
echo "# host: $(uname -sm)"
|
||||
echo "# cpu: $(sysctl -n machdep.cpu.brand_string 2>/dev/null || printf unknown)"
|
||||
echo "# ram bytes: $(sysctl -n hw.memsize 2>/dev/null || printf unknown)"
|
||||
echo "# load: tests/load.py closed loop; postgres/redis/lb limits are fixed in compose.yaml"
|
||||
echo "# each profile line below records the budget it was run with"
|
||||
docker version --format 'docker engine {{.Server.Version}}'
|
||||
# shellcheck disable=SC2086
|
||||
$COMPOSE_BIN version
|
||||
echo
|
||||
} > "$SUMMARY"
|
||||
fi
|
||||
|
||||
{
|
||||
echo "=== invocation $(date -u +%Y-%m-%dT%H:%M:%SZ): REPLICAS=\"$REPLICAS\" TOTAL_CPU=$TOTAL_CPU TOTAL_MEM_MB=$TOTAL_MEM_MB DURATION=$DURATION CONCURRENCY=$CONCURRENCY WARMUP=$WARMUP ==="
|
||||
echo
|
||||
} >> "$SUMMARY"
|
||||
|
||||
for replicas in $REPLICAS; do
|
||||
cpu=$(per_replica_cpu "$replicas")
|
||||
mem=$(per_replica_mem "$replicas")
|
||||
label=${LABEL:-r$replicas}
|
||||
|
||||
printf '=== profile label=%s replicas=%s cpu=%s mem=%s ===\n' "$label" "$replicas" "$cpu" "$mem" | tee -a "$SUMMARY"
|
||||
|
||||
API_REPLICAS="$replicas" API_CPU_LIMIT="$cpu" API_MEM_LIMIT="$mem" compose up -d --no-deps api
|
||||
wait_ready
|
||||
|
||||
# Warm up caches, connection pools and the JIT-free query plans; the warmup
|
||||
# data stays in the table, so every profile grows the same history shape.
|
||||
# shellcheck disable=SC2086
|
||||
$NO_PROXY_ENV $PYTHON tests/load.py --base-url "$BASE_URL" \
|
||||
--duration "$WARMUP" --concurrency "$CONCURRENCY" >/dev/null
|
||||
|
||||
STATS="$OUT/stats-$label.csv"
|
||||
printf 'timestamp,container,cpu_percent,mem_usage\n' > "$STATS"
|
||||
|
||||
PROFILE="$OUT/profile-$label.json"
|
||||
printf '{"label":"%s","replicas":%s,"total_cpu":%s,"total_mem_mb":%s,"duration":%s,"concurrency":%s,"warmup":%s}\n' \
|
||||
"$label" "$replicas" "$TOTAL_CPU" "$TOTAL_MEM_MB" "$DURATION" "$CONCURRENCY" "$WARMUP" > "$PROFILE"
|
||||
|
||||
(
|
||||
while :; do
|
||||
docker stats --no-stream \
|
||||
--format '{{.Name}},{{.CPUPerc}},{{.MemUsage}}' \
|
||||
| sed "s|^|$(date -u +%Y-%m-%dT%H:%M:%SZ),|" >> "$STATS"
|
||||
sleep 1
|
||||
done
|
||||
) &
|
||||
|
||||
sampler=$!
|
||||
trap 'kill "$sampler" 2>/dev/null || true' EXIT INT TERM
|
||||
|
||||
# shellcheck disable=SC2086
|
||||
$NO_PROXY_ENV $PYTHON tests/load.py --base-url "$BASE_URL" \
|
||||
--duration "$DURATION" --concurrency "$CONCURRENCY" \
|
||||
--output "$OUT/load-$label.json" | tee -a "$SUMMARY"
|
||||
|
||||
kill "$sampler" 2>/dev/null || true
|
||||
wait "$sampler" 2>/dev/null || true
|
||||
trap - EXIT INT TERM
|
||||
|
||||
# Shared-dependency view right after the run: connections, pool pressure and
|
||||
# how much history the profile wrote into.
|
||||
compose exec -T postgres psql -U "${POSTGRES_USER:-messenger}" -d "${POSTGRES_DB:-messenger}" -Atc \
|
||||
"SELECT 'postgres_connections=' || count(*) FROM pg_stat_activity;
|
||||
SELECT 'postgres_max_connections=' || current_setting('max_connections');
|
||||
SELECT 'messages_rows=' || count(*) FROM messages;
|
||||
SELECT 'idempotency_rows=' || count(*) FROM message_idempotency;" | tee -a "$SUMMARY"
|
||||
|
||||
printf '\n' >> "$SUMMARY"
|
||||
done
|
||||
|
||||
printf 'track1_scaling.sh: artifacts in %s\n' "$OUT"
|
||||
Executable
+144
@@ -0,0 +1,144 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Параллельная проверка общей идемпотентности отправки сообщения (lab3+).
|
||||
|
||||
Публичный smoke проверяет только последовательный повтор. Здесь один и тот же
|
||||
Idempotency-Key отправляется одновременно несколькими потоками через LB, то есть
|
||||
запросы попадают на разные API-реплики: ровно одно сообщение должно быть создано,
|
||||
а повтор с другим payload обязан получить 409.
|
||||
|
||||
Запуск (стенд уже поднят, LB на 8080):
|
||||
python3 student-tests/idempotency_parallel.py --base-url http://localhost:8080
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
import uuid
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
|
||||
from client import Client, LAB, Failure, arguments, check, run # noqa: E402
|
||||
|
||||
WORKERS = 12
|
||||
|
||||
|
||||
def messages_path(chat):
|
||||
return '/api/v1/chats/' + chat['id'] + '/messages'
|
||||
|
||||
|
||||
def history(client, actor, chat):
|
||||
page = client.call('GET', messages_path(chat) + '?limit=100', actor=actor, schema='MessagePage')['json']
|
||||
return page['items']
|
||||
|
||||
|
||||
def replay_confirmed(client, actor, chat, workers=WORKERS):
|
||||
"""Один payload, один ключ, одновременные запросы через LB."""
|
||||
key = uuid.uuid4().hex
|
||||
text = 'Параллельный повтор ' + key
|
||||
|
||||
with ThreadPoolExecutor(max_workers=workers) as pool:
|
||||
responses = list(pool.map(lambda _: client.message(actor, chat, text, key=key), range(workers)))
|
||||
|
||||
ids = {response['json']['id'] for response in responses}
|
||||
check(len(ids) == 1, 'параллельные повторы вернули разные сообщения: ' + str(len(ids)))
|
||||
instances = {response['headers']['X-Instance-Id'] for response in responses}
|
||||
check(len(instances) >= 2, 'запросы не разошлись по репликам: ' + str(sorted(instances)))
|
||||
|
||||
stored = [message for message in history(client, actor, chat) if message['text'] == text]
|
||||
check(len(stored) == 1, 'параллельный повтор создал ' + str(len(stored)) + ' сообщений')
|
||||
check(stored[0]['id'] == next(iter(ids)), 'в истории не то сообщение, что вернул POST')
|
||||
|
||||
return {'workers': workers, 'instances': sorted(instances), 'message_id': stored[0]['id']}
|
||||
|
||||
|
||||
def conflicting_payloads(client, actor, chat, workers=WORKERS):
|
||||
"""Один ключ, разные payload одновременно: один 201, остальные 409."""
|
||||
key = uuid.uuid4().hex
|
||||
texts = ['Конфликт ' + key + ' #' + str(index) for index in range(workers)]
|
||||
|
||||
def post(text):
|
||||
return client.call(
|
||||
'POST',
|
||||
messages_path(chat),
|
||||
(201, 409),
|
||||
actor=actor,
|
||||
body={'text': text},
|
||||
headers={'Idempotency-Key': key},
|
||||
schema='Message',
|
||||
)
|
||||
|
||||
with ThreadPoolExecutor(max_workers=workers) as pool:
|
||||
responses = list(pool.map(post, texts))
|
||||
|
||||
accepted = [response for response in responses if response['status'] == 201]
|
||||
conflicts = [response for response in responses if response['status'] == 409]
|
||||
check(len(accepted) == 1, 'принято запросов с одним ключом: ' + str(len(accepted)))
|
||||
check(len(conflicts) == workers - 1, 'конфликтов: ' + str(len(conflicts)))
|
||||
|
||||
stored = [message for message in history(client, actor, chat) if message['id'] == accepted[0]['json']['id']]
|
||||
check(len(stored) == 1, 'конфликтующий ключ создал не одно сообщение')
|
||||
|
||||
return {'workers': workers, 'accepted': len(accepted), 'conflicts': len(conflicts)}
|
||||
|
||||
|
||||
def replayed_body_is_stable(client, actor, chat):
|
||||
"""Повтор того же смысла, но другого JSON, возвращает исходное сообщение."""
|
||||
key = uuid.uuid4().hex
|
||||
text = 'Форматирование ' + key
|
||||
first = client.message(actor, chat, text, key=key)
|
||||
|
||||
# Тот же payload, другой порядок пробелов в JSON: контракт требует тот же 201
|
||||
# и то же сообщение.
|
||||
spaced = json.dumps({'text': text}, ensure_ascii=False).replace('":', '" :')
|
||||
replay = client.call(
|
||||
'POST',
|
||||
messages_path(chat),
|
||||
201,
|
||||
actor=actor,
|
||||
raw=spaced.encode('utf-8'),
|
||||
headers={'Idempotency-Key': key, 'Content-Type': 'application/json'},
|
||||
schema='Message',
|
||||
)
|
||||
check(replay['json'] == first['json'], 'повтор вернул другое сообщение')
|
||||
|
||||
return {'message_id': first['json']['id']}
|
||||
|
||||
|
||||
def key_is_required(client, actor, chat):
|
||||
client.call('POST', messages_path(chat), 400, actor=actor, body={'text': 'без ключа'}, schema='Error')
|
||||
|
||||
result = client.call(
|
||||
'POST',
|
||||
messages_path(chat),
|
||||
400,
|
||||
actor=actor,
|
||||
body={'text': 'кривой ключ'},
|
||||
headers={'Idempotency-Key': 'bad key!'},
|
||||
schema='Error',
|
||||
)
|
||||
check(result['status'] == 400, 'некорректный ключ обязан быть 400')
|
||||
|
||||
return {'status': result['status']}
|
||||
|
||||
|
||||
def main():
|
||||
args = arguments('Параллельная идемпотентность сообщений (lab3+); создаёт синтетические данные')
|
||||
check(LAB >= 3, 'параллельная идемпотентность требует lab3+')
|
||||
|
||||
client = Client(args.base_url, args.ca_file)
|
||||
alice, _, _, chat = client.bootstrap()
|
||||
|
||||
summary = {
|
||||
'replay': replay_confirmed(client, alice, chat),
|
||||
'conflict': conflicting_payloads(client, alice, chat),
|
||||
'stable_body': replayed_body_is_stable(client, alice, chat),
|
||||
'key_required': key_is_required(client, alice, chat),
|
||||
}
|
||||
|
||||
print(json.dumps(summary, ensure_ascii=False))
|
||||
print('PASS: параллельный повтор с одним Idempotency-Key создаёт ровно одно сообщение')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
Executable
+194
@@ -0,0 +1,194 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Последовательная остановка каждой API-реплики с измерениями (lab3).
|
||||
|
||||
Отличие от публичного `make test-failover`: здесь реплика выбирается явно
|
||||
(сначала первая, затем вторая), печатается реально остановленный контейнер и
|
||||
собираются метрики: успешные записи, ошибки, время восстановления записи через
|
||||
LB, набор реплик после отказа и отсутствие дублей при повторе одного ключа.
|
||||
|
||||
Запуск (стенд поднят, LB на 8080, hooks в scripts/):
|
||||
python3 student-tests/replica_failover.py --action-script scripts/stop-one.sh
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import uuid
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
from urllib.parse import quote
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
|
||||
from client import Client, LAB, Failure, arguments, check, run # noqa: E402
|
||||
from tests_helpers import compose, containers_by_hostname, messages_path # noqa: E402
|
||||
|
||||
WINDOW_SECONDS = 15.0
|
||||
RECOVERY_DEADLINE_SECONDS = 10.0
|
||||
STOP_DELAY_SECONDS = 0.5
|
||||
|
||||
|
||||
def observed_instances(client, actor, tries=40):
|
||||
seen = {}
|
||||
|
||||
for _ in range(tries):
|
||||
response = client.call('GET', '/api/v1/users/me', actor=actor, schema='User')
|
||||
instance = response['headers']['X-Instance-Id']
|
||||
seen[instance] = seen.get(instance, 0) + 1
|
||||
|
||||
return seen
|
||||
|
||||
|
||||
def stop_replica(script, instance):
|
||||
started = time.monotonic()
|
||||
env = dict(os.environ, TARGET_INSTANCE_ID=instance)
|
||||
proc = subprocess.run([str(script)], env=env, capture_output=True, text=True)
|
||||
|
||||
return {
|
||||
'returncode': proc.returncode,
|
||||
'seconds': round(time.monotonic() - started, 3),
|
||||
'stdout': proc.stdout.strip(),
|
||||
'stderr': proc.stderr.strip(),
|
||||
}
|
||||
|
||||
|
||||
def measure_outage(client, actor, chat, target, script):
|
||||
"""Пишет сообщения сквозь LB, пока hook останавливает выбранную реплику."""
|
||||
hook = ThreadPoolExecutor(max_workers=1)
|
||||
stop_started = time.monotonic()
|
||||
hook_future = hook.submit(lambda: (time.sleep(STOP_DELAY_SECONDS), stop_replica(script, target))[1])
|
||||
|
||||
successes, failures, uncertain = 0, 0, 0
|
||||
instances_after = []
|
||||
first_recovery = None
|
||||
key, text = None, None
|
||||
stop_finished = None
|
||||
|
||||
try:
|
||||
while time.monotonic() - stop_started < WINDOW_SECONDS:
|
||||
if key is None:
|
||||
key = uuid.uuid4().hex
|
||||
text = 'Отказ ' + target + ' ' + key
|
||||
|
||||
try:
|
||||
response = client.message(actor, chat, text, key=key)
|
||||
except Failure:
|
||||
failures += 1
|
||||
uncertain += 1
|
||||
continue
|
||||
|
||||
successes += 1
|
||||
instances_after.append(response['headers']['X-Instance-Id'])
|
||||
key, text = None, None
|
||||
|
||||
if hook_future.done() and stop_finished is None:
|
||||
stop_finished = time.monotonic() - stop_started
|
||||
first_recovery = first_recovery or round(stop_finished, 3)
|
||||
|
||||
time.sleep(0.1)
|
||||
finally:
|
||||
stopped = hook_future.result()
|
||||
|
||||
if first_recovery is None:
|
||||
first_recovery = round(time.monotonic() - stop_started, 3)
|
||||
|
||||
return {
|
||||
'stopped_container': stopped['stdout'],
|
||||
'hook_returncode': stopped['returncode'],
|
||||
'hook_seconds': stopped['seconds'],
|
||||
'hook_error': stopped['stderr'],
|
||||
'successful_writes': successes,
|
||||
'failed_attempts': failures,
|
||||
'uncertain_retries': uncertain,
|
||||
'first_recovery_seconds': first_recovery,
|
||||
'instances_after_recovery': sorted(set(instances_after[-5:])),
|
||||
}
|
||||
|
||||
|
||||
def all_messages(client, actor, chat, limit=2000):
|
||||
"""Вся история чата с keyset-пагинацией (проверка дублей не должна зависеть от одной страницы)."""
|
||||
items = []
|
||||
cursor = None
|
||||
|
||||
while True:
|
||||
query = messages_path(chat) + '?limit=100'
|
||||
if cursor:
|
||||
query += '&cursor=' + quote(cursor, safe='')
|
||||
|
||||
page = client.call('GET', query, actor=actor, schema='MessagePage')['json']
|
||||
items.extend(page['items'])
|
||||
cursor = page['next_cursor']
|
||||
|
||||
if not cursor:
|
||||
return items
|
||||
|
||||
check(len(items) <= limit, 'история больше защитного предела проверки')
|
||||
|
||||
|
||||
def ensure_no_duplicates(client, actor, chat):
|
||||
items = all_messages(client, actor, chat)
|
||||
texts = [message['text'] for message in items]
|
||||
ids = [message['id'] for message in items]
|
||||
check(len(texts) == len(set(texts)), 'повтор с тем же ключом создал дубль')
|
||||
check(len(ids) == len(set(ids)), 'дубли ID в истории')
|
||||
|
||||
return len(items)
|
||||
|
||||
|
||||
def restore(instance, timeout=90):
|
||||
started = time.monotonic()
|
||||
compose('up', '-d', '--no-deps', 'api')
|
||||
|
||||
deadline = time.monotonic() + timeout
|
||||
while time.monotonic() < deadline:
|
||||
hosts = containers_by_hostname()
|
||||
if instance in hosts:
|
||||
return {'seconds': round(time.monotonic() - started, 3), 'instances': sorted(hosts)}
|
||||
|
||||
time.sleep(1)
|
||||
|
||||
raise Failure('реплика ' + instance + ' не вернулась в строй')
|
||||
|
||||
|
||||
def main():
|
||||
def configure(parser):
|
||||
parser.add_argument('--action-script', required=True, help='stop-one hook, executable, authored by student')
|
||||
|
||||
args = arguments('Последовательная остановка реплик с метриками (lab3)', configure)
|
||||
check(LAB >= 3, 'отказ API-реплики требует lab3+')
|
||||
|
||||
script = Path(args.action_script).expanduser().resolve()
|
||||
check(script.is_file() and os.access(script, os.X_OK), 'hook должен существовать и быть исполняемым')
|
||||
|
||||
client = Client(args.base_url, args.ca_file)
|
||||
alice, _, _, chat = client.bootstrap()
|
||||
|
||||
observed = observed_instances(client, alice)
|
||||
check(len(observed) >= 2, 'через LB видно меньше двух реплик: ' + str(sorted(observed)))
|
||||
|
||||
report = {'before': {'instances': sorted(observed)}, 'replicas': []}
|
||||
|
||||
for instance in sorted(observed):
|
||||
result = measure_outage(client, alice, chat, instance, script)
|
||||
check(result['hook_returncode'] == 0, 'hook завершился неуспешно: ' + result['hook_error'])
|
||||
check(
|
||||
result['first_recovery_seconds'] <= RECOVERY_DEADLINE_SECONDS,
|
||||
'запись не восстановилась за ' + str(RECOVERY_DEADLINE_SECONDS) + ' c',
|
||||
)
|
||||
check(result['successful_writes'] >= 5, 'слишком мало подтверждённых записей после отказа')
|
||||
check(instance not in result['instances_after_recovery'], 'остановленная реплика продолжает обслуживать')
|
||||
result['messages_in_history'] = ensure_no_duplicates(client, alice, chat)
|
||||
|
||||
restored = restore(instance)
|
||||
result['restored_seconds'] = restored['seconds']
|
||||
result['instances_restored'] = restored['instances']
|
||||
|
||||
report['replicas'].append({'stopped': instance, **result})
|
||||
|
||||
print(json.dumps(report, ensure_ascii=False, indent=2))
|
||||
print('PASS: каждая реплика остановлена по очереди; записи продолжились, дублей и потерь нет')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
Executable
+139
@@ -0,0 +1,139 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Толерантный генератор записи для сценариев отказа (lab3).
|
||||
|
||||
Публичный `tests/load.py` не переживает разрыв соединения во время удаления
|
||||
реплики: он падает на уровне http.client. Этот генератор создан для измерений
|
||||
во время rolling update и отказов: он считает успешные запросы, ошибки по видам
|
||||
и увиденные реплики, а не падает на обрыве.
|
||||
|
||||
python3 student-tests/rolling_update_load.py --duration 60 --concurrency 16 --output evidence/rolling-update/load.json
|
||||
"""
|
||||
import json
|
||||
import math
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import uuid
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'tests'))
|
||||
|
||||
from client import Client, LAB, arguments, check, run # noqa: E402
|
||||
|
||||
|
||||
def classify(error):
|
||||
name = type(error).__name__
|
||||
message = str(error)
|
||||
|
||||
if name == 'Failure':
|
||||
# client.call сообщает о проблемах соединения как Failure с этим текстом,
|
||||
# отделяя их от HTTP-статусов, которые тоже приходят как Failure.
|
||||
if 'connection/TLS failure' in message:
|
||||
return 'connection_broken'
|
||||
|
||||
return 'http_error'
|
||||
if name in ('RemoteDisconnected', 'BadStatusLine', 'IncompleteRead', 'ConnectionResetError'):
|
||||
return 'connection_broken'
|
||||
if name in ('TimeoutError', 'socket.timeout'):
|
||||
return 'timeout'
|
||||
|
||||
return name
|
||||
|
||||
|
||||
def main():
|
||||
def configure(parser):
|
||||
parser.add_argument('--duration', type=float, default=30)
|
||||
parser.add_argument('--concurrency', type=int, default=8)
|
||||
parser.add_argument('--output', default=None)
|
||||
|
||||
args = arguments('Запись сообщений сквозь LB с учётом ошибок (lab3)', configure)
|
||||
check(LAB >= 3, 'сценарий требует lab3+')
|
||||
check(1 <= args.duration <= 3600, 'duration должен быть 1..3600')
|
||||
check(1 <= args.concurrency <= 128, 'concurrency должен быть 1..128')
|
||||
|
||||
bootstrap = Client(args.base_url, args.ca_file)
|
||||
alice, _, _, chat = bootstrap.bootstrap()
|
||||
|
||||
barrier = threading.Barrier(args.concurrency)
|
||||
lock = threading.Lock()
|
||||
latencies = []
|
||||
errors = {}
|
||||
instances = {}
|
||||
|
||||
def worker(worker_id):
|
||||
client = Client(args.base_url, args.ca_file, timeout=5)
|
||||
local_latencies = []
|
||||
local_errors = {}
|
||||
local_instances = {}
|
||||
barrier.wait()
|
||||
|
||||
deadline = time.monotonic() + args.duration
|
||||
index = 0
|
||||
|
||||
while time.monotonic() < deadline:
|
||||
started = time.monotonic()
|
||||
|
||||
try:
|
||||
response = client.message(alice, chat, 'rolling-%s-%s' % (worker_id, index), key=uuid.uuid4().hex)
|
||||
except Exception as error: # noqa: BLE001 - протокол и сеть дают разные типы
|
||||
category = classify(error)
|
||||
local_errors[category] = local_errors.get(category, 0) + 1
|
||||
else:
|
||||
local_latencies.append(time.monotonic() - started)
|
||||
instance = response['headers']['X-Instance-Id']
|
||||
local_instances[instance] = local_instances.get(instance, 0) + 1
|
||||
|
||||
index += 1
|
||||
|
||||
with lock:
|
||||
latencies.extend(local_latencies)
|
||||
|
||||
for category, count in local_errors.items():
|
||||
errors[category] = errors.get(category, 0) + count
|
||||
|
||||
for instance, count in local_instances.items():
|
||||
instances[instance] = instances.get(instance, 0) + count
|
||||
|
||||
started = time.monotonic()
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.concurrency) as pool:
|
||||
list(pool.map(worker, range(args.concurrency)))
|
||||
|
||||
elapsed = time.monotonic() - started
|
||||
ordered = sorted(latencies)
|
||||
|
||||
def percentile(value):
|
||||
return round(1000 * ordered[max(0, math.ceil(value * len(ordered)) - 1)], 3) if ordered else None
|
||||
|
||||
failed = sum(errors.values())
|
||||
|
||||
report = {
|
||||
'lab': LAB,
|
||||
'workload': 'closed-loop POST messages; failures counted, not raised',
|
||||
'requested_duration_seconds': args.duration,
|
||||
'elapsed_seconds': round(elapsed, 3),
|
||||
'concurrency': args.concurrency,
|
||||
'successful_requests': len(ordered),
|
||||
'failed_requests': failed,
|
||||
'error_ratio': round(failed / (failed + len(ordered)), 6) if (failed + len(ordered)) else None,
|
||||
'errors_by_kind': errors,
|
||||
'successful_rps': round(len(ordered) / elapsed, 3),
|
||||
'successful_latency_ms': {'p50': percentile(.50), 'p95': percentile(.95), 'p99': percentile(.99)},
|
||||
'instances': instances,
|
||||
'note': 'Percentiles cover successful writes only; transitional errors are expected during a rolling update.',
|
||||
}
|
||||
|
||||
text = json.dumps(report, ensure_ascii=False, indent=2)
|
||||
print(text)
|
||||
|
||||
if args.output:
|
||||
destination = Path(args.output)
|
||||
destination.parent.mkdir(parents=True, exist_ok=True)
|
||||
destination.write_text(text + '\n')
|
||||
|
||||
check(bool(ordered), 'не было ни одной успешной записи')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run(main)
|
||||
@@ -0,0 +1,43 @@
|
||||
"""Обвязки для собственных проверок ЛР3: docker compose и карта реплик.
|
||||
|
||||
Собственные тесты лежат в student-tests/ (CONTRIBUTING.md). X-Instance-Id равен
|
||||
hostname контейнера, поэтому по нему можно найти реально обслуживший контейнер.
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
def compose(*args, check=True):
|
||||
command = [*os.environ.get('COMPOSE_BIN', 'docker compose').split(), '--env-file', '.env', '-f', 'compose.yaml', *args]
|
||||
|
||||
return subprocess.run(command, cwd=ROOT, capture_output=True, text=True, check=check)
|
||||
|
||||
|
||||
def containers_by_hostname(service='api'):
|
||||
"""{hostname: {id, name, status}} для контейнеров сервиса."""
|
||||
listed = subprocess.run(
|
||||
['docker', 'ps', '-q', '--filter', 'label=com.docker.compose.service=' + service],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
).stdout.split()
|
||||
|
||||
result = {}
|
||||
for container in listed:
|
||||
info = subprocess.run(
|
||||
['docker', 'inspect', '--format', '{{.Config.Hostname}} {{.Name}} {{.State.Status}}', container],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
).stdout.split()
|
||||
|
||||
result[info[0]] = {'id': container[:12], 'name': info[1].lstrip('/'), 'status': info[2]}
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def messages_path(chat):
|
||||
return '/api/v1/chats/' + chat['id'] + '/messages'
|
||||
Reference in New Issue
Block a user