Compare commits
36
Commits
@@ -1,5 +1,7 @@
|
||||
.git
|
||||
.gitignore
|
||||
.github
|
||||
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
@@ -13,8 +15,28 @@ backups
|
||||
*.p12
|
||||
*.pfx
|
||||
*.jks
|
||||
|
||||
.venv
|
||||
__pycache__
|
||||
node_modules
|
||||
|
||||
evidence
|
||||
.DS_Store
|
||||
|
||||
tests
|
||||
my-tests
|
||||
scripts
|
||||
examples
|
||||
contracts
|
||||
README.md
|
||||
COURSE.md
|
||||
CONTRIBUTING.md
|
||||
MAINTAINERS.md
|
||||
REPORT.md
|
||||
|
||||
Makefile
|
||||
requirements-dev.txt
|
||||
Dockerfile.example
|
||||
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
@@ -9,5 +9,32 @@ 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
|
||||
|
||||
# --- Ресурсы API-реплики (на одну реплику) ---
|
||||
# Серия A трека 1 (фиксированный total): 1×1.0/512M, 2×0.5/256M, 4×0.25/128M
|
||||
API_CPUS=0.5
|
||||
API_MEMORY=256M
|
||||
API_CPU_RESERVATION=0.1
|
||||
API_MEMORY_RESERVATION=64M
|
||||
|
||||
# --- Ресурсы Postgres ---
|
||||
POSTGRES_CPUS=1.0
|
||||
POSTGRES_MEMORY=1G
|
||||
POSTGRES_CPU_RESERVATION=0.25
|
||||
POSTGRES_MEMORY_RESERVATION=256M
|
||||
|
||||
# --- Ресурсы Redis ---
|
||||
REDIS_CPUS=0.5
|
||||
REDIS_MEMORY=256M
|
||||
|
||||
# --- Публичный порт LB на хосте ---
|
||||
LB_PORT=8080
|
||||
|
||||
# --- TTL сессий и идемпотентности ---
|
||||
SESSION_TTL_SECONDS=3600
|
||||
IDEMPOTENCY_TTL_SECONDS=86400
|
||||
|
||||
# --- Graceful drain при SIGTERM ---
|
||||
SHUTDOWN_DRAIN_SECONDS=3
|
||||
+4
-1
@@ -24,9 +24,12 @@ target/
|
||||
bin/
|
||||
obj/
|
||||
coverage/
|
||||
*.log
|
||||
.DS_Store
|
||||
.idea/
|
||||
.vscode/
|
||||
# Keep small, sanitized evidence summaries in evidence/ under version control.
|
||||
# Inspect git diff --cached: ignore rules are not a secret scanner.
|
||||
|
||||
# Локальные дампы БД (крупные, не для Git)
|
||||
evidence/*.dump
|
||||
evidence/*.sql.gz
|
||||
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
FROM golang:1.26.1-alpine AS builder
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go mod download
|
||||
|
||||
COPY backend/ .
|
||||
|
||||
RUN CGO_ENABLED=0 GOOS=linux go build \
|
||||
-trimpath \
|
||||
-ldflags="-s -w" \
|
||||
-o /out/server \
|
||||
./cmd/server
|
||||
|
||||
FROM alpine:3.20
|
||||
|
||||
RUN adduser -D -u 1000 app
|
||||
|
||||
COPY --from=builder /out/server /server
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
USER app
|
||||
|
||||
HEALTHCHECK --interval=10s --timeout=3s --start-period=5s --retries=3 \
|
||||
CMD wget -q -O - http://127.0.0.1:8080/health/live >/dev/null || exit 1
|
||||
|
||||
ENTRYPOINT ["/server"]
|
||||
@@ -1,37 +1,597 @@
|
||||
# Отчёт — лабораторная 3
|
||||
# Отчёт - лабораторная 3
|
||||
|
||||
- Автор, группа: TODO
|
||||
- Целевая оценка; выбранный трек 5, если нужен: TODO
|
||||
- Commit/PR: TODO после публикации
|
||||
- Использованные источники, библиотеки и помощь ИИ: TODO
|
||||
- Автор, группа: Голиков, БВТ2303
|
||||
- Целевая оценка: на 5, трек 1 "Цена масштабирования"
|
||||
- Commit/PR: 018de46
|
||||
- Использованные источники, библиотеки и помощь ИИ:
|
||||
- Скелет лабы 3 и материалы курса: COURSE.md, contracts/openapi.json, contracts/README.md
|
||||
- Документация Docker Compose (services, deploy.resources), nginx upstream, k6 constant-arrival-rate
|
||||
- Собственная реализация лабы 2: backend на Go 1.26, gin, pgx, goose, Redis
|
||||
- ИИ использовался для структуры отчёта и вычитки формулировок; весь код, конфигурация и измерения выполнены самостоятельно
|
||||
|
||||
## Запуск из чистого clone
|
||||
|
||||
TODO: версии runtime/образов, prerequisites, команды создания локальных secrets/.env, build, миграций, запуска, ожидания готовности, тестов и остановки. Указать необходимые действия оператора. Не вставлять секреты. Отдельно указать безопасную остановку и команду намеренного удаления учебных данных.
|
||||
Prerequisites:
|
||||
|
||||
- Docker Desktop 4.30+ (WSL2 backend) или Docker Engine с Compose v2.20+
|
||||
- Go 1.26+ (для локальной сборки без Docker; в Docker-варианте не нужен)
|
||||
- Python 3.9+ (для публичных тестов из scaffold)
|
||||
- k6 v0.55+ (для нагрузочных экспериментов и трека 1)
|
||||
- git, make
|
||||
|
||||
Шаги запуска:
|
||||
|
||||
1. Клонировать fork и перейти на ветку solution:
|
||||
```
|
||||
git clone https://gitea.privcloud.tech/Maximillan_Mercer/mtusi2026lab3-fork.git mtusi2026lab3
|
||||
cd mtusi2026lab3
|
||||
git checkout solution/BVT2303-Golikov
|
||||
```
|
||||
|
||||
2. Создать локальные secrets. Значения генерируются оператором, в Git не попадают:
|
||||
```
|
||||
mkdir -p secrets
|
||||
PW="$(openssl rand -hex 16)"
|
||||
printf "%s" "$PW" > secrets/postgres_password
|
||||
printf "%s" "postgres://messenger:$PW@postgres:5432/messenger?sslmode=disable" > secrets/database_url
|
||||
printf "%s" "redis://redis:6379/0" > secrets/cache_url
|
||||
chmod 600 secrets/*
|
||||
```
|
||||
3. Создать .env из .env.example:
|
||||
```
|
||||
cp .env.example .env
|
||||
```
|
||||
Переменные и дефолты:
|
||||
|
||||
- API_REPLICAS=2 - число API-реплик
|
||||
- API_CPUS=0.5, API_MEMORY=256M - лимиты на одну реплику
|
||||
- POSTGRES_CPUS=1.0, POSTGRES_MEMORY=1G
|
||||
- REDIS_CPUS=0.5, REDIS_MEMORY=256M
|
||||
- LB_PORT=8080 - публичный порт LB на хосте
|
||||
- SESSION_TTL_SECONDS=3600
|
||||
- IDEMPOTENCY_TTL_SECONDS=86400
|
||||
- SHUTDOWN_DRAIN_SECONDS=3
|
||||
|
||||
4. Собрать образ API и запустить стек:
|
||||
```
|
||||
docker compose build api
|
||||
docker compose up -d
|
||||
```
|
||||
5. Проверить, что миграции применились и API готов:
|
||||
```
|
||||
docker compose logs migrate
|
||||
# ожидать: goose: no migrations to run. current version: 2
|
||||
# (при первом запуске: OK 0002_idempotency.sql)
|
||||
curl -sS http://localhost:8080/health/ready
|
||||
# ожидать: {"status":"ok"}
|
||||
```
|
||||
6. Прогнать публичный smoke и проверки от scaffold:
|
||||
```
|
||||
PYTHONUTF8=1 make check
|
||||
PYTHONUTF8=1 make test
|
||||
```
|
||||
7. Проверки сохранности и отказа (требуют реализации scripts/restart.sh и scripts/stop-one.sh):
|
||||
```
|
||||
PYTHONUTF8=1 make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
PYTHONUTF8=1 make test-failover ACTION_SCRIPT=scripts/stop-one.sh
|
||||
```
|
||||
Примечание для Windows. tests/resilience.py запускает хук через
|
||||
subprocess.Popen, который на Windows не умеет исполнять .sh-файлы
|
||||
(WinError 193). Локально созданы scripts/restart.cmd и scripts/stop-one.cmd,
|
||||
вызывающие ту же логику через docker compose. В репозиторий .cmd не
|
||||
коммитятся (в .gitignore), на Linux работают .sh-варианты.
|
||||
|
||||
Безопасная остановка:
|
||||
|
||||
docker compose stop # остановить контейнеры, volumes сохранить
|
||||
docker compose down # удалить контейнеры и сеть, volumes сохранить
|
||||
|
||||
Остановка с удалением учебных данных (необратимо, удалит volumes
|
||||
postgres_data и redis_data):
|
||||
|
||||
docker compose down -v
|
||||
|
||||
Отдельно про .env и secrets: оба пути в .gitignore, в репозиторий не
|
||||
попадают. Значения паролей синтетические, для локального стенда.
|
||||
|
||||
## Архитектура и решения
|
||||
|
||||
TODO: схема процессов/хранилищ, источник истины, транзакционные границы, ограничения. Что перенесено из lab2, что изменено в этой работе. Соответствие переменных из .env.example реальной конфигурации.
|
||||
Схема:
|
||||
|
||||
client (k6 или curl)
|
||||
|
|
||||
v
|
||||
nginx LB (:8080) единственная публичная точка
|
||||
|
|
||||
+-> api-1 :8080 реплика 1
|
||||
+-> api-2 :8080 реплика 2
|
||||
|
|
||||
+-> postgres :5432 общая БД (users, chats, messages, sessions, idempotency_keys)
|
||||
+-> redis :6379 общее хранилище сессий
|
||||
|
||||
Источник истины - PostgreSQL. Сессии хранятся в Redis (SESSION_STORE=redis),
|
||||
потому что так задано в ЛР2 и потому что это единственный способ обойтись
|
||||
без sticky session на LB: любая реплика видит любую сессию.
|
||||
|
||||
Транзакционные границы. Идемпотентная отправка сообщения - одна транзакция
|
||||
в Postgres. INSERT в idempotency_keys и INSERT в messages выполняются вместе,
|
||||
либо оба откатываются. Сериализация параллельных запросов на одну и ту же
|
||||
пару (user_id, method, path, key) - через уникальный индекс на idempotency_keys
|
||||
и ON CONFLICT DO NOTHING. Это делает идемпотентность корректной как внутри
|
||||
одной реплики, так и между репликами.
|
||||
|
||||
Что перенесено из ЛР2 без изменений:
|
||||
|
||||
- Схема БД: users, chats, chat_members, messages, sessions
|
||||
- Argon2id для паролей, opaque bearer token (SHA-256 от 32 случайных байт)
|
||||
- Миграции goose
|
||||
- Публичный HTTP-контракт: /api/v1/users, /chats, /messages, /auth/sessions
|
||||
|
||||
Что изменено в этой работе:
|
||||
|
||||
1. Добавлен обязательный Idempotency-Key на POST /chats/{chat_id}/messages.
|
||||
Хранится в новой таблице idempotency_keys. TTL из IDEMPOTENCY_TTL_SECONDS,
|
||||
дефолт 24 часа.
|
||||
2. Добавлен заголовок X-Instance-Id во все ответы API. Значение -
|
||||
os.Hostname() (короткий ID контейнера в Docker), стабильно в пределах
|
||||
жизни процесса.
|
||||
3. Миграции вынесены в отдельный процесс /server migrate. В compose это
|
||||
одноразовый сервис migrate с depends_on: service_completed_successfully.
|
||||
Реплики больше не запускают goose при старте.
|
||||
4. Graceful drain на SIGTERM. Atomic-флаг ready выключается до остановки
|
||||
HTTP-сервера, /health/ready возвращает 503 в окне SHUTDOWN_DRAIN_SECONDS.
|
||||
Затем srv.Shutdown ждёт завершения in-flight запросов.
|
||||
5. CPU/RAM лимиты на api, postgres, redis через deploy.resources.
|
||||
6. LB на nginx перед двумя репликами. Публичный порт только у LB, реплики
|
||||
доступны только через expose.
|
||||
7. Настроен upstream keepalive в nginx (keepalive 32, keepalive_requests,
|
||||
keepalive_timeout) как часть стандартной конфигурации LB.
|
||||
|
||||
Соответствие переменных .env.example реальной конфигурации:
|
||||
|
||||
- APP_HOST, APP_PORT - читаются в main.go, используются для ListenAndServe
|
||||
- DATABASE_URL_FILE - читается в config.Load через readSecret
|
||||
- SESSION_STORE - переключает сессии между postgres и redis
|
||||
- SESSION_TTL_SECONDS, IDEMPOTENCY_TTL_SECONDS - читаются в config.Load,
|
||||
идут в SessionService и MessageService
|
||||
- API_REPLICAS, API_CPUS, API_MEMORY - подставляются в deploy.replicas
|
||||
и deploy.resources в compose.yaml
|
||||
- LB_PORT - публичный порт nginx на хосте
|
||||
- SHUTDOWN_DRAIN_SECONDS - читается в config.Load, используется в main.go
|
||||
перед srv.Shutdown
|
||||
|
||||
## Доказательства критериев
|
||||
|
||||
| Критерий README | Команда/сценарий | Наблюдаемый результат | Файл доказательства |
|
||||
Уровень 3:
|
||||
|
||||
| Критерий | Команда | Наблюдаемый результат | Файл |
|
||||
| --- | --- | --- | --- |
|
||||
| Публичный smoke | make test | TODO | TODO |
|
||||
| Остальные пункты уровня 3 | TODO | TODO | TODO |
|
||||
| Все пункты уровня 4, если заявлен | TODO | TODO | TODO |
|
||||
| Выбранный трек 5, если заявлен | TODO | TODO | TODO |
|
||||
| Публичный smoke | PYTHONUTF8=1 make test | PASS: lab3 public API scenario | вывод на экран |
|
||||
| >= 2 API-реплики за LB | docker compose ps | api-1 и api-2 Up (healthy), LB публикует :8080 | evidence/docker-stats-limits.txt |
|
||||
| Разные X-Instance-Id при одной сессии | for i in 1..10; curl -D- health/live | два чередующихся ID | evidence/test-failover.log (observed_instances_before: 2) |
|
||||
| Остановка одной реплики <= 10 с | make test-failover | first_recovery_seconds 2.466 | evidence/test-failover.log |
|
||||
| Поочерёдная остановка каждой | make test-failover дважды | второй прогон 2.487 с, останавливалась другая реплика | evidence/test-failover-second.log |
|
||||
| Идемпотентность POST | PYTHONUTF8=1 make test (replay с тем же ключом) + make test-failover (uncertain retry) | тот же ответ, дублей нет | evidence/test-failover.log |
|
||||
| Идемпотентность POST: replay с attachment_ids: [] | PYTHONUTF8=1 python3 student-tests/test_regressions.py --base-url http://localhost:8080 | PASS: attachment_ids: [] и его отсутствие семантически равны | student-tests/test_regressions.py |
|
||||
| Persistence после restart | make test-persistence | PASS, прежний токен работает | evidence/test-persistence.log |
|
||||
|
||||
TODO: добавить отдельную строку для каждого заявленного критерия. PASS без команды и наблюдения не является доказательством. Проверка инфраструктурного hook требует подтверждения, какие реальные процессы/хранилища перезапущены.
|
||||
Уровень 4:
|
||||
|
||||
## Эксперименты и отказы
|
||||
|
||||
TODO: гипотеза, hardware/лимиты, версии, объём данных, профиль нагрузки, concurrency/arrival rate, длительность/прогрев, повторы, успешные RPS, ошибки, p50/p95/p99, CPU/RAM. Сохранить raw summary без tokens и объяснить ограничения измерения.
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| Критерий | Команда | Наблюдаемый результат | Файл |
|
||||
| --- | --- | --- | --- |
|
||||
| TODO | TODO | TODO | TODO |
|
||||
| Health/readiness, timeouts, SIGTERM согласованы | docker stop <api-N> с замером wall-clock | 3.88 с, в логах 503 на /health/ready до остановки сервера | evidence/shutdown-drain.log |
|
||||
| CPU/RAM лимиты, нет container_name, API без ports | docker inspect, docker stats | NanoCPUs=500000000, MemLimit=268435456 | evidence/docker-stats-limits.txt |
|
||||
| Миграции однократно | docker compose logs migrate | Exited (0), схема применяется один раз | evidence/migrate-log.txt |
|
||||
| Rolling update под нагрузкой | scripts/run-rolling-experiment.sh | RATE=50, 3 мин, write_errors 0.26 процента | evidence/k6-rolling.json, evidence/rolling-update.log |
|
||||
| Поочерёдная остановка каждой под нагрузкой | scripts/failover-under-load.sh 1, scripts/failover-under-load.sh 2 | прогон 1: 0 ошибок, 8.67 с; прогон 2: 1.38 процента в окне переключения nginx, 8.65 с | evidence/failover-load-api-1-k6.json, evidence/failover-load-api-2-k6.json |
|
||||
|
||||
## Отказоустойчивость: эксперименты и отказы
|
||||
|
||||
Общая среда: Windows 10, Docker Desktop (WSL2 backend), одна физическая
|
||||
машина, на которой работают и нагрузочный генератор, и весь стек. Все
|
||||
пользователи и сообщения синтетические. Версии: Postgres 16.4,
|
||||
Redis 7.4, nginx 1.27.4, Go 1.26.
|
||||
|
||||
Профиль нагрузки на k6: constant-arrival-rate, executor open-loop.
|
||||
Устраняет coordinated omission по сравнению с tests/load.py. Подробности
|
||||
в разделе трека 1.
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления, потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| SIGTERM одной реплике | drain 3 с, 503 на /health/ready, exit 0 | ровно так, 3.88 с wall-clock | 3.88 с, потерь нет |
|
||||
| Остановка одной реплики при RATE=30 (make test-failover) | writes продолжаются через LB, без дублей | first_recovery_seconds 2.466, повтор с тем же ключом даёт то же сообщение | 2.5 с, потерь нет |
|
||||
| Перезапуск всего стека (scripts/restart.sh) | данные и сессия сохранены | PASS, прежний токен работает после down/up | в пределах бюджета теста, потерь нет |
|
||||
| Rolling update под RATE=50, 3 мин | замена обеих реплик без всплеска ошибок | write_errors 0.26 процента, p95 6.27 ms | без простоя |
|
||||
| Остановка api-3 под RATE=30 | RPS не проседает, восстановление <= 10 с | 0 ошибок, 8.67 с wall-clock | без потерь |
|
||||
| Остановка api-4 под RATE=30 | RPS не проседает, восстановление <= 10 с | 1.38 процента ошибок в окне переключения, 8.65 с | без потерь |
|
||||
|
||||
Ошибки в окне переключения nginx (0.26 и 1.38 процента) объясняются тем,
|
||||
что docker stop отправляет SIGTERM, API начинает drain и держит соединение
|
||||
ещё 3 с, но LB в этот момент уже получил сброс со стороны закрывающегося
|
||||
процесса. Кратковременные ошибки допустимы по README уровня 3 (краткие
|
||||
ошибки во время обнаружения отказа измеряются и допустимы).
|
||||
|
||||
## Трек 1. Цена масштабирования
|
||||
|
||||
### Постановка и ошибки первой версии
|
||||
|
||||
Задача трека по README: при фиксированном суммарном CPU/RAM сравнить
|
||||
1/2/4 API-реплики на одном профиле нагрузки, затем провести серию с
|
||||
ростом ресурсов, найти saturation point, показать, почему рост реплик
|
||||
перестаёт помогать, дать исходные данные, графики и одно подтверждённое
|
||||
улучшение.
|
||||
|
||||
Первая версия отчёта содержала три ошибки методики, отмеченные на ревью:
|
||||
|
||||
1. Вывод о потолке 395 RPS был сделан из нагрузки RATE=400. Это точка,
|
||||
где система справляется, а не упирается. Настоящее насыщение выше.
|
||||
2. Отсутствовала серия с ростом ресурсов при фиксированном числе
|
||||
реплик, хотя README требует её явно.
|
||||
3. Метрики не разделяли успешные запросы, попытки и потерянные
|
||||
итерации. Доля ошибок и потери k6 смешивались.
|
||||
|
||||
Отдельно: объяснение улучшения через «включение keepalive» расходилось
|
||||
с Git. Директива `keepalive 32` присутствовала в `infra/nginx.conf` с
|
||||
первого коммита (2211eaa), а коммит e769e08 добавил только
|
||||
`keepalive_requests`, `keepalive_timeout` и увеличил
|
||||
`worker_connections 512 -> 1024`. Значит, приписывать +80 % пропускной
|
||||
способности включению keepalive было неверно.
|
||||
|
||||
Настоящий раздел написан заново. Серии A, B, C переделаны с нуля,
|
||||
метрики разделены, выводы пересмотрены.
|
||||
|
||||
### Методика
|
||||
|
||||
Нагрузочный генератор: k6 v0.55, executor `constant-arrival-rate`
|
||||
(open-loop). Скрипт `student-tests/load-k6.js`. Каждый VU логинится
|
||||
один раз в `setup()`, затем шлёт POST /messages с уникальным
|
||||
`Idempotency-Key`. Open-loop устраняет coordinated omission, в отличие
|
||||
от `tests/load.py`.
|
||||
|
||||
Каждый замер - 2 или 3 прогона в зависимости от серии. Между прогонами
|
||||
стек не пересоздаётся, но между конфигурациями - да, чтобы избежать
|
||||
накопленного состояния. Медиана по прогонам в сводных таблицах.
|
||||
|
||||
Метрики разделены:
|
||||
|
||||
- **Успешные** (`write_total.rate`) - POST, завершившиеся 201.
|
||||
- **Попытки** (`http_reqs.rate`) - все отправленные POST.
|
||||
- **Потерянные** (`dropped_iterations.rate`) - k6 не смог даже
|
||||
отправить запрос из-за нехватки VU. Это клиентский предел, не
|
||||
серверная ошибка.
|
||||
- **Ошибки** (`write_errors.rate`) - POST, вернувшие не-201.
|
||||
- **p95 / max** (`write_latency_ms`) - хвосты latency успешных.
|
||||
|
||||
Среда: Windows 10, Docker Desktop (WSL2), одна физическая машина.
|
||||
На ней и стек, и k6. Postgres 16.4, Redis 7.4, nginx 1.27.4, Go 1.26.
|
||||
Аппаратные лимиты: api - 0.25-2.0 CPU / 128M-1G в зависимости от
|
||||
конфигурации, postgres - 1.0 CPU / 1G, redis - 0.5 CPU / 256M,
|
||||
lb - 0.5 CPU / 128M.
|
||||
|
||||
Данные: `evidence/new_ev/` (JSON summary k6 + CSV docker stats).
|
||||
Скрипты запуска серий и сборки CSV в репозитории не публикуются,
|
||||
это вспомогательные утилиты.
|
||||
|
||||
### Серия A. Фиксированный суммарный CPU/RAM, RATE=400
|
||||
|
||||
Цель серии: проверить гипотезу о плато RPS при фиксированном
|
||||
суммарном ресурсе и разном числе реплик. Три конфигурации:
|
||||
|
||||
| Конфигурация | Total CPU | Total RAM |
|
||||
| --- | --- | --- |
|
||||
| 1 × 1.0 CPU / 512M | 1.0 | 512M |
|
||||
| 2 × 0.5 CPU / 256M | 1.0 | 512M |
|
||||
| 4 × 0.25 CPU / 128M | 1.0 | 512M |
|
||||
|
||||
Нагрузка: RATE=400, 2 минуты, 3 прогона на точку, медиана.
|
||||
|
||||
| Конфигурация | Успешных RPS | p95, ms | max, ms | Dropped/s | Ошибки |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 1 × 1.0 / 512M | 398 | 4.25 | 169 | 0 | 0 % |
|
||||
| 2 × 0.5 / 256M | 397 | 4.05 | 222 | 0 | 0 % |
|
||||
| 4 × 0.25 / 128M | 394 | 4.49 | 525 | 0 | 0 % |
|
||||
|
||||
Все три конфигурации обслуживают примерно одинаковое количество
|
||||
запросов: 394–398 RPS при спросе 400. Разброс между конфигурациями
|
||||
в пределах 1 %, что сопоставимо с шумом измерения. `dropped_iterations`
|
||||
равны нулю, `write_errors` тоже. Значит, k6 успел отправить всё, что
|
||||
планировал, и сервер на всё ответил.
|
||||
|
||||
**Вывод: при RATE=400 система недогружена.** Цифра 394–398 RPS - это
|
||||
не потолок системы, а величина спроса. Настоящее насыщение нужно искать
|
||||
при более высокой нагрузке, что и делается в серии B.
|
||||
|
||||
В первой версии отчёта эта серия интерпретировалась как «плато на 395
|
||||
RPS, saturation point». Это была ошибка методики: измеряли спрос, а не
|
||||
предел. Серия A показывает только, что до 400 RPS любая из трёх
|
||||
конфигураций справляется одинаково хорошо.
|
||||
|
||||
### Серия B. Рост нагрузки на фиксированной конфигурации 2 × 0.5 / 256M
|
||||
|
||||
Цель серии: найти настоящую точку насыщения. Конфигурация одна -
|
||||
2 реплики по 0.5 CPU / 256M, это значение позже окажется оптимальным
|
||||
в серии C. Меняем только интенсивность.
|
||||
|
||||
Нагрузка: RATE от 200 до 1000, длительность 1 минута, 2 прогона
|
||||
на точку, медиана.
|
||||
|
||||
| RATE (спрос) | Успешных RPS | p95 latency | max latency | Dropped/s | Ошибки |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| 200 | 197 | 4.2 ms | 13 ms | 0 | 0 % |
|
||||
| 400 | 395 | 4.0 ms | 80 ms | 0 | 0 % |
|
||||
| 600 | 591 | 6.0 ms | 232 ms | 0 | 0 % |
|
||||
| 800 | 719 | 4500 ms | 5400 ms | 26 | 0 % |
|
||||
| 1000 | 682 | 7000 ms | 7800 ms | 231 | 0 % |
|
||||
|
||||
До RATE=600 система ведёт себя линейно:
|
||||
|
||||
- Успешных RPS растут ровно по спросу: 197 → 395 → 591. Разница между
|
||||
спросом и фактической пропускной способностью в пределах 1 %.
|
||||
- p95 latency держится на уровне 4–6 мс.
|
||||
- `dropped_iterations` и `write_errors` равны нулю.
|
||||
- k6 успевает отправить всё запланированное, сервер отвечает без
|
||||
задержек.
|
||||
|
||||
Между RATE=600 и RATE=800 происходит резкий скачок:
|
||||
|
||||
- p95 вырастает с 6 мс до **4.5 секунд**, в ~750 раз.
|
||||
- Максимальная latency за прогон доходит до 5.4 с.
|
||||
- Появляются `dropped_iterations`: 26 итераций/с.
|
||||
- Успешных RPS растёт всего до 719, а не до 800.
|
||||
|
||||
При RATE=1000 картина деградирует дальше: успешных RPS даже падает
|
||||
до 682, `dropped_iterations` вырастает до 231/с, p95 latency - 7 с.
|
||||
Это уже область, где клиент k6 не справляется с подачей нагрузки,
|
||||
а не сервер.
|
||||
|
||||
**Точка насыщения: около 650–700 RPS.** Это значение, после которого
|
||||
рост спроса перестаёт давать прирост пропускной способности и начинает
|
||||
резко ухудшать latency. До неё система работает стабильно.
|
||||
|
||||
Отдельно важно, что `write_errors` на всём диапазоне равны нулю.
|
||||
Сервер нигде не отдаёт 5xx, не рвёт соединения, не отказывает. Всё, что
|
||||
мы видим как «потери» - это `dropped_iterations` на стороне k6:
|
||||
клиент не успел отправить запрос из-за нехватки виртуальных
|
||||
пользователей. То есть **ограничение сверху - не сервер, а нагрузочный
|
||||
генератор на той же машине**.
|
||||
|
||||
Это принципиальный вывод для всего трека: потолок в 720–750 RPS,
|
||||
который видно на графике, - это потолок k6 при заданной конфигурации
|
||||
VU и latency, а не потолок серверного стека. Настоящий потолок выше,
|
||||
но для его поиска нужен отдельный физический хост под нагрузочный
|
||||
генератор. Это ограничение честно фиксируется в разделе «Ограничения».
|
||||
|
||||

|
||||
|
||||
На графиках: верхний левый - серия A (все три конфигурации
|
||||
справляются с RATE=400); верхний правый - серия B, успешные RPS
|
||||
и dropped iterations против спроса, видна точка насыщения и
|
||||
клиентский bottleneck; нижний левый - серия B, p95 и avg latency
|
||||
на логарифмической шкале, резкий скачок после 600 RPS; нижний
|
||||
правый - серия C (разбирается ниже).
|
||||
|
||||
### Серия C. Рост ресурсов на фиксированном числе реплик, RATE=800
|
||||
|
||||
Цель серии: проверить второе требование README трека 1 - серию с
|
||||
ростом ресурсов. Фиксируем 2 реплики и увеличиваем ресурсы на реплику.
|
||||
Нагрузка RATE=800 - выше найденной точки насыщения, чтобы видеть
|
||||
разницу между конфигурациями в зоне деградации.
|
||||
|
||||
Конфигурации:
|
||||
|
||||
| Конфигурация | Total CPU | Total RAM |
|
||||
| --- | --- | --- |
|
||||
| 2 × 0.25 CPU / 128M | 0.5 | 256M |
|
||||
| 2 × 0.5 CPU / 256M | 1.0 | 512M |
|
||||
| 2 × 1.0 CPU / 512M | 2.0 | 1G |
|
||||
| 2 × 2.0 CPU / 1G | 4.0 | 2G |
|
||||
|
||||
| Конфигурация | Успешных RPS | p95 latency | Dropped/s | Ошибки |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| 2 × 0.25 / 128M | 436 | 7.5 с | 260 | 0 % / 4.88 % (run1/run2) |
|
||||
| 2 × 0.5 / 256M | **742** | 2.9 с | 12 | 0 % |
|
||||
| 2 × 1.0 / 512M | 698 | 4.7 с | 50 | 0 % |
|
||||
| 2 × 2.0 / 1G | 733 | 4.2 с | 22 | 0 % |
|
||||
|
||||
**Конфигурация 2 × 0.25 / 128M не тянет RATE=800.** Успешных RPS 436
|
||||
из 800 - около половины спроса. p95 latency 7.5 секунд, потеряно
|
||||
260 итераций в секунду, во втором прогоне появились серверные ошибки
|
||||
4.88 % - сервер начал отказывать под memory pressure. По `docker stats`
|
||||
обе api-реплики держат ровно 127.9 MiB / 128
|
||||
MiB, то есть упираются в memory limit. Go-runtime в memory pressure:
|
||||
GC работает агрессивно, stop-the-world паузы дают многократный рост
|
||||
latency, часть запросов не дожидается ответа.
|
||||
|
||||
**Конфигурация 2 × 0.5 / 256M - оптимум.** Успешных RPS 742, p95 всего
|
||||
2.9 секунды, dropped минимум (8–16 итераций/с), ошибок нет. Это лучший
|
||||
результат серии. Увеличение памяти до 256 MiB снимает memory pressure,
|
||||
Go-runtime дышит свободно, GC не создаёт длительных паузы.
|
||||
|
||||
**Дальнейший рост ресурсов не помогает.** 2 × 1.0 / 512M даёт 698 RPS
|
||||
(даже немного хуже), 2 × 2.0 / 1G - 733 RPS. Разница в пределах
|
||||
шума прогонов. Причина: как и в серии B, сервер уже не является узким
|
||||
местом. Выше 0.5 / 256M система упирается не в CPU и не в RAM, а в
|
||||
клиент k6 на той же машине.
|
||||
|
||||
**Главный вывод серии C:** точка оптимального размера реплики - около
|
||||
**0.5 CPU / 256M**. Меньше - memory pressure в Go-runtime. Больше -
|
||||
впустую, потому что узкое место уехало с сервера.
|
||||
|
||||
### Подтверждённое улучшение
|
||||
|
||||
Рост ресурсов реплики с 0.25 CPU / 128M до 0.5 CPU / 256M даёт
|
||||
измеримое улучшение при RATE=800:
|
||||
|
||||
| Метрика | 0.25 / 128M | 0.5 / 256M | Дельта |
|
||||
| --- | --- | --- | --- |
|
||||
| Успешных RPS | 436 | 742 | **+70 %** |
|
||||
| p95 latency | 7.5 с | 2.9 с | **x2.6 быстрее** |
|
||||
| Dropped iterations/s | 260 | 12 | **x21 меньше** |
|
||||
| Ошибки | 2.4 % | 0 % | 0 |
|
||||
|
||||
Это подтверждённое улучшение в терминах README: измеримое,
|
||||
воспроизводимое, с понятным механизмом (memory pressure в Go-runtime
|
||||
при лимите 128 MiB). В отличие от первой версии отчёта, где улучшением
|
||||
называлось включение keepalive (что не подтверждается Git), здесь
|
||||
улучшение видно в прямом сравнении двух конфигураций.
|
||||
|
||||
### Пересмотренные выводы по треку 1
|
||||
|
||||
**Что показали три серии в сумме:**
|
||||
|
||||
1. **Серия A:** при RATE=400 система недогружена. Разница между
|
||||
конфигурациями 1/2/4 реплики при фиксированном total ресурсе
|
||||
незначима, все обслуживают ~397 RPS. Плато «на 395» из первой
|
||||
версии отчёта - это не saturation point, а совпадение спроса с
|
||||
пропускной способностью.
|
||||
|
||||
2. **Серия B:** настоящая точка насыщения находится около **650–700
|
||||
RPS** при конфигурации 2 × 0.5 / 256M. До неё система работает
|
||||
стабильно, после неё p95 latency растёт в разы, начинаются потери
|
||||
k6. `write_errors` нигде не появляются: сервер не отказывает, всё
|
||||
ограничение на стороне клиента.
|
||||
|
||||
3. **Серия C:** рост ресурсов на реплику помогает только до 0.5 CPU /
|
||||
256M. Дальше бессмысленно. Увеличение лимитов с 0.25 / 128M до
|
||||
0.5 / 256M даёт +70 % успешных при RATE=800 и снижает p95 в 2.6
|
||||
раза.
|
||||
|
||||
**Почему рост реплик перестаёт помогать.** Настоящая причина не в
|
||||
конкретном компоненте стека. До 650 RPS система масштабируется
|
||||
предсказуемо. Выше - узкое место уезжает в клиент k6 на том же хосте.
|
||||
Ни API, ни Postgres, ни nginx при этом не упираются в CPU (по docker
|
||||
stats api-реплики держат 25–30 %, Postgres 45–50 %, LB 10 %). Дальнейший
|
||||
прирост пропускной способности не наблюдается, потому что запросов
|
||||
больше физически не приходит.
|
||||
|
||||
**Что не сработало как улучшение.** Гипотеза о том, что узкое место
|
||||
в LB и лечится upstream keepalive, не подтвердилась при проверке Git:
|
||||
`keepalive 32` был в конфиге с первого коммита, коммит e769e08 добавил
|
||||
только `keepalive_requests`, `keepalive_timeout` и увеличил
|
||||
`worker_connections`. Разница в цифрах между «до» и «после» в первой
|
||||
версии отчёта объясняется, вероятно, вариабельностью прогонов и
|
||||
изменением `worker_connections`, а не самим keepalive. Это исправлено
|
||||
в текущей версии отчёта.
|
||||
|
||||
### Ограничения трека
|
||||
|
||||
1. **k6 на том же физическом хосте, что и стек.** Это главное
|
||||
ограничение. При VU до 4800 k6 упирается в свой собственный CPU и
|
||||
в latency, начинаются `dropped_iterations`. Потолок 720–750 RPS,
|
||||
видимый в сериях B и C, - это потолок нагрузочного генератора, а не
|
||||
серверного стека. Настоящий потолок сервера не измерен.
|
||||
|
||||
2. **Одна машина.** Docker Desktop (WSL2) на Windows: сетевой стек
|
||||
эмулируется через виртуальную машину, накладные расходы не видны
|
||||
в метриках контейнеров. Всё живёт на одном хосте: LB, обе реплики,
|
||||
Postgres, Redis, клиент.
|
||||
|
||||
3. **2–3 прогона на точку.** Минимум по README. Разброс между
|
||||
прогонами в серии C достигал 10 % (например, 0.25 / 128M: 453 и
|
||||
419 RPS), что делает медиану нестабильной. В серии A разброс был
|
||||
меньше 1 %.
|
||||
|
||||
4. **Метрики CPU/RAM из `docker stats`** имеют округление 0.01 % и
|
||||
период семплирования 2 секунды. Короткие пики могут не попадать в
|
||||
семпл. В конфигурации 0.25 / 128M это заметно: реплики держат ровно
|
||||
127.9–128 MiB, но провал мог длиться дольше одного сэмпла.
|
||||
|
||||
5. **Параметры VU в k6.** `preAllocatedVUs = RATE * 2`, `maxVUs = RATE * 4`.
|
||||
При RATE=1000 это 4000 VU - примерно столько же, сколько активных
|
||||
клиентских соединений, то есть существенная нагрузка на CPU хоста.
|
||||
Ограничение даёт верхнюю границу применимости методики.
|
||||
|
||||
### Что нужно для полной картины
|
||||
|
||||
Для поиска настоящего потолка серверного стека нужен отдельный
|
||||
физический хост под нагрузочный генератор. Тогда:
|
||||
- клиент перестанет быть bottleneck;
|
||||
- можно давить выше 1000 RPS и найти реальную точку отказа;
|
||||
- можно отдельно измерить вклад nginx, Postgres и сети.
|
||||
|
||||
Это выходит за рамки одной учебной машины, поэтому фиксируется как
|
||||
честное ограничение, а не как достигнутый результат.
|
||||
|
||||
### Итог по треку 1
|
||||
|
||||
Что требовал README:
|
||||
|
||||
- **Сравнить 1/2/4 реплики при фиксированном total CPU/RAM** - серия A,
|
||||
все конфигурации дают ~397 RPS при RATE=400. Недогруз.
|
||||
- **Провести серию с ростом ресурсов** - серия C, 2 реплики × 0.25/0.5/1.0/2.0 CPU.
|
||||
Оптимум - 0.5 CPU / 256M.
|
||||
- **Найти saturation point** - серия B, около 650–700 RPS.
|
||||
- **Показать, почему рост реплик перестаёт помогать** - узкое место
|
||||
уезжает с сервера в клиент k6 на той же машине.
|
||||
- **Дать исходные данные** - `evidence/new_ev/` (JSON + CSV по всем
|
||||
прогонам).
|
||||
- **Дать графики** - `evidence/new_ev/charts.png`, четыре панели.
|
||||
- **Одно подтверждённое улучшение** - рост ресурсов реплики с
|
||||
0.25/128M до 0.5/256M: +70 % успешных при RATE=800, p95 в 2.6 раза
|
||||
ниже, dropped в 21 раз меньше.
|
||||
|
||||
Выводы первой версии отчёта (потолок 395 RPS, улучшение через
|
||||
keepalive) не подтвердились при повторном анализе. Причина -
|
||||
ошибки методики: измерение спроса вместо предела, отсутствие серии
|
||||
с ростом ресурсов, смешивание успешных и потерянных итераций.
|
||||
В текущей версии эти ошибки исправлены.
|
||||
|
||||
## Ограничения и следующие шаги
|
||||
|
||||
TODO: какие отказы выдерживаются и какие нет; что не реализовано; где учебное упрощение; какое улучшение подтверждено, а какое пока гипотеза.
|
||||
Что выдерживает:
|
||||
|
||||
- Отказ одной API-реплики (любой из двух) при RATE до 400 RPS.
|
||||
- Graceful drain с сохранением in-flight запросов.
|
||||
- Rolling update без простоя.
|
||||
- Перезапуск всего стека с сохранением данных и сессий.
|
||||
- Нагрузку до точки насыщения, измеренной в треке 1 (~650-700 RPS).
|
||||
|
||||
Что не выдерживает:
|
||||
|
||||
- Отказ узла. Всё работает на одном хосте, потеря хоста = потеря системы.
|
||||
Postgres и Redis без репликации, LB без резерва.
|
||||
- RATE выше ~650-700 RPS: рост latency и потери итераций k6. Точка
|
||||
насыщения измерена в серии B трека 1.
|
||||
|
||||
Не реализовано в этой работе:
|
||||
|
||||
- PgBouncer. Проверялась гипотеза о pool exhaustion в pgx, гипотеза
|
||||
не подтвердилась (см. первую версию трека 1), поэтому PgBouncer не
|
||||
добавлен.
|
||||
- Вторая реплика Postgres и failover БД. Не входит в обязательный
|
||||
минимум, отмечено как SPOF в ограничениях.
|
||||
- HTTPS. По контракту требуется только с ЛР7, здесь HTTP для локального
|
||||
стенда.
|
||||
- Полноценная распределённая нагрузка. k6 на одной машине со стеком
|
||||
измеряет не только стек, но и клиент. Это ключевое ограничение трека 1.
|
||||
|
||||
Учебные упрощения:
|
||||
|
||||
- БД и хранилище сессий живут в одном экземпляре, оба на том же хосте,
|
||||
что и API. Для уровня 3 достаточно, для продакшена недостаточно.
|
||||
- Миграции выполняются одноразовым сервисом migrate, но без отдельных
|
||||
rollback-сценариев. Если миграция падает, стек не поднимается.
|
||||
|
||||
Подтверждённые улучшения (сводка):
|
||||
|
||||
- Graceful drain снизил долю обрывов in-flight запросов при остановке
|
||||
реплики. docker stop даёт серверу корректно завершиться с exit 0.
|
||||
- Изоляция миграций в отдельный процесс сняла гонку за goose lock при
|
||||
старте нескольких реплик одновременно.
|
||||
- X-Instance-Id позволяет на защите и в тестах однозначно сопоставить
|
||||
ответ конкретной реплике, без чтения логов.
|
||||
- Оптимальный размер реплики: 0.5 CPU / 256M. Меньше - memory pressure
|
||||
в Go-runtime, больше - не даёт прироста. Подтверждено серией C
|
||||
трека 1: +70 % успешных, p95 в 2.6 раза ниже, dropped в 21 раз
|
||||
меньше при переходе с 0.25/128M на 0.5/256M.
|
||||
|
||||
Оставшиеся гипотезы (не проверены из-за ограничений стенда):
|
||||
|
||||
- Накладные расходы nginx при проксировании. В метриках не выделяются:
|
||||
nginx держит около 10 процентов CPU на всём диапазоне.
|
||||
|
||||
Следующий шаг для полной картины: вынести нагрузочный генератор на
|
||||
отдельный физический хост, провести серию с RATE выше 1000 RPS и найти
|
||||
настоящую точку отказа серверного стека. Тогда же можно отдельно
|
||||
измерить вклад nginx, Postgres и сети, который сейчас скрыт за
|
||||
клиентским bottleneck'ом.
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"high-loud-apps-labs/internal/config"
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi"
|
||||
"high-loud-apps-labs/internal/httpapi/handler"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
"high-loud-apps-labs/internal/storage/postgres"
|
||||
redisstore "high-loud-apps-labs/internal/storage/redis"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 && os.Args[1] == "migrate" {
|
||||
if err := runMigrate(); err != nil {
|
||||
log.Fatalf("миграции: %v", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
log.Fatalf("конфигурация: %v", err)
|
||||
}
|
||||
|
||||
addr := cfg.Host + ":" + cfg.Port
|
||||
|
||||
ctx := context.Background()
|
||||
pool, err := postgres.Connect(ctx, postgres.Config{
|
||||
URL: cfg.DatabaseURL,
|
||||
MaxConns: 10,
|
||||
MinConns: 1,
|
||||
MaxConnLifetime: time.Hour,
|
||||
MaxConnIdleTime: 30 * time.Minute,
|
||||
ConnectTimeout: 5 * time.Second,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatalf("БД: %v", err)
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
store := postgres.New(pool)
|
||||
|
||||
sessionRepo, cachePing, closeSession := newSessionRepo(cfg, store)
|
||||
defer closeSession()
|
||||
|
||||
hasher := service.NewArgon2idHasher()
|
||||
|
||||
userSvc := service.NewUserService(store.Users(), hasher)
|
||||
sessionSvc := service.NewSessionService(store.Users(), sessionRepo, hasher, cfg.SessionTTL)
|
||||
chatSvc := service.NewChatService(store.Chats(), store.Users())
|
||||
messageSvc := service.NewMessageService(store.Messages(), store.Chats(), cfg.IdempotencyTTL)
|
||||
|
||||
healthChecks := []handler.HealthCheck{
|
||||
func(ctx context.Context) error { return pool.Ping(ctx) },
|
||||
}
|
||||
if cachePing != nil {
|
||||
healthChecks = append(healthChecks, cachePing)
|
||||
}
|
||||
|
||||
var ready atomic.Bool
|
||||
ready.Store(true)
|
||||
|
||||
router := httpapi.NewRouter(
|
||||
httpapi.Handlers{
|
||||
Health: handler.NewHealthHandler(healthChecks...).WithReadyFlag(&ready),
|
||||
User: handler.NewUserHandler(userSvc),
|
||||
Chat: handler.NewChatHandler(chatSvc),
|
||||
Message: handler.NewMessageHandler(messageSvc),
|
||||
Auth: handler.NewAuthHandler(sessionSvc),
|
||||
},
|
||||
middleware.BearerAuth(sessionSvc),
|
||||
)
|
||||
|
||||
srv := &http.Server{Addr: addr, Handler: router}
|
||||
|
||||
go func() {
|
||||
log.Printf("Запускаем на %s (SESSION_STORE=%s)", addr, cfg.SessionStore)
|
||||
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Fatalf("Ошибка запуска: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
quit := make(chan os.Signal, 1)
|
||||
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
|
||||
<-quit
|
||||
|
||||
log.Printf("Получен сигнал завершения; readiness выключен, drain %s", cfg.ShutdownDrain)
|
||||
ready.Store(false)
|
||||
|
||||
if cfg.ShutdownDrain > 0 {
|
||||
time.Sleep(cfg.ShutdownDrain)
|
||||
}
|
||||
|
||||
log.Println("Drain завершён, останавливаем HTTP-сервер...")
|
||||
shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
if err := srv.Shutdown(shutdownCtx); err != nil {
|
||||
log.Fatalf("Ошибка при остановке: %v", err)
|
||||
}
|
||||
log.Println("Сервер остановлен")
|
||||
}
|
||||
|
||||
// runMigrate — одноразовый прогон goose. Запускается как `/server migrate`.
|
||||
// Использует те же DATABASE_URL_FILE / DATABASE_URL, что и сервер.
|
||||
// Отдельный процесс, поэтому не конкурирует с репликами за goose lock.
|
||||
func runMigrate() error {
|
||||
cfg, err := config.Load()
|
||||
if err != nil {
|
||||
return fmt.Errorf("конфигурация: %w", err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
|
||||
defer cancel()
|
||||
|
||||
pool, err := postgres.Connect(ctx, postgres.Config{
|
||||
URL: cfg.DatabaseURL,
|
||||
ConnectTimeout: 5 * time.Second,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("БД: %w", err)
|
||||
}
|
||||
defer pool.Close()
|
||||
|
||||
if err := postgres.RunMigrations(ctx, pool); err != nil {
|
||||
return fmt.Errorf("применение миграций: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func newSessionRepo(cfg *config.Config, store *postgres.Storage) (domain.SessionRepository, handler.HealthCheck, func()) {
|
||||
switch strings.ToLower(cfg.SessionStore) {
|
||||
case "", "postgres":
|
||||
return store.Sessions(), nil, func() {}
|
||||
case "redis":
|
||||
if cfg.CacheURL == "" {
|
||||
log.Fatalf("SESSION_STORE=%s требует CACHE_URL_FILE или CACHE_URL", cfg.SessionStore)
|
||||
}
|
||||
client, err := redisstore.NewClient(cfg.CacheURL)
|
||||
if err != nil {
|
||||
log.Fatalf("redis: %v", err)
|
||||
}
|
||||
ping := func(ctx context.Context) error {
|
||||
return client.Ping(ctx).Err()
|
||||
}
|
||||
return redisstore.NewSessionRepo(client), ping, func() { _ = client.Close() }
|
||||
default:
|
||||
log.Fatalf("SESSION_STORE=%q не поддерживается", cfg.SessionStore)
|
||||
return nil, nil, nil
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
module high-loud-apps-labs
|
||||
|
||||
go 1.26.1
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.12.0
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6
|
||||
github.com/jackc/pgx/v5 v5.7.1
|
||||
github.com/pressly/goose/v3 v3.22.1
|
||||
golang.org/x/crypto v0.57.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||
github.com/bytedance/sonic v1.15.0 // indirect
|
||||
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
|
||||
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/go-playground/validator/v10 v10.30.1 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
|
||||
github.com/jackc/puddle/v2 v2.2.2 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||
github.com/leodido/go-urn v1.4.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
github.com/mfridman/interpolate v0.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/quic-go/qpack v0.6.0 // indirect
|
||||
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||
github.com/redis/go-redis/v9 v9.22.0 // indirect
|
||||
github.com/sethvargo/go-retry v0.3.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.22.0 // indirect
|
||||
golang.org/x/net v0.58.0 // indirect
|
||||
golang.org/x/sync v0.23.0 // indirect
|
||||
golang.org/x/sys v0.48.0 // indirect
|
||||
golang.org/x/text v0.42.0 // indirect
|
||||
google.golang.org/protobuf v1.36.10 // indirect
|
||||
)
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
|
||||
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12 h1:e9hWvmLYvtp846tLHam2o++qitpguFiYCKbn0w9jyqw=
|
||||
github.com/gabriel-vasile/mimetype v1.4.12/go.mod h1:d+9Oxyo1wTzWdyVUPMmXFvp4F9tea18J8ufA774AB3s=
|
||||
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.30.1 h1:f3zDSN/zOma+w6+1Wswgd9fLkdwy06ntQJp0BBvFG0w=
|
||||
github.com/go-playground/validator/v10 v10.30.1/go.mod h1:oSuBIQzuJxL//3MelwSLD5hc2Tu889bF0Idm9Dg26cM=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6 h1:D/V0gu4zQ3cL2WKeVNVM4r2gLxGGf6McLwgXzRTo2RQ=
|
||||
github.com/jackc/pgerrcode v0.0.0-20250907135507-afb5586c32a6/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo=
|
||||
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.7.1 h1:x7SYsPBYDkHDksogeSmZZ5xzThcTgRz++I5E+ePFUcs=
|
||||
github.com/jackc/pgx/v5 v5.7.1/go.mod h1:e7O26IywZZ+naJtWWos6i6fvWK+29etgITqrqHLfoZA=
|
||||
github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo=
|
||||
github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
|
||||
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
|
||||
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/pressly/goose/v3 v3.22.1 h1:2zICEfr1O3yTP9BRZMGPj7qFxQ+ik6yeo+z1LMuioLc=
|
||||
github.com/pressly/goose/v3 v3.22.1/go.mod h1:xtMpbstWyCpyH+0cxLTMCENWBG+0CSxvTsXhW95d5eo=
|
||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||
github.com/redis/go-redis/v9 v9.22.0 h1:laDvpYXTJtZLloinw1fA5Kqd6HAEH2XKxOkG/PDq2F0=
|
||||
github.com/redis/go-redis/v9 v9.22.0/go.mod h1:y2g0Wj8rQvuK0ELM+oxSudcLtC09JScs98I/X9gRWY4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/sethvargo/go-retry v0.3.0 h1:EEt31A35QhrcRZtrYFDTBg91cqZVnFL2navjDrah2SE=
|
||||
github.com/sethvargo/go-retry v0.3.0/go.mod h1:mNX17F0C/HguQMyMyJxcnU471gOZGxCLyYaFyAZraas=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
||||
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||
golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk=
|
||||
golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
|
||||
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
|
||||
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
|
||||
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
|
||||
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
|
||||
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
|
||||
modernc.org/sqlite v1.33.0 h1:WWkA/T2G17okiLGgKAj4/RMIvgyMT19yQ038160IeYk=
|
||||
modernc.org/sqlite v1.33.0/go.mod h1:9uQ9hF/pCZoYZK73D/ud5Z7cIRIILSZI8NdIemVMTX8=
|
||||
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
|
||||
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
|
||||
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
|
||||
modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=
|
||||
@@ -0,0 +1,119 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Host string
|
||||
Port string
|
||||
DatabaseURL string
|
||||
SessionStore string
|
||||
CacheURL string
|
||||
SessionTTL time.Duration
|
||||
IdempotencyTTL time.Duration
|
||||
ShutdownDrain time.Duration
|
||||
}
|
||||
|
||||
func Load() (*Config, error) {
|
||||
dsn, err := readSecret("DATABASE_URL_FILE", "DATABASE_URL")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("database url: %w", err)
|
||||
}
|
||||
|
||||
cacheURL, err := readSecretOptional("CACHE_URL_FILE", "CACHE_URL")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cache url: %w", err)
|
||||
}
|
||||
|
||||
ttlSeconds, err := readInt("SESSION_TTL_SECONDS", 3600)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SESSION_TTL_SECONDS: %w", err)
|
||||
}
|
||||
if ttlSeconds <= 0 {
|
||||
return nil, fmt.Errorf("SESSION_TTL_SECONDS должен быть положительным")
|
||||
}
|
||||
|
||||
idemSeconds, err := readInt("IDEMPOTENCY_TTL_SECONDS", 86400)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("IDEMPOTENCY_TTL_SECONDS: %w", err)
|
||||
}
|
||||
if idemSeconds <= 0 {
|
||||
return nil, fmt.Errorf("IDEMPOTENCY_TTL_SECONDS должен быть положительным")
|
||||
}
|
||||
|
||||
drainSeconds, err := readInt("SHUTDOWN_DRAIN_SECONDS", 3)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("SHUTDOWN_DRAIN_SECONDS: %w", err)
|
||||
}
|
||||
if drainSeconds < 0 {
|
||||
return nil, fmt.Errorf("SHUTDOWN_DRAIN_SECONDS не может быть отрицательным")
|
||||
}
|
||||
|
||||
store := strings.ToLower(getenv("SESSION_STORE", "postgres"))
|
||||
switch store {
|
||||
case "postgres", "redis", "valkey":
|
||||
default:
|
||||
return nil, fmt.Errorf("SESSION_STORE=%q не поддерживается", store)
|
||||
}
|
||||
|
||||
return &Config{
|
||||
Host: getenv("APP_HOST", "0.0.0.0"),
|
||||
Port: getenv("APP_PORT", "8080"),
|
||||
DatabaseURL: dsn,
|
||||
SessionStore: store,
|
||||
CacheURL: cacheURL,
|
||||
SessionTTL: time.Duration(ttlSeconds) * time.Second,
|
||||
IdempotencyTTL: time.Duration(idemSeconds) * time.Second,
|
||||
ShutdownDrain: time.Duration(drainSeconds) * time.Second,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getenv(key, def string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
func readInt(key string, def int) (int, error) {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
return def, nil
|
||||
}
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("не целое число: %q", v)
|
||||
}
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func readSecret(fileEnv, envKey string) (string, error) {
|
||||
v, err := readSecretOptional(fileEnv, envKey)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
if v == "" {
|
||||
return "", fmt.Errorf("не задан %s или %s", fileEnv, envKey)
|
||||
}
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func readSecretOptional(fileEnv, envKey string) (string, error) {
|
||||
if path := os.Getenv(fileEnv); path != "" {
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("чтение %s=%s: %w", fileEnv, path, err)
|
||||
}
|
||||
s := strings.TrimSpace(string(b))
|
||||
if s == "" {
|
||||
return "", fmt.Errorf("файл %s пуст", path)
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
return os.Getenv(envKey), nil
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
|
||||
type Health struct {
|
||||
Status string
|
||||
}
|
||||
|
||||
type User struct {
|
||||
ID string
|
||||
Username string
|
||||
DisplayName string
|
||||
PasswordHash string // в DTO UserResponse его не будет
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Chat struct {
|
||||
ID string
|
||||
Title string
|
||||
MemberIDs []string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Message struct {
|
||||
ID string
|
||||
ChatID string
|
||||
SenderID string
|
||||
Text string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type Session struct {
|
||||
TokenHash []byte
|
||||
UserID string
|
||||
ExpiresAt time.Time
|
||||
CreatedAt time.Time
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ErrorCode string
|
||||
|
||||
const (
|
||||
CodeInvalidRequest ErrorCode = "invalid_request"
|
||||
CodeUnauthorized ErrorCode = "unauthorized"
|
||||
CodeNotFound ErrorCode = "not_found"
|
||||
CodeConflict ErrorCode = "conflict"
|
||||
CodeUnsupportedMediaType ErrorCode = "unsupported_media_type"
|
||||
CodeInternalError ErrorCode = "internal_error"
|
||||
CodeUnavailable ErrorCode = "unavailable"
|
||||
)
|
||||
|
||||
var (
|
||||
ErrNotFound = errors.New("не найдено")
|
||||
ErrAlreadyExists = errors.New("уже существует")
|
||||
ErrInvalidInput = errors.New("некорректные данные")
|
||||
ErrUnauthorized = errors.New("требуется аутентификация")
|
||||
ErrUnsupportedMediaType = errors.New("неподдерживаемый тип содержимого")
|
||||
ErrUnavailable = errors.New("сервис недоступен")
|
||||
)
|
||||
|
||||
type NotFoundError struct {
|
||||
Entity string
|
||||
ID string
|
||||
}
|
||||
|
||||
func (e *NotFoundError) Error() string {
|
||||
return fmt.Sprintf("%s с id %q не найден", e.Entity, e.ID)
|
||||
}
|
||||
func (e *NotFoundError) Unwrap() error { return ErrNotFound }
|
||||
func (e *NotFoundError) Code() ErrorCode { return CodeNotFound }
|
||||
|
||||
type AlreadyExistsError struct {
|
||||
Entity string
|
||||
Field string
|
||||
Value string
|
||||
}
|
||||
|
||||
func (e *AlreadyExistsError) Error() string {
|
||||
return fmt.Sprintf("%s с %s %q уже существует", e.Entity, e.Field, e.Value)
|
||||
}
|
||||
func (e *AlreadyExistsError) Unwrap() error { return ErrAlreadyExists }
|
||||
func (e *AlreadyExistsError) Code() ErrorCode { return CodeConflict }
|
||||
|
||||
type IdempotencyConflictError struct {
|
||||
Key string
|
||||
}
|
||||
|
||||
func (e *IdempotencyConflictError) Error() string {
|
||||
return "Idempotency-Key " + e.Key + " уже использован с другим телом запроса"
|
||||
}
|
||||
|
||||
func (e *IdempotencyConflictError) Unwrap() error { return ErrAlreadyExists }
|
||||
func (e *IdempotencyConflictError) Code() ErrorCode { return CodeConflict }
|
||||
|
||||
type ValidationError struct {
|
||||
Field string
|
||||
Message string
|
||||
}
|
||||
|
||||
func (e *ValidationError) Error() string {
|
||||
return fmt.Sprintf("ошибка валидации поля %q: %s", e.Field, e.Message)
|
||||
}
|
||||
func (e *ValidationError) Unwrap() error { return ErrInvalidInput }
|
||||
func (e *ValidationError) Code() ErrorCode { return CodeInvalidRequest }
|
||||
|
||||
type UnauthorizedError struct {
|
||||
Reason string // для логов; в JSON не попадает
|
||||
}
|
||||
|
||||
func (e *UnauthorizedError) Error() string {
|
||||
return "требуется аутентификация"
|
||||
}
|
||||
func (e *UnauthorizedError) Unwrap() error { return ErrUnauthorized }
|
||||
func (e *UnauthorizedError) Code() ErrorCode { return CodeUnauthorized }
|
||||
|
||||
type UnsupportedMediaTypeError struct {
|
||||
MediaType string
|
||||
}
|
||||
|
||||
func (e *UnsupportedMediaTypeError) Error() string {
|
||||
if e.MediaType == "" {
|
||||
return "требуется Content-Type: application/json"
|
||||
}
|
||||
return fmt.Sprintf("неподдерживаемый Content-Type %q; требуется application/json", e.MediaType)
|
||||
}
|
||||
func (e *UnsupportedMediaTypeError) Unwrap() error { return ErrUnsupportedMediaType }
|
||||
func (e *UnsupportedMediaTypeError) Code() ErrorCode { return CodeUnsupportedMediaType }
|
||||
|
||||
type UnavailableError struct {
|
||||
Reason string // для логов; в JSON не попадает
|
||||
}
|
||||
|
||||
func (e *UnavailableError) Error() string {
|
||||
return "сервис временно недоступен"
|
||||
}
|
||||
func (e *UnavailableError) Unwrap() error { return ErrUnavailable }
|
||||
func (e *UnavailableError) Code() ErrorCode { return CodeUnavailable }
|
||||
@@ -0,0 +1,23 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
)
|
||||
|
||||
type IdempotencyScope struct {
|
||||
UserID string
|
||||
Method string
|
||||
Path string
|
||||
Key string
|
||||
}
|
||||
|
||||
type CreateIdempotentResult struct {
|
||||
Status int
|
||||
Body []byte
|
||||
Replayed bool
|
||||
}
|
||||
|
||||
func RequestHash(text string) []byte {
|
||||
sum := sha256.Sum256([]byte(text))
|
||||
return sum[:]
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
)
|
||||
|
||||
type UserRepository interface {
|
||||
Create(ctx context.Context, user *User) error
|
||||
GetByID(ctx context.Context, id string) (*User, error)
|
||||
GetByUsername(ctx context.Context, username string) (*User, error)
|
||||
}
|
||||
|
||||
type ChatRepository interface {
|
||||
Create(ctx context.Context, chat *Chat) error
|
||||
GetByID(ctx context.Context, id string) (*Chat, error)
|
||||
ListByMember(ctx context.Context, userID string, limit int, cursor *string) ([]Chat, *string, error)
|
||||
}
|
||||
|
||||
type MessageRepository interface {
|
||||
Create(ctx context.Context, message *Message) error
|
||||
ListByChat(ctx context.Context, chatID string, limit int, cursor *string) ([]Message, *string, error)
|
||||
CreateIdempotent(
|
||||
ctx context.Context,
|
||||
scope IdempotencyScope,
|
||||
requestHash []byte,
|
||||
fresh *Message,
|
||||
freshResponse []byte,
|
||||
ttl time.Duration,
|
||||
) (*CreateIdempotentResult, error)
|
||||
}
|
||||
|
||||
type SessionRepository interface {
|
||||
Create(ctx context.Context, session *Session) error
|
||||
GetByTokenHash(ctx context.Context, tokenHash []byte) (*Session, error)
|
||||
DeleteByTokenHash(ctx context.Context, tokenHash []byte) error
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type CreateChatRequest struct {
|
||||
Title string `json:"title" binding:"required,min=1,max=100"`
|
||||
MemberIDs []string `json:"member_ids" binding:"required,min=1,max=100,dive,uuid"`
|
||||
}
|
||||
|
||||
type ChatResponse struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
MemberIDs []string `json:"member_ids"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type ChatPageResponse struct {
|
||||
Items []ChatResponse `json:"items"`
|
||||
NextCursor *string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
func ChatFromDomain(c *domain.Chat) ChatResponse {
|
||||
return ChatResponse{
|
||||
ID: c.ID,
|
||||
Title: c.Title,
|
||||
MemberIDs: append([]string(nil), c.MemberIDs...),
|
||||
CreatedAt: c.CreatedAt.UTC().Format(timeFormat),
|
||||
}
|
||||
}
|
||||
|
||||
func ChatsFromDomain(items []domain.Chat) []ChatResponse {
|
||||
out := make([]ChatResponse, len(items))
|
||||
for i := range items {
|
||||
out[i] = ChatFromDomain(&items[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
// делаем вложенный ответ через вкладку ErrorBody в обертку.
|
||||
|
||||
type ErrorBody struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
RequestID string `json:"request_id"`
|
||||
}
|
||||
|
||||
type ErrorResponse struct {
|
||||
Error ErrorBody `json:"error"`
|
||||
}
|
||||
|
||||
type coded interface {
|
||||
Code() domain.ErrorCode
|
||||
}
|
||||
|
||||
func ErrorFromDomain(err error, requestID string) ErrorResponse {
|
||||
var c coded
|
||||
if errors.As(err, &c) {
|
||||
code := c.Code()
|
||||
message := err.Error()
|
||||
if code == domain.CodeInternalError {
|
||||
message = "внутренняя ошибка"
|
||||
}
|
||||
return ErrorResponse{Error: ErrorBody{
|
||||
Code: string(code),
|
||||
Message: message,
|
||||
RequestID: requestID,
|
||||
}}
|
||||
}
|
||||
code := domain.CodeInternalError
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrNotFound):
|
||||
code = domain.CodeNotFound
|
||||
case errors.Is(err, domain.ErrAlreadyExists):
|
||||
code = domain.CodeConflict
|
||||
case errors.Is(err, domain.ErrInvalidInput):
|
||||
code = domain.CodeInvalidRequest
|
||||
case errors.Is(err, domain.ErrUnauthorized):
|
||||
code = domain.CodeUnauthorized
|
||||
case errors.Is(err, domain.ErrUnsupportedMediaType):
|
||||
code = domain.CodeUnsupportedMediaType
|
||||
case errors.Is(err, domain.ErrUnavailable):
|
||||
code = domain.CodeUnavailable
|
||||
}
|
||||
message := err.Error()
|
||||
if code == domain.CodeInternalError {
|
||||
message = "внутренняя ошибка"
|
||||
}
|
||||
return ErrorResponse{Error: ErrorBody{
|
||||
Code: string(code),
|
||||
Message: message,
|
||||
RequestID: requestID,
|
||||
}}
|
||||
}
|
||||
|
||||
func StatusFromError(err error) int {
|
||||
switch {
|
||||
case errors.Is(err, domain.ErrNotFound):
|
||||
return 404
|
||||
case errors.Is(err, domain.ErrAlreadyExists):
|
||||
return 409
|
||||
case errors.Is(err, domain.ErrInvalidInput):
|
||||
return 400
|
||||
case errors.Is(err, domain.ErrUnauthorized):
|
||||
return 401
|
||||
case errors.Is(err, domain.ErrUnsupportedMediaType):
|
||||
return 415
|
||||
case errors.Is(err, domain.ErrUnavailable):
|
||||
return 503
|
||||
default:
|
||||
return 500
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dto
|
||||
|
||||
type HealthResponse struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type CreateMessageRequest struct {
|
||||
Text string `json:"text" binding:"required,min=1,max=4000"`
|
||||
AttachmentIDs []string `json:"attachment_ids"`
|
||||
}
|
||||
|
||||
type MessageResponse struct {
|
||||
ID string `json:"id"`
|
||||
ChatID string `json:"chat_id"`
|
||||
SenderID string `json:"sender_id"`
|
||||
Text string `json:"text"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
type MessagePageResponse struct {
|
||||
Items []MessageResponse `json:"items"`
|
||||
NextCursor *string `json:"next_cursor"`
|
||||
}
|
||||
|
||||
func MessageFromDomain(m *domain.Message) MessageResponse {
|
||||
return MessageResponse{
|
||||
ID: m.ID,
|
||||
ChatID: m.ChatID,
|
||||
SenderID: m.SenderID,
|
||||
Text: m.Text,
|
||||
CreatedAt: m.CreatedAt.UTC().Format(timeFormat),
|
||||
}
|
||||
}
|
||||
|
||||
func MessagesFromDomain(items []domain.Message) []MessageResponse {
|
||||
out := make([]MessageResponse, len(items))
|
||||
for i := range items {
|
||||
out[i] = MessageFromDomain(&items[i])
|
||||
}
|
||||
return out
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type SessionResponse struct {
|
||||
Token string `json:"token"`
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresAt string `json:"expires_at"`
|
||||
User UserResponse `json:"user"`
|
||||
}
|
||||
|
||||
func SessionResponseFromDomain(s *domain.Session, token string, u *domain.User) SessionResponse {
|
||||
return SessionResponse{
|
||||
Token: token,
|
||||
TokenType: "Bearer",
|
||||
ExpiresAt: s.ExpiresAt.UTC().Format(timeFormat),
|
||||
User: UserFromDomain(u),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
const timeFormat = "2006-01-02T15:04:05.000000Z07:00"
|
||||
|
||||
type CreateUserRequest struct {
|
||||
Username string `json:"username" binding:"required,min=3,max=32"`
|
||||
DisplayName string `json:"display_name" binding:"required,min=1,max=100"`
|
||||
Password string `json:"password" binding:"required,min=12,max=512"`
|
||||
}
|
||||
|
||||
type UserResponse struct {
|
||||
ID string `json:"id"`
|
||||
Username string `json:"username"`
|
||||
DisplayName string `json:"display_name"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
|
||||
func UserFromDomain(u *domain.User) UserResponse {
|
||||
return UserResponse{
|
||||
ID: u.ID,
|
||||
Username: u.Username,
|
||||
DisplayName: u.DisplayName,
|
||||
CreatedAt: u.CreatedAt.UTC().Format(timeFormat),
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
)
|
||||
|
||||
type AuthHandler struct {
|
||||
sessions *service.SessionService
|
||||
}
|
||||
|
||||
func NewAuthHandler(sessions *service.SessionService) *AuthHandler {
|
||||
return &AuthHandler{sessions: sessions}
|
||||
}
|
||||
|
||||
func (h *AuthHandler) CreateSession(c *gin.Context) {
|
||||
username, password, err := parseBasicAuth(c)
|
||||
if err != nil {
|
||||
respondBasicChallenge(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
session, token, user, err := h.sessions.Login(c.Request.Context(), username, password)
|
||||
if err != nil {
|
||||
respondBasicChallenge(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.JSON(http.StatusCreated, dto.SessionResponseFromDomain(session, token, user))
|
||||
}
|
||||
|
||||
// RevokeCurrent отзывает текущую сессию. Токен уже проверен BearerAuth,
|
||||
// поэтому здесь его достаточно передать в SessionService.
|
||||
func (h *AuthHandler) RevokeCurrent(c *gin.Context) {
|
||||
token := middleware.CurrentToken(c)
|
||||
if token == "" {
|
||||
respondError(c, &domain.UnauthorizedError{Reason: "нет токена"})
|
||||
return
|
||||
}
|
||||
|
||||
if err := h.sessions.Revoke(c.Request.Context(), token); err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.Status(http.StatusNoContent)
|
||||
}
|
||||
|
||||
// parseBasicAuth читает Authorization: Basic base64(username:password).
|
||||
func parseBasicAuth(c *gin.Context) (string, string, error) {
|
||||
const prefix = "Basic "
|
||||
|
||||
auth := c.GetHeader("Authorization")
|
||||
if len(auth) < len(prefix) || !strings.EqualFold(auth[:len(prefix)], prefix) {
|
||||
return "", "", &domain.UnauthorizedError{Reason: "требуется Basic"}
|
||||
}
|
||||
|
||||
decoded, err := base64.StdEncoding.DecodeString(auth[len(prefix):])
|
||||
if err != nil {
|
||||
return "", "", &domain.UnauthorizedError{Reason: "некорректный Base64"}
|
||||
}
|
||||
|
||||
username, password, ok := strings.Cut(string(decoded), ":")
|
||||
if !ok || username == "" {
|
||||
return "", "", &domain.UnauthorizedError{Reason: "некорректный Basic-формат"}
|
||||
}
|
||||
|
||||
return username, password, nil
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"mime"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
func bindStrictJSON(c *gin.Context, dst any) error {
|
||||
ct := c.GetHeader("Content-Type")
|
||||
mediaType, _, err := mime.ParseMediaType(ct)
|
||||
if ct == "" || err != nil || !strings.EqualFold(mediaType, "application/json") {
|
||||
return &domain.UnsupportedMediaTypeError{MediaType: ct}
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
return &badRequestError{msg: "не удалось прочитать тело запроса"}
|
||||
}
|
||||
_ = c.Request.Body.Close()
|
||||
|
||||
dec := json.NewDecoder(bytes.NewReader(body))
|
||||
dec.DisallowUnknownFields()
|
||||
|
||||
if err := dec.Decode(dst); err != nil {
|
||||
if errors.Is(err, io.EOF) {
|
||||
return &badRequestError{msg: "тело запроса обязательно"}
|
||||
}
|
||||
return &badRequestError{msg: err.Error()}
|
||||
}
|
||||
|
||||
// Отклоняем любой непустой остаток после первого JSON-значения.
|
||||
var extra json.RawMessage
|
||||
if err := dec.Decode(&extra); !errors.Is(err, io.EOF) {
|
||||
return &badRequestError{msg: "тело запроса содержит данные после JSON"}
|
||||
}
|
||||
|
||||
if v := binding.Validator; v != nil {
|
||||
if err := v.ValidateStruct(dst); err != nil {
|
||||
return &badRequestError{msg: err.Error()}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
)
|
||||
|
||||
type ChatHandler struct {
|
||||
chats *service.ChatService
|
||||
}
|
||||
|
||||
func NewChatHandler(chats *service.ChatService) *ChatHandler {
|
||||
return &ChatHandler{chats: chats}
|
||||
}
|
||||
|
||||
func (h *ChatHandler) Create(c *gin.Context) {
|
||||
var req dto.CreateChatRequest
|
||||
if err := bindStrictJSON(c, &req); err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
me := middleware.CurrentUser(c)
|
||||
|
||||
chat, err := h.chats.Create(c.Request.Context(), me.ID, req.Title, req.MemberIDs)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, dto.ChatFromDomain(chat))
|
||||
}
|
||||
|
||||
func (h *ChatHandler) Get(c *gin.Context) {
|
||||
me := middleware.CurrentUser(c)
|
||||
|
||||
chatID, err := parseUUIDPathParam(c, "chat_id")
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
chat, err := h.chats.Get(c.Request.Context(), me.ID, chatID)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, dto.ChatFromDomain(chat))
|
||||
}
|
||||
|
||||
func (h *ChatHandler) List(c *gin.Context) {
|
||||
me := middleware.CurrentUser(c)
|
||||
limit, cursor, err := parseListQuery(c)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
items, next, err := h.chats.List(c.Request.Context(), me.ID, limit, cursor)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, dto.ChatPageResponse{
|
||||
Items: dto.ChatsFromDomain(items),
|
||||
NextCursor: next,
|
||||
})
|
||||
}
|
||||
|
||||
func parseListQuery(c *gin.Context) (int, *string, error) {
|
||||
limit := 50
|
||||
if v := c.Query("limit"); v != "" {
|
||||
n, err := strconv.Atoi(v)
|
||||
if err != nil || n < 1 || n > 100 {
|
||||
return 0, nil, &badRequestError{msg: "limit должен быть целым 1..100"}
|
||||
}
|
||||
limit = n
|
||||
}
|
||||
var cursor *string
|
||||
if v := c.Query("cursor"); v != "" {
|
||||
cursor = &v
|
||||
}
|
||||
return limit, cursor, nil
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
)
|
||||
|
||||
type HealthCheck func(ctx context.Context) error
|
||||
|
||||
type HealthHandler struct {
|
||||
checks []HealthCheck
|
||||
ready *atomic.Bool
|
||||
}
|
||||
|
||||
func NewHealthHandler(checks ...HealthCheck) *HealthHandler {
|
||||
return &HealthHandler{checks: checks}
|
||||
}
|
||||
|
||||
func (h *HealthHandler) WithReadyFlag(v *atomic.Bool) *HealthHandler {
|
||||
h.ready = v
|
||||
return h
|
||||
}
|
||||
|
||||
func (h *HealthHandler) Live(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, dto.HealthResponse{Status: "ok"})
|
||||
}
|
||||
|
||||
func (h *HealthHandler) Ready(c *gin.Context) {
|
||||
if h.ready != nil && !h.ready.Load() {
|
||||
respondError(c, &domain.UnavailableError{Reason: "shutting down"})
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), 2*time.Second)
|
||||
defer cancel()
|
||||
|
||||
for _, check := range h.checks {
|
||||
if check == nil {
|
||||
continue
|
||||
}
|
||||
if err := check(ctx); err != nil {
|
||||
respondError(c, &domain.UnavailableError{Reason: "зависимость недоступна"})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusOK, dto.HealthResponse{Status: "ok"})
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"regexp"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
)
|
||||
|
||||
var idempotencyKeyPattern = regexp.MustCompile(`^[A-Za-z0-9._:-]{1,128}$`)
|
||||
|
||||
type MessageHandler struct {
|
||||
messages *service.MessageService
|
||||
}
|
||||
|
||||
func NewMessageHandler(messages *service.MessageService) *MessageHandler {
|
||||
return &MessageHandler{messages: messages}
|
||||
}
|
||||
|
||||
func (h *MessageHandler) Create(c *gin.Context) {
|
||||
var req dto.CreateMessageRequest
|
||||
if err := bindStrictJSON(c, &req); err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
key := c.GetHeader("Idempotency-Key")
|
||||
if key == "" || !idempotencyKeyPattern.MatchString(key) {
|
||||
respondError(c, &badRequestError{
|
||||
msg: "Idempotency-Key обязателен и должен соответствовать ^[A-Za-z0-9._:-]{1,128}$",
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
me := middleware.CurrentUser(c)
|
||||
|
||||
chatID, err := parseUUIDPathParam(c, "chat_id")
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := h.messages.Create(
|
||||
c.Request.Context(),
|
||||
me.ID,
|
||||
chatID,
|
||||
req.Text,
|
||||
key,
|
||||
c.Request.URL.Path,
|
||||
)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.Data(result.Status, "application/json", result.Body)
|
||||
}
|
||||
|
||||
func (h *MessageHandler) List(c *gin.Context) {
|
||||
me := middleware.CurrentUser(c)
|
||||
|
||||
chatID, err := parseUUIDPathParam(c, "chat_id")
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
limit, cursor, err := parseListQuery(c)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
items, next, err := h.messages.List(c.Request.Context(), me.ID, chatID, limit, cursor)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, dto.MessagePageResponse{
|
||||
Items: dto.MessagesFromDomain(items),
|
||||
NextCursor: next,
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
)
|
||||
|
||||
type badRequestError struct{ msg string }
|
||||
|
||||
func (e *badRequestError) Error() string { return e.msg }
|
||||
func (e *badRequestError) Unwrap() error { return domain.ErrInvalidInput }
|
||||
func (e *badRequestError) Code() domain.ErrorCode { return domain.CodeInvalidRequest }
|
||||
|
||||
func parseUUIDPathParam(c *gin.Context, name string) (string, error) {
|
||||
raw := c.Param(name)
|
||||
if raw == "" {
|
||||
return "", &badRequestError{msg: "параметр " + name + " обязателен"}
|
||||
}
|
||||
|
||||
id, err := uuid.Parse(raw)
|
||||
if err != nil {
|
||||
return "", &badRequestError{msg: "параметр " + name + " должен быть корректным UUID"}
|
||||
}
|
||||
|
||||
return id.String(), nil
|
||||
}
|
||||
|
||||
func respondError(c *gin.Context, err error) {
|
||||
reqID := middleware.GetRequestID(c)
|
||||
c.JSON(dto.StatusFromError(err), dto.ErrorFromDomain(err, reqID))
|
||||
}
|
||||
|
||||
// respondBasicChallenge выставляет WWW-Authenticate для 401 на /auth/sessions.
|
||||
// На не-401 ответах заголовок не ставится как по контракту нужно
|
||||
func respondBasicChallenge(c *gin.Context, err error) {
|
||||
if dto.StatusFromError(err) == 401 {
|
||||
c.Header("WWW-Authenticate", `Basic realm="messenger", charset="UTF-8"`)
|
||||
}
|
||||
respondError(c, err)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
)
|
||||
|
||||
type UserHandler struct {
|
||||
users *service.UserService
|
||||
}
|
||||
|
||||
func NewUserHandler(users *service.UserService) *UserHandler {
|
||||
return &UserHandler{users: users}
|
||||
}
|
||||
|
||||
func (h *UserHandler) Create(c *gin.Context) {
|
||||
var req dto.CreateUserRequest
|
||||
if err := bindStrictJSON(c, &req); err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
u, err := h.users.Create(c.Request.Context(), req.Username, req.DisplayName, req.Password)
|
||||
if err != nil {
|
||||
respondError(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusCreated, dto.UserFromDomain(u))
|
||||
}
|
||||
|
||||
func (h *UserHandler) Current(c *gin.Context) {
|
||||
u := middleware.CurrentUser(c)
|
||||
if u == nil {
|
||||
respondError(c, &badRequestError{msg: "нет текущего пользователя"})
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, dto.UserFromDomain(u))
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
)
|
||||
|
||||
func Auth(users domain.UserRepository) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
id := c.GetHeader("X-User-Id")
|
||||
if id == "" {
|
||||
abortUnauthorized(c, "требуется X-User-Id")
|
||||
return
|
||||
}
|
||||
|
||||
u, err := users.GetByID(c.Request.Context(), id)
|
||||
if err != nil {
|
||||
abortUnauthorized(c, "неизвестный пользователь")
|
||||
return
|
||||
}
|
||||
|
||||
c.Set(CurrentUserKey, u)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func abortUnauthorized(c *gin.Context, msg string) {
|
||||
reqID := GetRequestID(c)
|
||||
body := dto.ErrorFromDomain(
|
||||
&domain.UnauthorizedError{Reason: msg},
|
||||
reqID,
|
||||
)
|
||||
c.AbortWithStatusJSON(http.StatusUnauthorized, body)
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
"high-loud-apps-labs/internal/service"
|
||||
)
|
||||
|
||||
const authTimeout = 3 * time.Second
|
||||
|
||||
// BearerAuth читает Authorization: Bearer <token>, проверяет сессию
|
||||
// через SessionService и кладёт пользователя и токен в контекст.
|
||||
func BearerAuth(sessions *service.SessionService) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
token, ok := parseBearerToken(c)
|
||||
if !ok {
|
||||
abortBearer(c, "требуется Bearer")
|
||||
return
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(c.Request.Context(), authTimeout)
|
||||
defer cancel()
|
||||
|
||||
user, err := sessions.Resolve(ctx, token)
|
||||
if err != nil {
|
||||
abortBearerWithErr(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
c.Set(CurrentUserKey, user)
|
||||
c.Set(CurrentTokenKey, token)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
// parseBearerToken читает Authorization: Bearer <opaque-token>.
|
||||
func parseBearerToken(c *gin.Context) (string, bool) {
|
||||
const prefix = "Bearer "
|
||||
auth := c.GetHeader("Authorization")
|
||||
if len(auth) < len(prefix) || !strings.EqualFold(auth[:len(prefix)], prefix) {
|
||||
return "", false
|
||||
}
|
||||
token := strings.TrimSpace(auth[len(prefix):])
|
||||
if token == "" {
|
||||
return "", false
|
||||
}
|
||||
return token, true
|
||||
}
|
||||
|
||||
func abortBearer(c *gin.Context, reason string) {
|
||||
abortBearerWithErr(c, &domain.UnauthorizedError{Reason: reason})
|
||||
}
|
||||
|
||||
// abortBearerWithErr формирует ответ на ошибку аутентификации.
|
||||
// Заголовок WWW-Authenticate: Bearer выставляется только на 401;
|
||||
// при 503 (недоступность БД/кэша) — обычный ответ ошибки без challenge.
|
||||
func abortBearerWithErr(c *gin.Context, err error) {
|
||||
reqID := GetRequestID(c)
|
||||
status := dto.StatusFromError(err)
|
||||
if status == 401 {
|
||||
c.Header("WWW-Authenticate", `Bearer realm="messenger"`)
|
||||
}
|
||||
c.AbortWithStatusJSON(status, dto.ErrorFromDomain(err, reqID))
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
const (
|
||||
CurrentUserKey = "current_user"
|
||||
CurrentTokenKey = "current_token"
|
||||
)
|
||||
|
||||
func CurrentUser(c *gin.Context) *domain.User {
|
||||
if v, ok := c.Get(CurrentUserKey); ok {
|
||||
if u, ok := v.(*domain.User); ok {
|
||||
return u
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CurrentToken(c *gin.Context) string {
|
||||
if v, ok := c.Get(CurrentTokenKey); ok {
|
||||
if s, ok := v.(string); ok {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const InstanceIDHeader = "X-Instance-Id"
|
||||
|
||||
var instanceID = resolveInstanceID()
|
||||
|
||||
func resolveInstanceID() string {
|
||||
if v := os.Getenv("INSTANCE_ID"); v != "" {
|
||||
return v
|
||||
}
|
||||
if v, err := os.Hostname(); err == nil && v != "" {
|
||||
return v
|
||||
}
|
||||
return uuid.NewString()
|
||||
}
|
||||
|
||||
func Instance() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
c.Writer.Header().Set(InstanceIDHeader, instanceID)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func GetInstanceID() string { return instanceID }
|
||||
@@ -0,0 +1,32 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
RequestIDKey = "request_id"
|
||||
RequestIDHeader = "X-Request-Id"
|
||||
)
|
||||
|
||||
func RequestID() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
id := c.GetHeader(RequestIDHeader)
|
||||
if id == "" {
|
||||
id = uuid.NewString()
|
||||
}
|
||||
c.Set(RequestIDKey, id)
|
||||
c.Writer.Header().Set(RequestIDHeader, id)
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
||||
func GetRequestID(c *gin.Context) string {
|
||||
if v, ok := c.Get(RequestIDKey); ok {
|
||||
if s, ok := v.(string); ok {
|
||||
return s
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
"high-loud-apps-labs/internal/httpapi/handler"
|
||||
"high-loud-apps-labs/internal/httpapi/middleware"
|
||||
)
|
||||
|
||||
type Handlers struct {
|
||||
Health *handler.HealthHandler
|
||||
User *handler.UserHandler
|
||||
Chat *handler.ChatHandler
|
||||
Message *handler.MessageHandler
|
||||
Auth *handler.AuthHandler
|
||||
}
|
||||
|
||||
func NewRouter(h Handlers, auth gin.HandlerFunc) *gin.Engine {
|
||||
gin.EnableJsonDecoderDisallowUnknownFields()
|
||||
|
||||
r := gin.New()
|
||||
r.Use(gin.Logger())
|
||||
r.Use(gin.Recovery())
|
||||
r.Use(middleware.RequestID())
|
||||
r.Use(middleware.Instance())
|
||||
|
||||
r.GET("/health/live", h.Health.Live)
|
||||
r.GET("/health/ready", h.Health.Ready)
|
||||
|
||||
api := r.Group("/api/v1")
|
||||
{
|
||||
api.POST("/users", h.User.Create)
|
||||
api.POST("/auth/sessions", h.Auth.CreateSession)
|
||||
}
|
||||
|
||||
protected := api.Group("")
|
||||
protected.Use(auth)
|
||||
{
|
||||
protected.DELETE("/auth/sessions/current", h.Auth.RevokeCurrent)
|
||||
|
||||
protected.GET("/users/me", h.User.Current)
|
||||
protected.POST("/chats", h.Chat.Create)
|
||||
protected.GET("/chats", h.Chat.List)
|
||||
protected.GET("/chats/:chat_id", h.Chat.Get)
|
||||
protected.POST("/chats/:chat_id/messages", h.Message.Create)
|
||||
protected.GET("/chats/:chat_id/messages", h.Message.List)
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type ChatService struct {
|
||||
chats domain.ChatRepository
|
||||
users domain.UserRepository
|
||||
}
|
||||
|
||||
func NewChatService(chats domain.ChatRepository, users domain.UserRepository) *ChatService {
|
||||
return &ChatService{chats: chats, users: users}
|
||||
}
|
||||
|
||||
func (s *ChatService) Create(ctx context.Context, creatorID, title string, memberIDs []string) (*domain.Chat, error) {
|
||||
if strings.TrimSpace(title) == "" {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "title",
|
||||
Message: "не может состоять только из пробелов",
|
||||
}
|
||||
}
|
||||
if utf8.RuneCountInString(title) > 100 {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "title",
|
||||
Message: "не более 100 символов",
|
||||
}
|
||||
}
|
||||
|
||||
seen := make(map[string]struct{}, len(memberIDs))
|
||||
for _, id := range memberIDs {
|
||||
if _, dup := seen[id]; dup {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "member_ids",
|
||||
Message: "дубликаты запрещены",
|
||||
}
|
||||
}
|
||||
seen[id] = struct{}{}
|
||||
}
|
||||
|
||||
if _, ok := seen[creatorID]; !ok {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "member_ids",
|
||||
Message: "создатель должен входить в список участников",
|
||||
}
|
||||
}
|
||||
|
||||
for _, id := range memberIDs {
|
||||
if _, err := s.users.GetByID(ctx, id); err != nil {
|
||||
if errors.Is(err, domain.ErrNotFound) {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "member_ids",
|
||||
Message: "неизвестный участник " + id,
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
c := &domain.Chat{
|
||||
ID: uuid.NewString(),
|
||||
Title: title,
|
||||
MemberIDs: append([]string(nil), memberIDs...),
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
if err := s.chats.Create(ctx, c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (s *ChatService) Get(ctx context.Context, userID, chatID string) (*domain.Chat, error) {
|
||||
c, err := s.chats.GetByID(ctx, chatID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, m := range c.MemberIDs {
|
||||
if m == userID {
|
||||
return c, nil
|
||||
}
|
||||
}
|
||||
return nil, &domain.NotFoundError{Entity: "chat", ID: chatID}
|
||||
}
|
||||
|
||||
func (s *ChatService) List(ctx context.Context, userID string, limit int, cursor *string) ([]domain.Chat, *string, error) {
|
||||
return s.chats.ListByMember(ctx, userID, limit, cursor)
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
"high-loud-apps-labs/internal/httpapi/dto"
|
||||
)
|
||||
|
||||
type MessageService struct {
|
||||
messages domain.MessageRepository
|
||||
chats domain.ChatRepository
|
||||
idempotencyTTL time.Duration
|
||||
}
|
||||
|
||||
func NewMessageService(
|
||||
messages domain.MessageRepository,
|
||||
chats domain.ChatRepository,
|
||||
idempotencyTTL time.Duration,
|
||||
) *MessageService {
|
||||
return &MessageService{
|
||||
messages: messages,
|
||||
chats: chats,
|
||||
idempotencyTTL: idempotencyTTL,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MessageService) Create(ctx context.Context, senderID, chatID, text, idempotencyKey, requestPath string,
|
||||
) (*domain.CreateIdempotentResult, error) {
|
||||
if strings.TrimSpace(text) == "" {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "text",
|
||||
Message: "не может состоять только из пробелов",
|
||||
}
|
||||
}
|
||||
if utf8.RuneCountInString(text) > 4000 {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "text",
|
||||
Message: "не более 4000 символов",
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.ensureMember(ctx, senderID, chatID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fresh := &domain.Message{
|
||||
ID: uuid.NewString(),
|
||||
ChatID: chatID,
|
||||
SenderID: senderID,
|
||||
Text: text,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
|
||||
body, err := json.Marshal(dto.MessageFromDomain(fresh))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return s.messages.CreateIdempotent(
|
||||
ctx,
|
||||
domain.IdempotencyScope{
|
||||
UserID: senderID,
|
||||
Method: http.MethodPost,
|
||||
Path: requestPath,
|
||||
Key: idempotencyKey,
|
||||
},
|
||||
domain.RequestHash(text),
|
||||
fresh,
|
||||
body,
|
||||
s.idempotencyTTL,
|
||||
)
|
||||
}
|
||||
|
||||
func (s *MessageService) List(ctx context.Context, userID, chatID string, limit int, cursor *string) ([]domain.Message, *string, error) {
|
||||
if err := s.ensureMember(ctx, userID, chatID); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
return s.messages.ListByChat(ctx, chatID, limit, cursor)
|
||||
}
|
||||
|
||||
func (s *MessageService) ensureMember(ctx context.Context, userID, chatID string) error {
|
||||
c, err := s.chats.GetByID(ctx, chatID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, m := range c.MemberIDs {
|
||||
if m == userID {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return &domain.NotFoundError{Entity: "chat", ID: chatID}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/subtle"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/crypto/argon2"
|
||||
)
|
||||
|
||||
// PasswordHasher хеширует пароли и проверяет пароль сохранённого хеша.
|
||||
type PasswordHasher interface {
|
||||
Hash(password string) (string, error)
|
||||
Verify(password, encoded string) (bool, error)
|
||||
}
|
||||
|
||||
type Argon2idHasher struct {
|
||||
memory uint32
|
||||
iterations uint32
|
||||
parallelism uint8
|
||||
saltLength uint32
|
||||
keyLength uint32
|
||||
}
|
||||
|
||||
func NewArgon2idHasher() *Argon2idHasher {
|
||||
return &Argon2idHasher{
|
||||
memory: 64 * 1024,
|
||||
iterations: 3,
|
||||
parallelism: 4,
|
||||
saltLength: 16,
|
||||
keyLength: 32,
|
||||
}
|
||||
}
|
||||
|
||||
func (h *Argon2idHasher) Hash(password string) (string, error) {
|
||||
salt := make([]byte, h.saltLength)
|
||||
if _, err := rand.Read(salt); err != nil {
|
||||
return "", fmt.Errorf("генерация соли: %w", err)
|
||||
}
|
||||
|
||||
key := argon2.IDKey(
|
||||
[]byte(password),
|
||||
salt,
|
||||
h.iterations,
|
||||
h.memory,
|
||||
h.parallelism,
|
||||
h.keyLength,
|
||||
)
|
||||
|
||||
return fmt.Sprintf(
|
||||
"$argon2id$v=%d$m=%d,t=%d,p=%d$%s$%s",
|
||||
argon2.Version,
|
||||
h.memory,
|
||||
h.iterations,
|
||||
h.parallelism,
|
||||
base64.RawStdEncoding.EncodeToString(salt),
|
||||
base64.RawStdEncoding.EncodeToString(key),
|
||||
), nil
|
||||
}
|
||||
|
||||
// Verify сравнивает пароль с сохранённым PHC-хешем.
|
||||
// Возвращает false и nil при неверном пароле.
|
||||
// Возвращает false и ошибку, если строка хеша повреждена или несовместима.
|
||||
func (h *Argon2idHasher) Verify(password, encoded string) (bool, error) {
|
||||
parts := strings.Split(encoded, "$")
|
||||
if len(parts) != 6 || parts[1] != "argon2id" {
|
||||
return false, errors.New("некорректный формат хеша")
|
||||
}
|
||||
|
||||
var version int
|
||||
if n, err := fmt.Sscanf(parts[2], "v=%d", &version); err != nil || n != 1 {
|
||||
return false, errors.New("некорректная версия хеша")
|
||||
}
|
||||
if version != argon2.Version {
|
||||
return false, errors.New("неподдерживаемая версия Argon2")
|
||||
}
|
||||
|
||||
var (
|
||||
memory uint32
|
||||
iterations uint32
|
||||
parallelism uint8
|
||||
)
|
||||
if n, err := fmt.Sscanf(parts[3], "m=%d,t=%d,p=%d", &memory, &iterations, ¶llelism); err != nil || n != 3 {
|
||||
return false, errors.New("некорректные параметры хеша")
|
||||
}
|
||||
|
||||
salt, err := base64.RawStdEncoding.DecodeString(parts[4])
|
||||
if err != nil {
|
||||
return false, errors.New("некорректная соль")
|
||||
}
|
||||
|
||||
wantKey, err := base64.RawStdEncoding.DecodeString(parts[5])
|
||||
if err != nil {
|
||||
return false, errors.New("некорректный ключ")
|
||||
}
|
||||
|
||||
gotKey := argon2.IDKey(
|
||||
[]byte(password),
|
||||
salt,
|
||||
iterations,
|
||||
memory,
|
||||
parallelism,
|
||||
uint32(len(wantKey)),
|
||||
)
|
||||
|
||||
return subtle.ConstantTimeCompare(gotKey, wantKey) == 1, nil
|
||||
}
|
||||
|
||||
var _ PasswordHasher = (*Argon2idHasher)(nil)
|
||||
@@ -0,0 +1,127 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
// SessionService отвечает за вход, проверку и отзыв сессий.
|
||||
type SessionService struct {
|
||||
users domain.UserRepository
|
||||
sessions domain.SessionRepository
|
||||
hasher PasswordHasher
|
||||
ttl time.Duration
|
||||
}
|
||||
|
||||
// NewSessionService создаёт сервис с заданным TTL сессий.
|
||||
func NewSessionService(
|
||||
users domain.UserRepository,
|
||||
sessions domain.SessionRepository,
|
||||
hasher PasswordHasher,
|
||||
ttl time.Duration,
|
||||
) *SessionService {
|
||||
return &SessionService{
|
||||
users: users,
|
||||
sessions: sessions,
|
||||
hasher: hasher,
|
||||
ttl: ttl,
|
||||
}
|
||||
}
|
||||
|
||||
// Login проверяет username/password и создаёт новую сессию.
|
||||
// Возвращает сессию, открытый токен и пользователя.
|
||||
// Открытый токен уходит клиенту; в БД сохраняется только его SHA-256.
|
||||
func (s *SessionService) Login(ctx context.Context, username, password string) (*domain.Session, string, *domain.User, error) {
|
||||
user, err := s.users.GetByUsername(ctx, username)
|
||||
if err != nil {
|
||||
if errors.Is(err, domain.ErrNotFound) {
|
||||
return nil, "", nil, &domain.UnauthorizedError{Reason: "неверные учётные данные"}
|
||||
}
|
||||
return nil, "", nil, err
|
||||
}
|
||||
|
||||
ok, err := s.hasher.Verify(password, user.PasswordHash)
|
||||
if err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
if !ok {
|
||||
return nil, "", nil, &domain.UnauthorizedError{Reason: "неверные учётные данные"}
|
||||
}
|
||||
|
||||
token, err := generateToken()
|
||||
if err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
|
||||
tokenHash := sha256.Sum256([]byte(token))
|
||||
now := time.Now().UTC()
|
||||
|
||||
session := &domain.Session{
|
||||
TokenHash: tokenHash[:],
|
||||
UserID: user.ID,
|
||||
ExpiresAt: now.Add(s.ttl),
|
||||
CreatedAt: now,
|
||||
}
|
||||
if err := s.sessions.Create(ctx, session); err != nil {
|
||||
return nil, "", nil, err
|
||||
}
|
||||
|
||||
return session, token, user, nil
|
||||
}
|
||||
|
||||
// Resolve проверяет токен и возвращает пользователя сессии.
|
||||
// Истёкший, отозванный или неизвестный токен - UnauthorizedError по контракту
|
||||
func (s *SessionService) Resolve(ctx context.Context, token string) (*domain.User, error) {
|
||||
if token == "" {
|
||||
return nil, &domain.UnauthorizedError{Reason: "пустой токен"}
|
||||
}
|
||||
|
||||
tokenHash := sha256.Sum256([]byte(token))
|
||||
|
||||
session, err := s.sessions.GetByTokenHash(ctx, tokenHash[:])
|
||||
if err != nil {
|
||||
if errors.Is(err, domain.ErrNotFound) {
|
||||
return nil, &domain.UnauthorizedError{Reason: "неизвестный токен"}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if !session.ExpiresAt.After(time.Now().UTC()) {
|
||||
return nil, &domain.UnauthorizedError{Reason: "сессия истекла"}
|
||||
}
|
||||
|
||||
user, err := s.users.GetByID(ctx, session.UserID)
|
||||
if err != nil {
|
||||
if errors.Is(err, domain.ErrNotFound) {
|
||||
return nil, &domain.UnauthorizedError{Reason: "пользователь сессии не найден"}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
// Revoke удаляет сессию по токену.
|
||||
func (s *SessionService) Revoke(ctx context.Context, token string) error {
|
||||
if token == "" {
|
||||
return nil
|
||||
}
|
||||
tokenHash := sha256.Sum256([]byte(token))
|
||||
return s.sessions.DeleteByTokenHash(ctx, tokenHash[:])
|
||||
}
|
||||
|
||||
// generateToken возвращает 32 случайных байта в base64url без паддинга=.
|
||||
func generateToken() (string, error) {
|
||||
buf := make([]byte, 32)
|
||||
if _, err := rand.Read(buf); err != nil {
|
||||
return "", fmt.Errorf("генерация токена: %w", err)
|
||||
}
|
||||
return base64.RawURLEncoding.EncodeToString(buf), nil
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
var usernamePattern = regexp.MustCompile(`^[a-z0-9_]{3,32}$`)
|
||||
|
||||
type UserService struct {
|
||||
users domain.UserRepository
|
||||
hasher PasswordHasher
|
||||
}
|
||||
|
||||
func NewUserService(users domain.UserRepository, hasher PasswordHasher) *UserService {
|
||||
return &UserService{users: users, hasher: hasher}
|
||||
}
|
||||
|
||||
func (s *UserService) Create(ctx context.Context, username, displayName, password string) (*domain.User, error) {
|
||||
if !usernamePattern.MatchString(username) {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "username",
|
||||
Message: "должен соответствовать ^[a-z0-9_]{3,32}$",
|
||||
}
|
||||
}
|
||||
if strings.TrimSpace(displayName) == "" {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "display_name",
|
||||
Message: "не может состоять только из пробелов",
|
||||
}
|
||||
}
|
||||
if utf8.RuneCountInString(displayName) > 100 {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "display_name",
|
||||
Message: "не более 100 символов",
|
||||
}
|
||||
}
|
||||
|
||||
passwordRunes := utf8.RuneCountInString(password)
|
||||
if passwordRunes < 12 || passwordRunes > 128 {
|
||||
return nil, &domain.ValidationError{
|
||||
Field: "password",
|
||||
Message: "длина 12–128 символов",
|
||||
}
|
||||
}
|
||||
|
||||
hash, err := s.hasher.Hash(password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
u := &domain.User{
|
||||
ID: uuid.NewString(),
|
||||
Username: username,
|
||||
DisplayName: displayName,
|
||||
PasswordHash: hash,
|
||||
CreatedAt: time.Now().UTC(),
|
||||
}
|
||||
if err := s.users.Create(ctx, u); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func (s *UserService) GetByID(ctx context.Context, id string) (*domain.User, error) {
|
||||
return s.users.GetByID(ctx, id)
|
||||
}
|
||||
|
||||
func (s *UserService) GetByUsername(ctx context.Context, username string) (*domain.User, error) {
|
||||
return s.users.GetByUsername(ctx, username)
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
func (r *ChatRepo) Create(ctx context.Context, chat *domain.Chat) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
stored := *chat
|
||||
stored.MemberIDs = append([]string(nil), chat.MemberIDs...)
|
||||
r.chats[chat.ID] = &stored
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ChatRepo) GetByID(ctx context.Context, id string) (*domain.Chat, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
c, ok := r.chats[id]
|
||||
if !ok {
|
||||
return nil, &domain.NotFoundError{Entity: "chat", ID: id}
|
||||
}
|
||||
copy := *c
|
||||
copy.MemberIDs = append([]string(nil), c.MemberIDs...)
|
||||
return ©, nil
|
||||
}
|
||||
|
||||
func (r *ChatRepo) ListByMember(ctx context.Context, userID string, limit int, cursor *string) ([]domain.Chat, *string, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
scope := "chats:" + userID
|
||||
|
||||
all := make([]domain.Chat, 0)
|
||||
for _, c := range r.chats {
|
||||
for _, m := range c.MemberIDs {
|
||||
if m == userID {
|
||||
copy := *c
|
||||
copy.MemberIDs = append([]string(nil), c.MemberIDs...)
|
||||
all = append(all, copy)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
slices.SortFunc(all, func(a, b domain.Chat) int {
|
||||
if lessThan(a.CreatedAt, a.ID, b.CreatedAt, b.ID) {
|
||||
return -1
|
||||
}
|
||||
if lessThan(b.CreatedAt, b.ID, a.CreatedAt, a.ID) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
start := 0
|
||||
if cursor != nil {
|
||||
t, id, err := decodeCursor(*cursor, scope)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
start = len(all)
|
||||
for i, c := range all {
|
||||
if lessThan(t, id, c.CreatedAt, c.ID) {
|
||||
start = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if start >= len(all) {
|
||||
return []domain.Chat{}, nil, nil
|
||||
}
|
||||
end := start + limit
|
||||
if end > len(all) {
|
||||
end = len(all)
|
||||
}
|
||||
page := all[start:end]
|
||||
|
||||
var next *string
|
||||
if end < len(all) {
|
||||
last := page[len(page)-1]
|
||||
c := encodeCursor(scope, last.CreatedAt, last.ID)
|
||||
next = &c
|
||||
}
|
||||
|
||||
return page, next, nil
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
func encodeCursor(scope string, createdAt time.Time, id string) string {
|
||||
raw := scope + "|" + createdAt.UTC().Format(time.RFC3339Nano) + "|" + id
|
||||
return base64.RawURLEncoding.EncodeToString([]byte(raw))
|
||||
}
|
||||
|
||||
func decodeCursor(cursor, expectedScope string) (time.Time, string, error) {
|
||||
data, err := base64.RawURLEncoding.DecodeString(cursor)
|
||||
if err != nil {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
parts := strings.SplitN(string(data), "|", 3)
|
||||
if len(parts) != 3 {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
if parts[0] != expectedScope {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339Nano, parts[1])
|
||||
if err != nil {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
return t, parts[2], nil
|
||||
}
|
||||
|
||||
func badCursor() error {
|
||||
return &domain.ValidationError{
|
||||
Field: "cursor",
|
||||
Message: "некорректный формат",
|
||||
}
|
||||
}
|
||||
|
||||
func lessThan(aTime time.Time, aID string, bTime time.Time, bID string) bool {
|
||||
if aTime.Equal(bTime) {
|
||||
return aID < bID
|
||||
}
|
||||
return aTime.Before(bTime)
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
func (r *MessageRepo) Create(ctx context.Context, message *domain.Message) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
stored := *message
|
||||
r.messages[message.ChatID] = append(r.messages[message.ChatID], stored)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *MessageRepo) ListByChat(ctx context.Context, chatID string, limit int, cursor *string) ([]domain.Message, *string, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
scope := "messages:" + chatID
|
||||
|
||||
var (
|
||||
afterTime time.Time
|
||||
afterID string
|
||||
hasCursor bool
|
||||
)
|
||||
if cursor != nil {
|
||||
t, id, err := decodeCursor(*cursor, scope)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
afterTime = t
|
||||
afterID = id
|
||||
hasCursor = true
|
||||
}
|
||||
|
||||
src := r.messages[chatID]
|
||||
if len(src) == 0 {
|
||||
return []domain.Message{}, nil, nil
|
||||
}
|
||||
|
||||
all := make([]domain.Message, len(src))
|
||||
copy(all, src)
|
||||
|
||||
slices.SortFunc(all, func(a, b domain.Message) int {
|
||||
if lessThan(a.CreatedAt, a.ID, b.CreatedAt, b.ID) {
|
||||
return -1
|
||||
}
|
||||
if lessThan(b.CreatedAt, b.ID, a.CreatedAt, a.ID) {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
})
|
||||
|
||||
start := 0
|
||||
if hasCursor {
|
||||
start = len(all)
|
||||
for i, m := range all {
|
||||
if lessThan(afterTime, afterID, m.CreatedAt, m.ID) {
|
||||
start = i
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if start >= len(all) {
|
||||
return []domain.Message{}, nil, nil
|
||||
}
|
||||
end := start + limit
|
||||
if end > len(all) {
|
||||
end = len(all)
|
||||
}
|
||||
page := all[start:end]
|
||||
|
||||
var next *string
|
||||
if end < len(all) {
|
||||
last := page[len(page)-1]
|
||||
c := encodeCursor(scope, last.CreatedAt, last.ID)
|
||||
next = &c
|
||||
}
|
||||
|
||||
return page, next, nil
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type Storage struct {
|
||||
mu sync.RWMutex
|
||||
users map[string]*domain.User
|
||||
chats map[string]*domain.Chat
|
||||
messages map[string][]domain.Message
|
||||
}
|
||||
|
||||
func New() *Storage {
|
||||
return &Storage{
|
||||
users: make(map[string]*domain.User),
|
||||
chats: make(map[string]*domain.Chat),
|
||||
messages: make(map[string][]domain.Message),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Storage) Users() *UserRepo { return &UserRepo{s} }
|
||||
func (s *Storage) Chats() *ChatRepo { return &ChatRepo{s} }
|
||||
func (s *Storage) Messages() *MessageRepo { return &MessageRepo{s} }
|
||||
|
||||
type UserRepo struct{ *Storage }
|
||||
type ChatRepo struct{ *Storage }
|
||||
type MessageRepo struct{ *Storage }
|
||||
|
||||
var _ domain.UserRepository = (*UserRepo)(nil)
|
||||
var _ domain.ChatRepository = (*ChatRepo)(nil)
|
||||
var _ domain.MessageRepository = (*MessageRepo)(nil)
|
||||
@@ -0,0 +1,59 @@
|
||||
package memory
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
func (r *UserRepo) Create(ctx context.Context, user *domain.User) error {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
for _, u := range r.users {
|
||||
if u.Username == user.Username {
|
||||
return &domain.AlreadyExistsError{
|
||||
Entity: "user",
|
||||
Field: "username",
|
||||
Value: user.Username,
|
||||
}
|
||||
}
|
||||
}
|
||||
stored := *user
|
||||
r.users[user.ID] = &stored
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepo) GetByID(ctx context.Context, id string) (*domain.User, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
u, ok := r.users[id]
|
||||
if !ok {
|
||||
return nil, &domain.NotFoundError{Entity: "user", ID: id}
|
||||
}
|
||||
copy := *u
|
||||
return ©, nil
|
||||
}
|
||||
|
||||
func (r *UserRepo) GetByUsername(ctx context.Context, username string) (*domain.User, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
r.mu.RLock()
|
||||
defer r.mu.RUnlock()
|
||||
|
||||
for _, u := range r.users {
|
||||
if u.Username == username {
|
||||
copy := *u
|
||||
return ©, nil
|
||||
}
|
||||
}
|
||||
return nil, &domain.NotFoundError{Entity: "user", ID: username}
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type ChatRepo struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewChatRepo(pool *pgxpool.Pool) *ChatRepo {
|
||||
return &ChatRepo{pool: pool}
|
||||
}
|
||||
|
||||
// Create атомарно создаёт чат и его участников.
|
||||
func (r *ChatRepo) Create(ctx context.Context, chat *domain.Chat) error {
|
||||
tx, err := r.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return mapError(err)
|
||||
}
|
||||
defer func() { _ = tx.Rollback(ctx) }()
|
||||
|
||||
const qChat = `INSERT INTO chats (id, title, created_at) VALUES ($1::uuid, $2, $3)`
|
||||
if _, err := tx.Exec(ctx, qChat, chat.ID, chat.Title, chat.CreatedAt); err != nil {
|
||||
if checkViolation(err) {
|
||||
return &domain.ValidationError{Field: "chat", Message: "нарушено ограничение целостности"}
|
||||
}
|
||||
return mapError(err)
|
||||
}
|
||||
|
||||
const qMember = `INSERT INTO chat_members (chat_id, user_id) VALUES ($1::uuid, $2::uuid)`
|
||||
for _, uid := range chat.MemberIDs {
|
||||
if _, err := tx.Exec(ctx, qMember, chat.ID, uid); err != nil {
|
||||
if foreignKeyViolation(err) {
|
||||
return &domain.ValidationError{
|
||||
Field: "member_ids",
|
||||
Message: "неизвестный участник " + uid,
|
||||
}
|
||||
}
|
||||
if uniqueViolation(err) {
|
||||
return &domain.ValidationError{
|
||||
Field: "member_ids",
|
||||
Message: "дубликаты запрещены",
|
||||
}
|
||||
}
|
||||
return mapError(err)
|
||||
}
|
||||
}
|
||||
|
||||
return mapError(tx.Commit(ctx))
|
||||
}
|
||||
|
||||
func (r *ChatRepo) GetByID(ctx context.Context, id string) (*domain.Chat, error) {
|
||||
const q = `SELECT id, title, created_at FROM chats WHERE id = $1::uuid`
|
||||
c := &domain.Chat{}
|
||||
err := r.pool.QueryRow(ctx, q, id).Scan(&c.ID, &c.Title, &c.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, notFound(err, "chat", id)
|
||||
}
|
||||
members, err := r.loadMembers(ctx, []string{c.ID})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.MemberIDs = members[c.ID]
|
||||
if c.MemberIDs == nil {
|
||||
c.MemberIDs = []string{}
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
func (r *ChatRepo) ListByMember(ctx context.Context, userID string, limit int, cursor *string) ([]domain.Chat, *string, error) {
|
||||
scope := "chats:" + userID
|
||||
|
||||
var (
|
||||
afterTime time.Time
|
||||
afterID string
|
||||
hasCursor bool
|
||||
)
|
||||
if cursor != nil {
|
||||
t, id, err := decodeCursor(*cursor, scope)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
afterTime = t
|
||||
afterID = id
|
||||
hasCursor = true
|
||||
}
|
||||
|
||||
var (
|
||||
rows pgx.Rows
|
||||
err error
|
||||
)
|
||||
if hasCursor {
|
||||
const q = `
|
||||
SELECT c.id, c.title, c.created_at
|
||||
FROM chats c
|
||||
JOIN chat_members m ON m.chat_id = c.id
|
||||
WHERE m.user_id = $1::uuid
|
||||
AND (c.created_at, c.id) > ($2, $3::uuid)
|
||||
ORDER BY c.created_at, c.id
|
||||
LIMIT $4
|
||||
`
|
||||
rows, err = r.pool.Query(ctx, q, userID, afterTime, afterID, limit+1)
|
||||
} else {
|
||||
const q = `
|
||||
SELECT c.id, c.title, c.created_at
|
||||
FROM chats c
|
||||
JOIN chat_members m ON m.chat_id = c.id
|
||||
WHERE m.user_id = $1::uuid
|
||||
ORDER BY c.created_at, c.id
|
||||
LIMIT $2
|
||||
`
|
||||
rows, err = r.pool.Query(ctx, q, userID, limit+1)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, mapError(err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
page := make([]domain.Chat, 0, limit)
|
||||
for rows.Next() {
|
||||
var c domain.Chat
|
||||
if err := rows.Scan(&c.ID, &c.Title, &c.CreatedAt); err != nil {
|
||||
return nil, nil, mapError(err)
|
||||
}
|
||||
page = append(page, c)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, nil, mapError(err)
|
||||
}
|
||||
|
||||
var next *string
|
||||
if len(page) > limit {
|
||||
page = page[:limit]
|
||||
last := page[len(page)-1]
|
||||
c := encodeCursor(scope, last.CreatedAt, last.ID)
|
||||
next = &c
|
||||
}
|
||||
|
||||
if len(page) > 0 {
|
||||
ids := make([]string, len(page))
|
||||
for i := range page {
|
||||
ids[i] = page[i].ID
|
||||
}
|
||||
members, err := r.loadMembers(ctx, ids)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for i := range page {
|
||||
if m, ok := members[page[i].ID]; ok {
|
||||
page[i].MemberIDs = m
|
||||
} else {
|
||||
page[i].MemberIDs = []string{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return page, next, nil
|
||||
}
|
||||
|
||||
// loadMembers одним запросом собирает участников для указанных чатов.
|
||||
func (r *ChatRepo) loadMembers(ctx context.Context, chatIDs []string) (map[string][]string, error) {
|
||||
if len(chatIDs) == 0 {
|
||||
return map[string][]string{}, nil
|
||||
}
|
||||
const q = `
|
||||
SELECT chat_id, user_id
|
||||
FROM chat_members
|
||||
WHERE chat_id = ANY($1::uuid[])
|
||||
ORDER BY chat_id, user_id
|
||||
`
|
||||
rows, err := r.pool.Query(ctx, q, chatIDs)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
result := make(map[string][]string, len(chatIDs))
|
||||
for rows.Next() {
|
||||
var chatID, userID string
|
||||
if err := rows.Scan(&chatID, &userID); err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
result[chatID] = append(result[chatID], userID)
|
||||
}
|
||||
return result, mapError(rows.Err())
|
||||
}
|
||||
|
||||
var _ domain.ChatRepository = (*ChatRepo)(nil)
|
||||
@@ -0,0 +1,46 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Взял за основу что в inmemery делал
|
||||
func encodeCursor(scope string, createdAt time.Time, id string) string {
|
||||
raw := scope + "|" + createdAt.UTC().Format(time.RFC3339Nano) + "|" + id
|
||||
return base64.RawURLEncoding.EncodeToString([]byte(raw))
|
||||
}
|
||||
|
||||
func decodeCursor(cursor, expectedScope string) (time.Time, string, error) {
|
||||
data, err := base64.RawURLEncoding.DecodeString(cursor)
|
||||
if err != nil {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
parts := strings.SplitN(string(data), "|", 3)
|
||||
if len(parts) != 3 {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
if parts[0] != expectedScope {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
t, err := time.Parse(time.RFC3339Nano, parts[1])
|
||||
if err != nil {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
if _, err := uuid.Parse(parts[2]); err != nil {
|
||||
return time.Time{}, "", badCursor()
|
||||
}
|
||||
return t, parts[2], nil
|
||||
}
|
||||
|
||||
func badCursor() error {
|
||||
return &domain.ValidationError{
|
||||
Field: "cursor",
|
||||
Message: "некорректный формат",
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
"github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/pressly/goose/v3"
|
||||
|
||||
"high-loud-apps-labs/migrations"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
URL string
|
||||
MaxConns int32
|
||||
MinConns int32
|
||||
MaxConnLifetime time.Duration
|
||||
MaxConnIdleTime time.Duration
|
||||
ConnectTimeout time.Duration
|
||||
}
|
||||
|
||||
func Connect(ctx context.Context, cfg Config) (*pgxpool.Pool, error) {
|
||||
if cfg.URL == "" {
|
||||
return nil, fmt.Errorf("DATABASE_URL пустой")
|
||||
}
|
||||
|
||||
poolCfg, err := pgxpool.ParseConfig(cfg.URL)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("разбор DATABASE_URL: %w", err)
|
||||
}
|
||||
if cfg.MaxConns > 0 {
|
||||
poolCfg.MaxConns = cfg.MaxConns
|
||||
}
|
||||
if cfg.MinConns > 0 {
|
||||
poolCfg.MinConns = cfg.MinConns
|
||||
}
|
||||
if cfg.MaxConnLifetime > 0 {
|
||||
poolCfg.MaxConnLifetime = cfg.MaxConnLifetime
|
||||
}
|
||||
if cfg.MaxConnIdleTime > 0 {
|
||||
poolCfg.MaxConnIdleTime = cfg.MaxConnIdleTime
|
||||
}
|
||||
if cfg.ConnectTimeout > 0 {
|
||||
poolCfg.ConnConfig.ConnectTimeout = cfg.ConnectTimeout
|
||||
}
|
||||
poolCfg.HealthCheckPeriod = 10 * time.Second
|
||||
|
||||
pool, err := pgxpool.NewWithConfig(ctx, poolCfg)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("создание пула: %w", err)
|
||||
}
|
||||
|
||||
pingCtx, cancel := context.WithTimeout(ctx, 5*time.Second)
|
||||
defer cancel()
|
||||
if err := pool.Ping(pingCtx); err != nil {
|
||||
pool.Close()
|
||||
return nil, fmt.Errorf("ping БД: %w", err)
|
||||
}
|
||||
return pool, nil
|
||||
}
|
||||
|
||||
func RunMigrations(ctx context.Context, pool *pgxpool.Pool) error {
|
||||
db := stdlib.OpenDBFromPool(pool)
|
||||
|
||||
goose.SetBaseFS(migrations.FS)
|
||||
if err := goose.SetDialect("postgres"); err != nil {
|
||||
return fmt.Errorf("goose dialect: %w", err)
|
||||
}
|
||||
if err := goose.UpContext(ctx, db, "."); err != nil {
|
||||
return fmt.Errorf("применение миграций: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"github.com/jackc/pgerrcode"
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgconn"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type coded interface {
|
||||
Code() domain.ErrorCode
|
||||
}
|
||||
|
||||
// mapError переводит ошибки драйвера в доменные.
|
||||
func mapError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
var c coded
|
||||
if errors.As(err, &c) {
|
||||
return err
|
||||
}
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return err
|
||||
}
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return &domain.UnavailableError{Reason: "превышено время ожидания БД"}
|
||||
}
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return &domain.UnavailableError{Reason: "запрос отменён"}
|
||||
}
|
||||
return &domain.UnavailableError{Reason: err.Error()}
|
||||
}
|
||||
|
||||
func notFound(err error, entity, id string) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, pgx.ErrNoRows) {
|
||||
return &domain.NotFoundError{Entity: entity, ID: id}
|
||||
}
|
||||
return mapError(err)
|
||||
}
|
||||
|
||||
func uniqueViolation(err error) bool {
|
||||
var pgErr *pgconn.PgError
|
||||
if errors.As(err, &pgErr) {
|
||||
return pgErr.Code == pgerrcode.UniqueViolation
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func foreignKeyViolation(err error) bool {
|
||||
var pgErr *pgconn.PgError
|
||||
if errors.As(err, &pgErr) {
|
||||
return pgErr.Code == pgerrcode.ForeignKeyViolation
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func checkViolation(err error) bool {
|
||||
var pgErr *pgconn.PgError
|
||||
if errors.As(err, &pgErr) {
|
||||
return pgErr.Code == pgerrcode.CheckViolation
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -0,0 +1,203 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/jackc/pgx/v5"
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type MessageRepo struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewMessageRepo(pool *pgxpool.Pool) *MessageRepo {
|
||||
return &MessageRepo{pool: pool}
|
||||
}
|
||||
|
||||
func (r *MessageRepo) Create(ctx context.Context, m *domain.Message) error {
|
||||
const q = `
|
||||
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
|
||||
VALUES ($1::uuid, $2::uuid, $3::uuid, $4, $5)
|
||||
`
|
||||
_, err := r.pool.Exec(ctx, q, m.ID, m.ChatID, m.SenderID, m.Text, m.CreatedAt)
|
||||
if err != nil {
|
||||
if foreignKeyViolation(err) {
|
||||
return &domain.NotFoundError{Entity: "chat", ID: m.ChatID}
|
||||
}
|
||||
if checkViolation(err) {
|
||||
return &domain.ValidationError{Field: "text", Message: "нарушено ограничение"}
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (r *MessageRepo) CreateIdempotent(
|
||||
ctx context.Context,
|
||||
scope domain.IdempotencyScope,
|
||||
requestHash []byte,
|
||||
fresh *domain.Message,
|
||||
freshResponse []byte,
|
||||
ttl time.Duration,
|
||||
) (*domain.CreateIdempotentResult, error) {
|
||||
tx, err := r.pool.Begin(ctx)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
defer func() { _ = tx.Rollback(ctx) }()
|
||||
|
||||
// 1) Убираем просроченную запись, чтобы ON CONFLICT сработал
|
||||
// только на живой, а не на истёкшей строке.
|
||||
if _, err := tx.Exec(ctx, `
|
||||
DELETE FROM idempotency_keys
|
||||
WHERE user_id = $1::uuid AND method = $2 AND path = $3 AND key = $4
|
||||
AND expires_at <= now()
|
||||
`, scope.UserID, scope.Method, scope.Path, scope.Key); err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
// 2) Резервируем слот. Если параллельная реплика уже вставила —
|
||||
// Postgres заблокирует конфликтный INSERT и мы увидим RowsAffected=0
|
||||
// только после того, как конкурент закоммитит или откатится.
|
||||
expiresAt := time.Now().UTC().Add(ttl)
|
||||
tag, err := tx.Exec(ctx, `
|
||||
INSERT INTO idempotency_keys
|
||||
(user_id, method, path, key, request_hash, response_status, response_body, expires_at)
|
||||
VALUES ($1::uuid, $2, $3, $4, $5, $6, $7, $8)
|
||||
ON CONFLICT (user_id, method, path, key) DO NOTHING
|
||||
`, scope.UserID, scope.Method, scope.Path, scope.Key,
|
||||
requestHash, http.StatusCreated, freshResponse, expiresAt)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
// 3) Слот занят — читаем сохранённый ответ в этой же транзакции.
|
||||
if tag.RowsAffected() == 0 {
|
||||
var (
|
||||
storedHash []byte
|
||||
storedStatus int
|
||||
storedBody []byte
|
||||
)
|
||||
err := tx.QueryRow(ctx, `
|
||||
SELECT request_hash, response_status, response_body
|
||||
FROM idempotency_keys
|
||||
WHERE user_id = $1::uuid AND method = $2 AND path = $3 AND key = $4
|
||||
`, scope.UserID, scope.Method, scope.Path, scope.Key).
|
||||
Scan(&storedHash, &storedStatus, &storedBody)
|
||||
if err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
if !bytes.Equal(storedHash, requestHash) {
|
||||
return nil, &domain.IdempotencyConflictError{Key: scope.Key}
|
||||
}
|
||||
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
return &domain.CreateIdempotentResult{
|
||||
Status: storedStatus,
|
||||
Body: storedBody,
|
||||
Replayed: true,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// 4) Слот наш — вставляем сообщение в той же транзакции.
|
||||
if _, err := tx.Exec(ctx, `
|
||||
INSERT INTO messages (id, chat_id, sender_id, text, created_at)
|
||||
VALUES ($1::uuid, $2::uuid, $3::uuid, $4, $5)
|
||||
`, fresh.ID, fresh.ChatID, fresh.SenderID, fresh.Text, fresh.CreatedAt); err != nil {
|
||||
if foreignKeyViolation(err) {
|
||||
return nil, &domain.NotFoundError{Entity: "chat", ID: fresh.ChatID}
|
||||
}
|
||||
if checkViolation(err) {
|
||||
return nil, &domain.ValidationError{Field: "text", Message: "нарушено ограничение"}
|
||||
}
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
if err := tx.Commit(ctx); err != nil {
|
||||
return nil, mapError(err)
|
||||
}
|
||||
return &domain.CreateIdempotentResult{
|
||||
Status: http.StatusCreated,
|
||||
Body: freshResponse,
|
||||
Replayed: false,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *MessageRepo) ListByChat(ctx context.Context, chatID string, limit int, cursor *string) ([]domain.Message, *string, error) {
|
||||
scope := "messages:" + chatID
|
||||
|
||||
var (
|
||||
afterTime time.Time
|
||||
afterID string
|
||||
hasCursor bool
|
||||
)
|
||||
if cursor != nil {
|
||||
t, id, err := decodeCursor(*cursor, scope)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
afterTime = t
|
||||
afterID = id
|
||||
hasCursor = true
|
||||
}
|
||||
|
||||
var (
|
||||
rows pgx.Rows
|
||||
err error
|
||||
)
|
||||
if hasCursor {
|
||||
const q = `
|
||||
SELECT id, chat_id, sender_id, text, created_at
|
||||
FROM messages
|
||||
WHERE chat_id = $1::uuid
|
||||
AND (created_at, id) > ($2, $3::uuid)
|
||||
ORDER BY created_at, id
|
||||
LIMIT $4
|
||||
`
|
||||
rows, err = r.pool.Query(ctx, q, chatID, afterTime, afterID, limit+1)
|
||||
} else {
|
||||
const q = `
|
||||
SELECT id, chat_id, sender_id, text, created_at
|
||||
FROM messages
|
||||
WHERE chat_id = $1::uuid
|
||||
ORDER BY created_at, id
|
||||
LIMIT $2
|
||||
`
|
||||
rows, err = r.pool.Query(ctx, q, chatID, limit+1)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
page := make([]domain.Message, 0, limit)
|
||||
for rows.Next() {
|
||||
var m domain.Message
|
||||
if err := rows.Scan(&m.ID, &m.ChatID, &m.SenderID, &m.Text, &m.CreatedAt); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
page = append(page, m)
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
var next *string
|
||||
if len(page) > limit {
|
||||
page = page[:limit]
|
||||
last := page[len(page)-1]
|
||||
c := encodeCursor(scope, last.CreatedAt, last.ID)
|
||||
next = &c
|
||||
}
|
||||
return page, next, nil
|
||||
}
|
||||
|
||||
var _ domain.MessageRepository = (*MessageRepo)(nil)
|
||||
@@ -0,0 +1,59 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type SessionRepo struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewSessionRepo(pool *pgxpool.Pool) *SessionRepo {
|
||||
return &SessionRepo{pool: pool}
|
||||
}
|
||||
|
||||
func (r *SessionRepo) Create(ctx context.Context, s *domain.Session) error {
|
||||
const q = `
|
||||
INSERT INTO sessions (token_hash, user_id, expires_at, created_at)
|
||||
VALUES ($1, $2::uuid, $3, $4)
|
||||
`
|
||||
_, err := r.pool.Exec(ctx, q, s.TokenHash, s.UserID, s.ExpiresAt, s.CreatedAt)
|
||||
if err != nil {
|
||||
if uniqueViolation(err) {
|
||||
return &domain.AlreadyExistsError{
|
||||
Entity: "session",
|
||||
Field: "token_hash",
|
||||
Value: "",
|
||||
}
|
||||
}
|
||||
return mapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *SessionRepo) GetByTokenHash(ctx context.Context, tokenHash []byte) (*domain.Session, error) {
|
||||
const q = `
|
||||
SELECT token_hash, user_id, expires_at, created_at
|
||||
FROM sessions
|
||||
WHERE token_hash = $1
|
||||
`
|
||||
s := &domain.Session{}
|
||||
err := r.pool.QueryRow(ctx, q, tokenHash).
|
||||
Scan(&s.TokenHash, &s.UserID, &s.ExpiresAt, &s.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, notFound(err, "session", "")
|
||||
}
|
||||
return s, nil
|
||||
}
|
||||
|
||||
func (r *SessionRepo) DeleteByTokenHash(ctx context.Context, tokenHash []byte) error {
|
||||
const q = `DELETE FROM sessions WHERE token_hash = $1`
|
||||
_, err := r.pool.Exec(ctx, q, tokenHash)
|
||||
return mapError(err)
|
||||
}
|
||||
|
||||
var _ domain.SessionRepository = (*SessionRepo)(nil)
|
||||
@@ -0,0 +1,18 @@
|
||||
package postgres
|
||||
|
||||
import "github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
type Storage struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func New(pool *pgxpool.Pool) *Storage {
|
||||
return &Storage{pool: pool}
|
||||
}
|
||||
|
||||
func (s *Storage) Pool() *pgxpool.Pool { return s.pool }
|
||||
|
||||
func (s *Storage) Users() *UserRepo { return &UserRepo{pool: s.pool} }
|
||||
func (s *Storage) Chats() *ChatRepo { return &ChatRepo{pool: s.pool} }
|
||||
func (s *Storage) Messages() *MessageRepo { return &MessageRepo{pool: s.pool} }
|
||||
func (s *Storage) Sessions() *SessionRepo { return &SessionRepo{pool: s.pool} }
|
||||
@@ -0,0 +1,76 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgxpool"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type UserRepo struct {
|
||||
pool *pgxpool.Pool
|
||||
}
|
||||
|
||||
func NewUserRepo(pool *pgxpool.Pool) *UserRepo {
|
||||
return &UserRepo{pool: pool}
|
||||
}
|
||||
|
||||
func (r *UserRepo) Create(ctx context.Context, user *domain.User) error {
|
||||
const q = `
|
||||
INSERT INTO users (id, username, display_name, password_hash, created_at)
|
||||
VALUES ($1::uuid, $2, $3, $4, $5)
|
||||
`
|
||||
_, err := r.pool.Exec(ctx, q,
|
||||
user.ID, user.Username, user.DisplayName, user.PasswordHash, user.CreatedAt,
|
||||
)
|
||||
if err != nil {
|
||||
if uniqueViolation(err) {
|
||||
return &domain.AlreadyExistsError{
|
||||
Entity: "user",
|
||||
Field: "username",
|
||||
Value: user.Username,
|
||||
}
|
||||
}
|
||||
if checkViolation(err) {
|
||||
return &domain.ValidationError{
|
||||
Field: "user",
|
||||
Message: "нарушено ограничение целостности",
|
||||
}
|
||||
}
|
||||
return mapError(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *UserRepo) GetByID(ctx context.Context, id string) (*domain.User, error) {
|
||||
const q = `
|
||||
SELECT id, username, display_name, password_hash, created_at
|
||||
FROM users
|
||||
WHERE id = $1::uuid
|
||||
`
|
||||
u := &domain.User{}
|
||||
err := r.pool.QueryRow(ctx, q, id).
|
||||
Scan(&u.ID, &u.Username, &u.DisplayName, &u.PasswordHash, &u.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, notFound(err, "user", id)
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
func (r *UserRepo) GetByUsername(ctx context.Context, username string) (*domain.User, error) {
|
||||
const q = `
|
||||
SELECT id, username, display_name, password_hash, created_at
|
||||
FROM users
|
||||
WHERE username = $1
|
||||
`
|
||||
u := &domain.User{}
|
||||
err := r.pool.QueryRow(ctx, q, username).
|
||||
Scan(&u.ID, &u.Username, &u.DisplayName, &u.PasswordHash, &u.CreatedAt)
|
||||
if err != nil {
|
||||
return nil, notFound(err, "user", username)
|
||||
}
|
||||
return u, nil
|
||||
}
|
||||
|
||||
var _ domain.UserRepository = (*UserRepo)(nil)
|
||||
@@ -0,0 +1,33 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
func NewClient(url string) (*redis.Client, error) {
|
||||
opt, err := redis.ParseURL(url)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("разбор URL: %w", err)
|
||||
}
|
||||
|
||||
opt.DialTimeout = 700 * time.Millisecond
|
||||
opt.ReadTimeout = 700 * time.Millisecond
|
||||
opt.WriteTimeout = 700 * time.Millisecond
|
||||
opt.MaxRetries = 1
|
||||
opt.PoolSize = 10
|
||||
opt.ConnMaxIdleTime = time.Minute
|
||||
|
||||
client := redis.NewClient(opt)
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
defer cancel()
|
||||
if err := client.Ping(ctx).Err(); err != nil {
|
||||
_ = client.Close()
|
||||
return nil, fmt.Errorf("ping: %w", err)
|
||||
}
|
||||
return client, nil
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
type coded interface {
|
||||
Code() domain.ErrorCode
|
||||
}
|
||||
|
||||
// mapError переводит ошибки драйвера в доменные.
|
||||
// Любая недоступность redis (dial/read/write/context) → UnavailableError (503).
|
||||
func mapError(err error) error {
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
var c coded
|
||||
if errors.As(err, &c) {
|
||||
return err
|
||||
}
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
return &domain.UnavailableError{Reason: "превышено время ожидания redis"}
|
||||
}
|
||||
if errors.Is(err, context.Canceled) {
|
||||
return &domain.UnavailableError{Reason: "запрос отменён"}
|
||||
}
|
||||
return &domain.UnavailableError{Reason: err.Error()}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package redis
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
|
||||
"high-loud-apps-labs/internal/domain"
|
||||
)
|
||||
|
||||
const sessionKeyPrefix = "session:"
|
||||
|
||||
type SessionRepo struct {
|
||||
client *redis.Client
|
||||
}
|
||||
|
||||
func NewSessionRepo(client *redis.Client) *SessionRepo {
|
||||
return &SessionRepo{client: client}
|
||||
}
|
||||
|
||||
type sessionValue struct {
|
||||
UserID string `json:"user_id"`
|
||||
ExpiresAt time.Time `json:"expires_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
func (r *SessionRepo) key(tokenHash []byte) string {
|
||||
return sessionKeyPrefix + hex.EncodeToString(tokenHash)
|
||||
}
|
||||
|
||||
func (r *SessionRepo) Create(ctx context.Context, s *domain.Session) error {
|
||||
ttl := time.Until(s.ExpiresAt)
|
||||
if ttl <= 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := json.Marshal(sessionValue{
|
||||
UserID: s.UserID,
|
||||
ExpiresAt: s.ExpiresAt.UTC(),
|
||||
CreatedAt: s.CreatedAt.UTC(),
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("сериализация сессии: %w", err)
|
||||
}
|
||||
|
||||
return mapError(r.client.Set(ctx, r.key(s.TokenHash), data, ttl).Err())
|
||||
}
|
||||
|
||||
func (r *SessionRepo) GetByTokenHash(ctx context.Context, tokenHash []byte) (*domain.Session, error) {
|
||||
data, err := r.client.Get(ctx, r.key(tokenHash)).Bytes()
|
||||
if err != nil {
|
||||
if errors.Is(err, redis.Nil) {
|
||||
return nil, &domain.NotFoundError{Entity: "session"}
|
||||
}
|
||||
return nil, mapError(err)
|
||||
}
|
||||
|
||||
var sv sessionValue
|
||||
if err := json.Unmarshal(data, &sv); err != nil {
|
||||
return nil, fmt.Errorf("разбор сессии: %w", err)
|
||||
}
|
||||
|
||||
return &domain.Session{
|
||||
TokenHash: tokenHash,
|
||||
UserID: sv.UserID,
|
||||
ExpiresAt: sv.ExpiresAt,
|
||||
CreatedAt: sv.CreatedAt,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (r *SessionRepo) DeleteByTokenHash(ctx context.Context, tokenHash []byte) error {
|
||||
return mapError(r.client.Del(ctx, r.key(tokenHash)).Err())
|
||||
}
|
||||
|
||||
var _ domain.SessionRepository = (*SessionRepo)(nil)
|
||||
@@ -0,0 +1,67 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE users (
|
||||
id UUID PRIMARY KEY,
|
||||
username TEXT NOT NULL,
|
||||
display_name TEXT NOT NULL,
|
||||
password_hash TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT users_username_format
|
||||
CHECK (username ~ '^[a-z0-9_]{3,32}$'),
|
||||
CONSTRAINT users_display_name_not_blank
|
||||
CHECK (display_name !~ '^[[:space:]]*$'),
|
||||
CONSTRAINT users_display_name_len
|
||||
CHECK (char_length(display_name) <= 100),
|
||||
CONSTRAINT users_password_hash_not_blank
|
||||
CHECK (length(password_hash) > 0)
|
||||
);
|
||||
CREATE UNIQUE INDEX users_username_uniq ON users (username);
|
||||
|
||||
CREATE TABLE chats (
|
||||
id UUID PRIMARY KEY,
|
||||
title TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT chats_title_not_blank CHECK (title !~ '^[[:space:]]*$'),
|
||||
CONSTRAINT chats_title_len CHECK (char_length(title) <= 100)
|
||||
);
|
||||
CREATE INDEX chats_created_id_idx ON chats (created_at, id);
|
||||
|
||||
CREATE TABLE chat_members (
|
||||
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
||||
joined_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (chat_id, user_id)
|
||||
);
|
||||
CREATE INDEX chat_members_user_idx ON chat_members (user_id, chat_id);
|
||||
|
||||
CREATE TABLE messages (
|
||||
id UUID PRIMARY KEY,
|
||||
chat_id UUID NOT NULL REFERENCES chats(id) ON DELETE CASCADE,
|
||||
sender_id UUID NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
||||
text TEXT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT messages_text_not_blank CHECK (text !~ '^[[:space:]]*$'),
|
||||
CONSTRAINT messages_text_len CHECK (char_length(text) <= 4000)
|
||||
);
|
||||
CREATE INDEX messages_chat_created_id_idx
|
||||
ON messages (chat_id, created_at, id);
|
||||
|
||||
CREATE TABLE sessions (
|
||||
token_hash BYTEA PRIMARY KEY,
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
CONSTRAINT sessions_token_hash_len CHECK (octet_length(token_hash) = 32)
|
||||
);
|
||||
CREATE INDEX sessions_user_idx ON sessions (user_id);
|
||||
CREATE INDEX sessions_expires_idx ON sessions (expires_at);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS sessions;
|
||||
DROP TABLE IF EXISTS messages;
|
||||
DROP TABLE IF EXISTS chat_members;
|
||||
DROP TABLE IF EXISTS chats;
|
||||
DROP TABLE IF EXISTS users;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,35 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
CREATE TABLE idempotency_keys (
|
||||
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
method TEXT NOT NULL,
|
||||
path TEXT NOT NULL,
|
||||
key TEXT NOT NULL,
|
||||
request_hash BYTEA NOT NULL,
|
||||
response_status INT NOT NULL,
|
||||
response_body BYTEA NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
expires_at TIMESTAMPTZ NOT NULL,
|
||||
|
||||
CONSTRAINT idempotency_keys_pkey
|
||||
PRIMARY KEY (user_id, method, path, key),
|
||||
CONSTRAINT idempotency_keys_key_len
|
||||
CHECK (char_length(key) BETWEEN 1 AND 128),
|
||||
CONSTRAINT idempotency_keys_method_len
|
||||
CHECK (char_length(method) BETWEEN 1 AND 16),
|
||||
CONSTRAINT idempotency_keys_path_len
|
||||
CHECK (char_length(path) BETWEEN 1 AND 2048),
|
||||
CONSTRAINT idempotency_keys_hash_len
|
||||
CHECK (octet_length(request_hash) = 32),
|
||||
CONSTRAINT idempotency_keys_status_range
|
||||
CHECK (response_status BETWEEN 100 AND 599)
|
||||
);
|
||||
|
||||
CREATE INDEX idempotency_keys_expires_idx
|
||||
ON idempotency_keys (expires_at);
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
DROP TABLE IF EXISTS idempotency_keys;
|
||||
-- +goose StatementEnd
|
||||
@@ -0,0 +1,6 @@
|
||||
package migrations
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed *.sql
|
||||
var FS embed.FS
|
||||
+163
@@ -0,0 +1,163 @@
|
||||
name: mtusi-messenger-lab3
|
||||
|
||||
x-api-resources: &api-resources
|
||||
limits:
|
||||
cpus: "${API_CPUS:-0.5}"
|
||||
memory: "${API_MEMORY:-256M}"
|
||||
reservations:
|
||||
cpus: "${API_CPU_RESERVATION:-0.1}"
|
||||
memory: "${API_MEMORY_RESERVATION:-64M}"
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:16.4-alpine
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: messenger
|
||||
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
||||
POSTGRES_DB: messenger
|
||||
secrets:
|
||||
- postgres_password
|
||||
volumes:
|
||||
- postgres_data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${POSTGRES_CPUS:-1.0}"
|
||||
memory: ${POSTGRES_MEMORY:-1G}
|
||||
reservations:
|
||||
cpus: "${POSTGRES_CPU_RESERVATION:-0.25}"
|
||||
memory: ${POSTGRES_MEMORY_RESERVATION:-256M}
|
||||
networks:
|
||||
- internal
|
||||
|
||||
redis:
|
||||
image: redis:7.4-alpine
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- redis-server
|
||||
- --appendonly
|
||||
- "yes"
|
||||
- --appendfsync
|
||||
- everysec
|
||||
- --save
|
||||
- "60 1000"
|
||||
volumes:
|
||||
- redis_data:/data
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 10
|
||||
start_period: 5s
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "${REDIS_CPUS:-0.5}"
|
||||
memory: ${REDIS_MEMORY:-256M}
|
||||
networks:
|
||||
- internal
|
||||
|
||||
migrate:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger-api:lab3
|
||||
restart: "no"
|
||||
command: ["migrate"]
|
||||
environment:
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
secrets:
|
||||
- database_url
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
healthcheck:
|
||||
disable: true
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128M
|
||||
networks:
|
||||
- internal
|
||||
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: mtusi-messenger-api:lab3
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
APP_HOST: "0.0.0.0"
|
||||
APP_PORT: "8080"
|
||||
DATABASE_URL_FILE: /run/secrets/database_url
|
||||
CACHE_URL_FILE: /run/secrets/cache_url
|
||||
SESSION_STORE: "redis"
|
||||
SESSION_TTL_SECONDS: "${SESSION_TTL_SECONDS:-3600}"
|
||||
IDEMPOTENCY_TTL_SECONDS: "${IDEMPOTENCY_TTL_SECONDS:-86400}"
|
||||
SHUTDOWN_DRAIN_SECONDS: "${SHUTDOWN_DRAIN_SECONDS:-3}"
|
||||
GIN_MODE: "release"
|
||||
secrets:
|
||||
- database_url
|
||||
- cache_url
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
redis:
|
||||
condition: service_healthy
|
||||
migrate:
|
||||
condition: service_completed_successfully
|
||||
expose:
|
||||
- "8080"
|
||||
stop_grace_period: 15s
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
start_period: 10s
|
||||
deploy:
|
||||
replicas: ${API_REPLICAS:-2}
|
||||
resources: *api-resources
|
||||
networks:
|
||||
- internal
|
||||
|
||||
lb:
|
||||
image: nginx:1.27.4-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${LB_PORT:-8080}:8080"
|
||||
volumes:
|
||||
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
depends_on:
|
||||
api:
|
||||
condition: service_started
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
cpus: "0.5"
|
||||
memory: 128M
|
||||
networks:
|
||||
- internal
|
||||
secrets:
|
||||
postgres_password:
|
||||
file: ./secrets/postgres_password
|
||||
database_url:
|
||||
file: ./secrets/database_url
|
||||
cache_url:
|
||||
file: ./secrets/cache_url
|
||||
|
||||
volumes:
|
||||
postgres_data:
|
||||
redis_data:
|
||||
|
||||
networks:
|
||||
internal:
|
||||
driver: bridge
|
||||
@@ -0,0 +1,6 @@
|
||||
NAME CPU % MEM USAGE / LIMIT MEM %
|
||||
mtusi-messenger-lab3-lb-1 0.00% 9.191MiB / 7.691GiB 0.12%
|
||||
mtusi-messenger-lab3-api-2 0.00% 4.625MiB / 256MiB 1.81%
|
||||
mtusi-messenger-lab3-api-1 0.50% 136.1MiB / 256MiB 53.17%
|
||||
mtusi-messenger-lab3-postgres-1 0.00% 31.16MiB / 1GiB 3.04%
|
||||
mtusi-messenger-lab3-redis-1 0.34% 5.816MiB / 256MiB 2.27%
|
||||
@@ -0,0 +1,143 @@
|
||||
1791539348 kill
|
||||
1791539349 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539349 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539349 exec_die
|
||||
1791539351 stop
|
||||
1791539351 die
|
||||
1791539394 start
|
||||
1791539402 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539402 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539402 exec_die
|
||||
1791539402 health_status: healthy
|
||||
1791539407 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539407 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539407 exec_die
|
||||
1791539412 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539412 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539412 exec_die
|
||||
1791539417 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539417 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539417 exec_die
|
||||
1791539422 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539422 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539422 exec_die
|
||||
1791539427 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539427 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539427 exec_die
|
||||
1791539435 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539435 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539435 exec_die
|
||||
1791539440 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539440 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539440 exec_die
|
||||
1791539445 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539445 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539445 exec_die
|
||||
1791539450 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539450 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539450 exec_die
|
||||
1791539455 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539455 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539455 exec_die
|
||||
1791539460 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539460 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539460 exec_die
|
||||
1791539468 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539468 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539468 exec_die
|
||||
1791539473 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539473 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539473 exec_die
|
||||
1791539478 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539478 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539478 exec_die
|
||||
1791539483 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539483 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539483 exec_die
|
||||
1791539488 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539488 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539488 exec_die
|
||||
1791539493 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539493 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539493 exec_die
|
||||
1791539501 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539501 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539501 exec_die
|
||||
1791539506 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539506 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539506 exec_die
|
||||
1791539511 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539511 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539511 exec_die
|
||||
1791539516 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539516 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539516 exec_die
|
||||
1791539521 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539521 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539521 exec_die
|
||||
1791539526 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539526 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539526 exec_die
|
||||
1791539534 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539534 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539534 exec_die
|
||||
1791539539 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539539 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539539 exec_die
|
||||
1791539544 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539544 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539544 exec_die
|
||||
1791539549 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539549 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539549 exec_die
|
||||
1791539554 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539554 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539554 exec_die
|
||||
1791539562 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539562 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539562 exec_die
|
||||
1791539567 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539567 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539567 exec_die
|
||||
1791539572 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539572 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539572 exec_die
|
||||
1791539577 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539577 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539577 exec_die
|
||||
1791539582 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539582 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539582 exec_die
|
||||
1791539587 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539587 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539587 exec_die
|
||||
1791539595 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539595 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539595 exec_die
|
||||
1791539600 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539600 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539600 exec_die
|
||||
1791539605 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539605 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539605 exec_die
|
||||
1791539610 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539610 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539610 exec_die
|
||||
1791539615 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539615 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539615 exec_die
|
||||
1791539620 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539620 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539620 exec_die
|
||||
1791539628 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539628 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539628 exec_die
|
||||
1791539633 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539633 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539633 exec_die
|
||||
1791539638 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539638 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539638 exec_die
|
||||
1791539643 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539643 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539643 exec_die
|
||||
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"avg": 46.472133111480815,
|
||||
"min": 3.3973,
|
||||
"med": 4.8097,
|
||||
"max": 2191.8273,
|
||||
"p(90)": 6.073320000000001,
|
||||
"p(95)": 6.78405
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.01139467554076539,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0806,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 1803,
|
||||
"value": 0
|
||||
},
|
||||
"checks": {
|
||||
"passes": 3600,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"vus": {
|
||||
"max": 31,
|
||||
"value": 0,
|
||||
"min": 0
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.01676705490848586,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 7.8948,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.017589628397115916,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0322,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 1800,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"vus_max": {
|
||||
"min": 60,
|
||||
"max": 60,
|
||||
"value": 60
|
||||
},
|
||||
"write_total": {
|
||||
"count": 1800,
|
||||
"rate": 29.689741459504642
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"med": 4.80935,
|
||||
"max": 2191.8273,
|
||||
"p(90)": 6.059230000000002,
|
||||
"p(95)": 6.777195,
|
||||
"avg": 46.20643522222217,
|
||||
"min": 3.3973
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 569546,
|
||||
"rate": 9394.26304960835
|
||||
},
|
||||
"iteration_duration": {
|
||||
"min": 3.5105,
|
||||
"med": 4.8450500000000005,
|
||||
"max": 2191.8273,
|
||||
"p(90)": 6.2725,
|
||||
"p(95)": 6.95858,
|
||||
"avg": 46.268034388888886
|
||||
},
|
||||
"iterations": {
|
||||
"count": 1800,
|
||||
"rate": 29.689741459504642
|
||||
},
|
||||
"http_req_duration": {
|
||||
"max": 2191.8273,
|
||||
"p(90)": 6.073320000000001,
|
||||
"p(95)": 6.78405,
|
||||
"avg": 46.472133111480815,
|
||||
"min": 3.3973,
|
||||
"med": 4.8097
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0032602329450915134,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0178
|
||||
},
|
||||
"data_received": {
|
||||
"count": 808658,
|
||||
"rate": 13338.248305088946
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 1803,
|
||||
"rate": 29.739224361937147
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"p(95)": 6.776689999999999,
|
||||
"avg": 46.45128325013858,
|
||||
"min": 3.3973,
|
||||
"med": 4.8005,
|
||||
"max": 2191.8273,
|
||||
"p(90)": 6.02736
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "e1ab1237-0d56-44bc-b502-9d3115dd54c5",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 1800,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 1800,
|
||||
"fails": 0
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Failover under k6 load
|
||||
# target: mtusi-messenger-lab3-api-3
|
||||
# rate: 30
|
||||
# duration: 60s
|
||||
# wall-clock stop-recover: 8.67 s
|
||||
@@ -0,0 +1,62 @@
|
||||
1791539438 kill
|
||||
1791539440 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539440 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539440 exec_die
|
||||
1791539441 stop
|
||||
1791539441 die
|
||||
1791539485 start
|
||||
1791539490 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539490 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539490 exec_die
|
||||
1791539490 health_status: healthy
|
||||
1791539498 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539498 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539498 exec_die
|
||||
1791539503 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539503 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539503 exec_die
|
||||
1791539508 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539508 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539508 exec_die
|
||||
1791539513 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539513 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539513 exec_die
|
||||
1791539518 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539518 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539518 exec_die
|
||||
1791539523 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539523 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539523 exec_die
|
||||
1791539530 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539530 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539531 exec_die
|
||||
1791539536 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539536 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539536 exec_die
|
||||
1791539541 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539541 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539541 exec_die
|
||||
1791539546 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539546 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539546 exec_die
|
||||
1791539551 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539551 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539551 exec_die
|
||||
1791539556 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539556 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539556 exec_die
|
||||
1791539564 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539564 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539564 exec_die
|
||||
1791539569 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539569 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539569 exec_die
|
||||
1791539574 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539574 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539574 exec_die
|
||||
1791539579 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539579 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539579 exec_die
|
||||
1791539584 exec_create: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539584 exec_start: /bin/sh -c wget -q -O - http://127.0.0.1:8080/health/ready >/dev/null || exit 1
|
||||
1791539584 exec_die
|
||||
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"max": 2189.4549,
|
||||
"p(90)": 5.89327,
|
||||
"p(95)": 6.508175,
|
||||
"avg": 16.798438188976416,
|
||||
"min": 3.013,
|
||||
"med": 4.776199999999999
|
||||
},
|
||||
"http_req_sending": {
|
||||
"max": 0.6084,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0006680532445923462,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 25,
|
||||
"fails": 1778,
|
||||
"value": 0.013865779256794232
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"avg": 46.06709388888875,
|
||||
"min": 3.013,
|
||||
"med": 4.7886500000000005,
|
||||
"max": 2189.4549,
|
||||
"p(90)": 5.974140000000001,
|
||||
"p(95)": 6.77885
|
||||
},
|
||||
"write_total": {
|
||||
"count": 1800,
|
||||
"rate": 29.23901164317586
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 25,
|
||||
"fails": 1775,
|
||||
"thresholds": {
|
||||
"rate<0.01": true
|
||||
},
|
||||
"value": 0.013888888888888888
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.0064486966167498615,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0015,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 569542,
|
||||
"rate": 9251.580649598704
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 46.82858108707698,
|
||||
"min": 3.0001,
|
||||
"med": 4.7755,
|
||||
"max": 2189.4549,
|
||||
"p(90)": 5.951979999999998,
|
||||
"p(95)": 6.774429999999999
|
||||
},
|
||||
"data_received": {
|
||||
"rate": 13081.793711482598,
|
||||
"count": 805336
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"med": 0,
|
||||
"max": 1.0119,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.02058219633943428,
|
||||
"min": 0
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 60,
|
||||
"min": 60,
|
||||
"max": 60
|
||||
},
|
||||
"checks": {
|
||||
"passes": 3550,
|
||||
"fails": 50,
|
||||
"value": 0.9861111111111112
|
||||
},
|
||||
"iteration_duration": {
|
||||
"p(95)": 6.900695,
|
||||
"avg": 46.12894022222213,
|
||||
"min": 3.013,
|
||||
"med": 4.8256,
|
||||
"max": 2189.4549,
|
||||
"p(90)": 6.06301
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 46.84983133666098,
|
||||
"min": 3.013,
|
||||
"med": 4.7889,
|
||||
"max": 2189.4549,
|
||||
"p(90)": 5.98108,
|
||||
"p(95)": 6.823749999999994
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"max": 11.0017,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.012612423738214086,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"vus": {
|
||||
"value": 0,
|
||||
"min": 0,
|
||||
"max": 31
|
||||
},
|
||||
"iterations": {
|
||||
"count": 1800,
|
||||
"rate": 29.23901164317586
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 1803,
|
||||
"rate": 29.28774332924782
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "9705985e-7b75-4147-9bb9-d32b7024f81f",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 1775,
|
||||
"fails": 25,
|
||||
"name": "status is 201"
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 1775,
|
||||
"fails": 25
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
# Failover under k6 load
|
||||
# target: mtusi-messenger-lab3-api-4
|
||||
# rate: 30
|
||||
# duration: 60s
|
||||
# wall-clock stop-recover: 8.65 s
|
||||
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"iteration_duration": {
|
||||
"min": 2.7143,
|
||||
"med": 3.96935,
|
||||
"max": 11.377,
|
||||
"p(90)": 4.80631,
|
||||
"p(95)": 5.273655,
|
||||
"avg": 4.148489466666667
|
||||
},
|
||||
"data_received": {
|
||||
"count": 673708,
|
||||
"rate": 21268.63445048648
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.015508649367930803,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 10.3133,
|
||||
"p(90)": 0
|
||||
},
|
||||
"iterations": {
|
||||
"count": 1500,
|
||||
"rate": 47.35427169594204
|
||||
},
|
||||
"http_req_duration": {
|
||||
"med": 3.9578,
|
||||
"max": 889.562,
|
||||
"p(90)": 4.75692,
|
||||
"p(95)": 5.063949999999999,
|
||||
"avg": 5.203563073852293,
|
||||
"min": 2.7143
|
||||
},
|
||||
"checks": {
|
||||
"passes": 3000,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"p(95)": 5.046234999999999,
|
||||
"avg": 4.107610933333333,
|
||||
"min": 2.7143,
|
||||
"med": 3.9565,
|
||||
"max": 11.2309,
|
||||
"p(90)": 4.75412
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 473946,
|
||||
"rate": 14962.24510213663
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"avg": 5.203563073852293,
|
||||
"min": 2.7143,
|
||||
"med": 3.9578,
|
||||
"max": 889.562,
|
||||
"p(90)": 4.75692,
|
||||
"p(95)": 5.063949999999999
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.007103393213572853,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.3121,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0032186959414504325,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0038
|
||||
},
|
||||
"write_total": {
|
||||
"rate": 47.35427169594204,
|
||||
"count": 1500
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.01398117099135063,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0235,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 1500,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 5.186363206919492,
|
||||
"min": 2.7128,
|
||||
"med": 3.9517,
|
||||
"max": 889.562,
|
||||
"p(90)": 4.725820000000001,
|
||||
"p(95)": 5.00228
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 100,
|
||||
"min": 100,
|
||||
"max": 100
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 1503,
|
||||
"value": 0
|
||||
},
|
||||
"vus": {
|
||||
"value": 0,
|
||||
"min": 0,
|
||||
"max": 0
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 1503,
|
||||
"rate": 47.44898023933392
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "97d84ac4-969c-42aa-97d7-f49264e23135",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 1500,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 1500,
|
||||
"fails": 0
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
# Baseline k6 — open-loop нагрузка на POST /messages
|
||||
|
||||
- Дата: 2026-10-08
|
||||
- Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
- Коммит: a5b668c31c18fc92e6c6620fa353d70d2083127b
|
||||
- Скрипт: `student-tests/load-k6.js`
|
||||
- Профиль: `constant-arrival-rate`, RATE=50, DURATION=30s, maxVUs=100
|
||||
- Стенд: 2 × api (0.5 CPU / 256 MiB), postgres (1 CPU / 1 GiB), redis (0.5 CPU / 256 MiB), nginx LB
|
||||
|
||||
## Назначение
|
||||
|
||||
Отправная точка для сравнения до и после rolling update и для
|
||||
экспериментов трека 1. В отличие от `tests/load.py`, k6 работает в
|
||||
open-loop режиме: интенсивность задаётся в RPS, k6 сам подбирает число
|
||||
VU, и снижение пропускной способности сервера не приводит к снижению
|
||||
частоты запросов. Это устраняет coordinated omission и даёт честные
|
||||
p95/p99.
|
||||
|
||||
`write_latency_ms` считает только POST /messages, без setup-запросов
|
||||
регистрации/логина, поэтому метрика не размывается первичным
|
||||
`setup()`.
|
||||
|
||||
## Команда
|
||||
|
||||
k6 run -e RATE=50 -e DURATION=30s \
|
||||
--summary-export evidence/k6-baseline.json \
|
||||
student-tests/load-k6.js
|
||||
|
||||
## Консольный вывод
|
||||
|
||||
█ THRESHOLDS
|
||||
|
||||
write_errors
|
||||
✓ 'rate<0.01' rate=0.00%
|
||||
|
||||
█ TOTAL RESULTS
|
||||
|
||||
checks_total.......: 3000 94.708543/s
|
||||
checks_succeeded...: 100.00% 3000 out of 3000
|
||||
checks_failed......: 0.00% 0 out of 3000
|
||||
|
||||
✓ status is 201
|
||||
✓ has message id
|
||||
|
||||
CUSTOM
|
||||
write_errors...................: 0.00% 0 out of 1500
|
||||
write_latency_ms...............: avg=4.1ms min=2.71ms med=3.95ms max=11.23ms p(90)=4.75ms p(95)=5.04ms
|
||||
write_total....................: 1500 47.354272/s
|
||||
|
||||
HTTP
|
||||
http_req_duration..............: avg=5.2ms min=2.71ms med=3.95ms max=889.56ms p(90)=4.75ms p(95)=5.06ms
|
||||
http_req_failed................: 0.00% 0 out of 1503
|
||||
http_reqs......................: 1503 47.44898/s
|
||||
|
||||
EXECUTION
|
||||
iteration_duration.............: avg=4.14ms min=2.71ms med=3.96ms max=11.37ms p(90)=4.8ms p(95)=5.27ms
|
||||
iterations.....................: 1500 47.354272/s
|
||||
vus_max........................: 100 min=100 max=100
|
||||
|
||||
NETWORK
|
||||
data_received..................: 674 kB 21 kB/s
|
||||
data_sent......................: 474 kB 15 kB/s
|
||||
|
||||
## Итоговые метрики
|
||||
|
||||
| Метрика | Значение |
|
||||
| --- | --- |
|
||||
| Фактический RPS POST | 47.45 |
|
||||
| Всего записей (write_total) | 1500 |
|
||||
| Ошибок (write_errors) | 0 (0.00%) |
|
||||
| write_latency_ms p50 | 3.96 ms |
|
||||
| write_latency_ms p90 | 4.75 ms |
|
||||
| write_latency_ms p95 | 5.05 ms |
|
||||
| write_latency_ms max | 11.23 ms |
|
||||
| Checks passed | 3000 / 3000 |
|
||||
|
||||
`http_req_duration.max = 889.56 ms` — единичный выброс в самом начале
|
||||
прогона: первый запрос на свежую реплику, прогрев pgx pool и Go runtime.
|
||||
На p95/p99 не влияет, поэтому не искажает картину.
|
||||
|
||||
## Замечание про поля `passes/fails/value` в k6 summary
|
||||
|
||||
В JSON у метрик `write_errors` и `http_req_failed`:
|
||||
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 1500,
|
||||
"value": 0
|
||||
}
|
||||
|
||||
`fails: 1500` здесь - не ошибки, а количество событий, у которых
|
||||
значение метрики было `false` (`status !== 201` → ложь для всех
|
||||
успешных). Итоговое значение метрики — `value: 0` (0% ошибок), что
|
||||
совпадает с `✓ 'rate<0.01' rate=0.00%` в консольном выводе.
|
||||
Это стандартное поведение k6 для `Rate`
|
||||
|
||||
## Связанные файлы
|
||||
|
||||
- `evidence/k6-baseline.json` — полный JSON summary (session token замаскирован)
|
||||
- `evidence/load-py-baseline.md` — closed-loop аналог для сравнения
|
||||
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"root_group": {
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 8976,
|
||||
"fails": 24
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 8976,
|
||||
"fails": 24
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
},
|
||||
"metrics": {
|
||||
"checks": {
|
||||
"passes": 17952,
|
||||
"fails": 48,
|
||||
"value": 0.9973333333333333
|
||||
},
|
||||
"iteration_duration": {
|
||||
"max": 2192.8658,
|
||||
"p(90)": 5.48771,
|
||||
"p(95)": 6.405184999999993,
|
||||
"avg": 17.414163077777637,
|
||||
"min": 2.6781,
|
||||
"med": 4.2417
|
||||
},
|
||||
"vus": {
|
||||
"min": 0,
|
||||
"max": 34,
|
||||
"value": 0
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0031226035765855825,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.772
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_sending": {
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0039,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0013810063312229255
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 2850244,
|
||||
"rate": 15749.516701281575
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.024373464400755326,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.3292,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"iterations": {
|
||||
"count": 9000,
|
||||
"rate": 49.731058222220334
|
||||
},
|
||||
"data_received": {
|
||||
"count": 4037365,
|
||||
"rate": 22309.159319928287
|
||||
},
|
||||
"write_errors": {
|
||||
"fails": 8976,
|
||||
"passes": 24,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0.0026666666666666666
|
||||
},
|
||||
"http_req_duration": {
|
||||
"med": 4.2178,
|
||||
"max": 2192.8658,
|
||||
"p(90)": 5.3326,
|
||||
"p(95)": 6.278109999999999,
|
||||
"avg": 17.46616996556693,
|
||||
"min": 2.6781
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"avg": 11.915301392137255,
|
||||
"min": 2.6781,
|
||||
"med": 4.2167,
|
||||
"max": 2192.8658,
|
||||
"p(90)": 5.31872,
|
||||
"p(95)": 6.177340000000008
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"avg": 0.004824891702765745,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 11.5307,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 100,
|
||||
"min": 100,
|
||||
"max": 100
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"p(95)": 6.27192,
|
||||
"avg": 17.36525141111101,
|
||||
"min": 2.6781,
|
||||
"med": 4.2178,
|
||||
"max": 2192.8658,
|
||||
"p(90)": 5.33021
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 9003,
|
||||
"rate": 49.74763524162774
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 17.44041549483494,
|
||||
"min": 2.6593,
|
||||
"med": 4.205,
|
||||
"max": 2192.8658,
|
||||
"p(90)": 5.2940000000000005,
|
||||
"p(95)": 6.22353
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 24,
|
||||
"fails": 8979,
|
||||
"value": 0.0026657780739753416
|
||||
},
|
||||
"write_total": {
|
||||
"count": 9000,
|
||||
"rate": 49.731058222220334
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "b56efcdb-8859-4239-84e9-dce612a06a8f",
|
||||
"token": "REDACTED"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "закрытый цикл POST /messages; без автоматических повторов",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.108,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 10726,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 356.248,
|
||||
"successful_latency_ms": {
|
||||
"p50": 7.475,
|
||||
"p95": 26.506,
|
||||
"p99": 53.035
|
||||
},
|
||||
"note": "Процентили latency покрывают только успешные запросы. Таймауты и ошибки учитываются отдельно; closed-loop страдает coordinated omission и содержит накладные расходы клиента."
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
# Baseline load.py — closed-loop
|
||||
|
||||
- Дата: 2026-10-08
|
||||
- Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
- Коммит: a5b668c31c18fc92e6c6620fa353d70d2083127b
|
||||
- Скрипт: `tests/load.py` (публичный, из scaffold)
|
||||
- Профиль: closed-loop, 4 конкурентных воркера, 30 секунд
|
||||
- Лимиты стенда: 2 × api (0.5 CPU / 256 MiB), postgres (1 CPU / 1 GiB), redis (0.5 CPU / 256 MiB), nginx LB
|
||||
|
||||
## Назначение
|
||||
|
||||
Точка отсчёта для сравнения с open-loop k6. `load.py` использует
|
||||
closed-loop модель: следующий запрос отправляется сразу после ответа на
|
||||
предыдущий, поэтому фактический RPS зависит от latency сервера. Это
|
||||
означает **coordinated omission**: если сервер начнёт тормозить, RPS
|
||||
упадёт, и пострадавшая latency окажется заниженной. Для заявлений о
|
||||
максимальной пропускной способности нужен open-loop k6.
|
||||
|
||||
## Команда
|
||||
|
||||
python3 tests/load.py --duration 30 --concurrency 4 \
|
||||
--output evidence/load-py-baseline.json
|
||||
|
||||
## Результат
|
||||
|
||||
{
|
||||
"lab": 3,
|
||||
"workload": "закрытый цикл POST /messages; без автоматических повторов",
|
||||
"requested_duration_seconds": 30.0,
|
||||
"elapsed_seconds": 30.108,
|
||||
"concurrency": 4,
|
||||
"successful_requests": 10726,
|
||||
"failed_requests": 0,
|
||||
"error_ratio": 0.0,
|
||||
"successful_rps": 356.248,
|
||||
"successful_latency_ms": {
|
||||
"p50": 7.475,
|
||||
"p95": 26.506,
|
||||
"p99": 53.035
|
||||
},
|
||||
"note": "Процентили latency покрывают только успешные запросы. Таймауты и ошибки учитываются отдельно; closed-loop страдает coordinated omission и содержит накладные расходы клиента."
|
||||
}
|
||||
## Что показывают цифры
|
||||
|
||||
- **356 RPS при 4 воркерах** — стек выдерживает несколько сотен
|
||||
последовательных POST. Это не предел: closed-loop насыщает клиент
|
||||
и сервер одновременно, цифра зависит от того, кто первым стал
|
||||
bottleneck.
|
||||
- **p50 = 7.5 ms, p95 = 26.5 ms, p99 = 53.0 ms** — хвосты растут
|
||||
заметно по сравнению с open-loop k6 на 50 RPS (там p95 = 5.05 ms).
|
||||
Ожидаемо: 4 воркера держат в полёте несколько запросов
|
||||
одновременно, latency включает очередь на стороне API и Postgres.
|
||||
- **failed_requests = 0** — на этом уровне ошибок нет.
|
||||
- Сравнение с k6-базой не «кто быстрее», а «как меняется картина
|
||||
при разных моделях нагрузки». Closed-loop даёт завышенный RPS и
|
||||
заниженную latency хвостов из-за coordinated omission.
|
||||
|
||||
## Связанные файлы
|
||||
|
||||
- `evidence/load-py-baseline.json` — сырой JSON, сохранённый скриптом
|
||||
- `evidence/k6-baseline.md` — open-loop аналог для сравнения
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 183 KiB |
@@ -0,0 +1,64 @@
|
||||
config,run,metric,value
|
||||
rep1-cpu1.0-mem512M,1,write_total.rate,396.9147682757007
|
||||
rep1-cpu1.0-mem512M,1,http_reqs.rate,396.9395754487179
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.avg,3.6438378875000246
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.p(90),3.8937199999999996
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.p(95),4.2524
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.max,169.4691
|
||||
rep1-cpu1.0-mem512M,1,vus_max.value,800
|
||||
rep1-cpu1.0-mem512M,2,write_total.rate,398.0077206134656
|
||||
rep1-cpu1.0-mem512M,2,http_reqs.rate,398.03259609600394
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.avg,3.2020571541666505
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.p(90),3.7152
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.p(95),4.0011
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.max,55.0712
|
||||
rep1-cpu1.0-mem512M,2,vus_max.value,800
|
||||
rep1-cpu1.0-mem512M,3,write_total.rate,398.66205923290477
|
||||
rep1-cpu1.0-mem512M,3,http_reqs.rate,398.68697561160684
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.avg,3.1599093291666684
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.p(90),3.7155099999999996
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.p(95),4.0008
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.max,21.2291
|
||||
rep1-cpu1.0-mem512M,3,vus_max.value,800
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,397.0886528801121
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,397.1134709209171
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,3.730664437499994
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),3.7443
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),4.054214999999998
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,221.6521
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,800
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,397.3458041976314
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,397.3706377930272
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,3.2759642215787452
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),3.7372
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),4.003
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,44.9461
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,800
|
||||
rep2-cpu0.5-mem256M,3,write_total.rate,397.34261530318344
|
||||
rep2-cpu0.5-mem256M,3,http_reqs.rate,397.3674492166399
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.avg,3.3407634458333675
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.p(90),3.9099
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.p(95),4.218
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.max,60.789
|
||||
rep2-cpu0.5-mem256M,3,vus_max.value,800
|
||||
rep4-cpu0.25-mem128M,1,write_total.rate,393.89957622171187
|
||||
rep4-cpu0.25-mem128M,1,http_reqs.rate,393.9241944323463
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.avg,4.617149742713689
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.p(90),4.0018
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.p(95),4.4948
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.max,524.6304
|
||||
rep4-cpu0.25-mem128M,1,vus_max.value,800
|
||||
rep4-cpu0.25-mem128M,2,write_total.rate,393.78662832050185
|
||||
rep4-cpu0.25-mem128M,2,http_reqs.rate,393.8112394720395
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.avg,4.100821487052345
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.p(90),4.1949
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.p(95),5.1462
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.max,288.2237
|
||||
rep4-cpu0.25-mem128M,2,vus_max.value,800
|
||||
rep4-cpu0.25-mem128M,3,write_total.rate,394.4866549703591
|
||||
rep4-cpu0.25-mem128M,3,http_reqs.rate,394.511309872651
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.avg,3.6398426178621053
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.p(90),3.9956
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.p(95),4.2448
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.max,86.0005
|
||||
rep4-cpu0.25-mem128M,3,vus_max.value,800
|
||||
|
@@ -0,0 +1,17 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,721.8249956327732
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,721.8706460878474
|
||||
rep2-cpu0.5-mem256M,1,dropped_iterations.rate,191.1841058506232
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,4517.129968266742
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),6323.4827000000005
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),6456.36425
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,6736.0397
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,4000
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,642.12362007902
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,642.1692968196716
|
||||
rep2-cpu0.5-mem256M,2,dropped_iterations.rate,271.41119295131153
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,5235.301641421281
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),6978.46239
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),7433.966485
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,7827.1602
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,4000
|
||||
|
@@ -0,0 +1,15 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,197.31590683614613
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,197.36523170244965
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,3.3276426797766807
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),3.7283
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),4.1869
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,12.8598
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,400
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,197.47169035743912
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,197.52105416637772
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,3.2765851929005985
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),3.71
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),4.0384
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,10.0245
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,400
|
||||
|
@@ -0,0 +1,15 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,394.53267497800704
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,394.58198950760726
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,3.3621370817882386
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),3.9626
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),4.1185
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,80.0027
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,800
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,395.18172626218734
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,395.2311219198177
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,3.299516145160586
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),3.7902
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),4.0067
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,50.0027
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,800
|
||||
|
@@ -0,0 +1,15 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,591.55693321979
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,591.6062282615849
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,5.437148204216531
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),4.0013
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),5.9984
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,231.8701
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,1200
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,591.2531324459899
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,591.302402171757
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,4.611455562345495
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),4.2592
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),7.001
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,130.746
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,1200
|
||||
|
@@ -0,0 +1,17 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,725.3991090037861
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,725.4458667135324
|
||||
rep2-cpu0.5-mem256M,1,dropped_iterations.rate,22.73983283994078
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,2454.367098762404
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),3665.7873
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),4096.1525599999995
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,4590.6913
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,2895
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,712.1827303892608
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,712.2290411769744
|
||||
rep2-cpu0.5-mem256M,2,dropped_iterations.rate,28.789873028632737
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,2746.757344458653
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),4661.001859999999
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),4939.050329999997
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,5444.0319
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,3200
|
||||
|
@@ -0,0 +1,65 @@
|
||||
config,run,metric,value
|
||||
rep2-cpu0.25-mem128M,1,write_total.rate,453.2065610320589
|
||||
rep2-cpu0.25-mem128M,1,http_reqs.rate,453.2505161491899
|
||||
rep2-cpu0.25-mem128M,1,dropped_iterations.rate,250.0753130639849
|
||||
rep2-cpu0.25-mem128M,1,write_latency_ms.avg,6093.802205764284
|
||||
rep2-cpu0.25-mem128M,1,write_latency_ms.p(90),7016.492800000001
|
||||
rep2-cpu0.25-mem128M,1,write_latency_ms.p(95),7526.062404999999
|
||||
rep2-cpu0.25-mem128M,1,write_latency_ms.max,7942.0795
|
||||
rep2-cpu0.25-mem128M,1,vus_max.value,3200
|
||||
rep2-cpu0.25-mem128M,2,write_total.rate,418.64341387003867
|
||||
rep2-cpu0.25-mem128M,2,http_reqs.rate,418.6864295991071
|
||||
rep2-cpu0.25-mem128M,2,dropped_iterations.rate,269.60825122438393
|
||||
rep2-cpu0.25-mem128M,2,write_latency_ms.avg,6538.852833797988
|
||||
rep2-cpu0.25-mem128M,2,write_latency_ms.p(90),9338.392780000002
|
||||
rep2-cpu0.25-mem128M,2,write_latency_ms.p(95),9660.761299999998
|
||||
rep2-cpu0.25-mem128M,2,write_latency_ms.max,11119.5976
|
||||
rep2-cpu0.25-mem128M,2,vus_max.value,3200
|
||||
rep2-cpu0.5-mem256M,1,write_total.rate,748.5830475147193
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,748.6303802538869
|
||||
rep2-cpu0.5-mem256M,1,dropped_iterations.rate,8.740779166276493
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,1769.8529807802556
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),2675.3608999999997
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),2879.9886500000002
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,3112.068
|
||||
rep2-cpu0.5-mem256M,1,vus_max.value,2089
|
||||
rep2-cpu0.5-mem256M,2,write_total.rate,736.1132987779325
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,736.1603107397909
|
||||
rep2-cpu0.5-mem256M,2,dropped_iterations.rate,16.09376160950604
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,2110.4978718567586
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),3333.6357300000004
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),3529.0254649999997
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,3813.0537
|
||||
rep2-cpu0.5-mem256M,2,vus_max.value,2483
|
||||
rep2-cpu1.0-mem512M,1,write_total.rate,683.5291672113441
|
||||
rep2-cpu1.0-mem512M,1,http_reqs.rate,683.575923430457
|
||||
rep2-cpu1.0-mem512M,1,dropped_iterations.rate,64.57033859490159
|
||||
rep2-cpu1.0-mem512M,1,write_latency_ms.avg,3347.980236621289
|
||||
rep2-cpu1.0-mem512M,1,write_latency_ms.p(90),4642.26784
|
||||
rep2-cpu1.0-mem512M,1,write_latency_ms.p(95),4729.05158
|
||||
rep2-cpu1.0-mem512M,1,write_latency_ms.max,5003.5691
|
||||
rep2-cpu1.0-mem512M,1,vus_max.value,3200
|
||||
rep2-cpu1.0-mem512M,2,write_total.rate,712.2830965103443
|
||||
rep2-cpu1.0-mem512M,2,http_reqs.rate,712.3298946376199
|
||||
rep2-cpu1.0-mem512M,2,dropped_iterations.rate,36.50253927496563
|
||||
rep2-cpu1.0-mem512M,2,write_latency_ms.avg,2518.4434249381343
|
||||
rep2-cpu1.0-mem512M,2,write_latency_ms.p(90),4216.3193
|
||||
rep2-cpu1.0-mem512M,2,write_latency_ms.p(95),4369.1268
|
||||
rep2-cpu1.0-mem512M,2,write_latency_ms.max,4646.5564
|
||||
rep2-cpu1.0-mem512M,2,vus_max.value,3200
|
||||
rep2-cpu2.0-mem1G,1,write_total.rate,720.7435535035722
|
||||
rep2-cpu2.0-mem1G,1,http_reqs.rate,720.7903996483965
|
||||
rep2-cpu2.0-mem1G,1,dropped_iterations.rate,28.81037906694884
|
||||
rep2-cpu2.0-mem1G,1,write_latency_ms.avg,2903.1001716201745
|
||||
rep2-cpu2.0-mem1G,1,write_latency_ms.p(90),4055.11845
|
||||
rep2-cpu2.0-mem1G,1,write_latency_ms.p(95),4241.56125
|
||||
rep2-cpu2.0-mem1G,1,write_latency_ms.max,4565.337
|
||||
rep2-cpu2.0-mem1G,1,vus_max.value,3194
|
||||
rep2-cpu2.0-mem1G,2,write_total.rate,745.110636964332
|
||||
rep2-cpu2.0-mem1G,2,http_reqs.rate,745.1581810325406
|
||||
rep2-cpu2.0-mem1G,2,dropped_iterations.rate,15.610302395139252
|
||||
rep2-cpu2.0-mem1G,2,write_latency_ms.avg,2122.849284709457
|
||||
rep2-cpu2.0-mem1G,2,write_latency_ms.p(90),2929.8991
|
||||
rep2-cpu2.0-mem1G,2,write_latency_ms.p(95),3065.7545
|
||||
rep2-cpu2.0-mem1G,2,write_latency_ms.max,3286.2418
|
||||
rep2-cpu2.0-mem1G,2,vus_max.value,2409
|
||||
|
@@ -0,0 +1,54 @@
|
||||
=== rolling update начинается ===
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-1 Up 2 minutes (healthy)
|
||||
mtusi-messenger-lab3-api-2 Up 2 minutes (healthy)
|
||||
|
||||
>>> раунд 1: останавливаем mtusi-messenger-lab3-api-1
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Running
|
||||
Container mtusi-messenger-lab3-api-2 Running
|
||||
Container mtusi-messenger-lab3-api-3 Creating
|
||||
Container mtusi-messenger-lab3-api-3 Created
|
||||
Container mtusi-messenger-lab3-lb-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Starting
|
||||
Container mtusi-messenger-lab3-migrate-1 Started
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-redis-1 Waiting
|
||||
Container mtusi-messenger-lab3-migrate-1 Waiting
|
||||
Container mtusi-messenger-lab3-redis-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Exited
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-api-3 Starting
|
||||
Container mtusi-messenger-lab3-api-3 Started
|
||||
восстановлено до 2 healthy
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-2 Up 2 minutes (healthy)
|
||||
mtusi-messenger-lab3-api-3 Up 6 seconds (healthy)
|
||||
|
||||
>>> раунд 2: останавливаем mtusi-messenger-lab3-api-2
|
||||
Container mtusi-messenger-lab3-postgres-1 Running
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
Container mtusi-messenger-lab3-api-3 Running
|
||||
Container mtusi-messenger-lab3-api-4 Creating
|
||||
Container mtusi-messenger-lab3-api-4 Created
|
||||
Container mtusi-messenger-lab3-lb-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Starting
|
||||
Container mtusi-messenger-lab3-migrate-1 Started
|
||||
Container mtusi-messenger-lab3-redis-1 Waiting
|
||||
Container mtusi-messenger-lab3-migrate-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Exited
|
||||
Container mtusi-messenger-lab3-redis-1 Healthy
|
||||
Container mtusi-messenger-lab3-api-4 Starting
|
||||
Container mtusi-messenger-lab3-api-4 Started
|
||||
восстановлено до 2 healthy
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-3 Up 20 seconds (healthy)
|
||||
mtusi-messenger-lab3-api-4 Up 5 seconds (healthy)
|
||||
|
||||
=== rolling update завершён ===
|
||||
@@ -0,0 +1,658 @@
|
||||
>>> k6: RATE=50 DURATION=3m (фон)
|
||||
>>> прогрев 20 секунд, затем rolling update
|
||||
|
||||
/\ Grafana /‾‾/
|
||||
/\ / \ |\ __ / /
|
||||
/ \/ \ | |/ / / ‾‾\
|
||||
/ \ | ( | (‾) |
|
||||
/ __________ \ |_|\_\ \_____/
|
||||
|
||||
|
||||
execution: local
|
||||
script: student-tests/load-k6.js
|
||||
output: -
|
||||
|
||||
scenarios: (100.00%) 1 scenario, 200 max VUs, 3m30s max duration (incl. graceful stop):
|
||||
* writes: 50.00 iterations/s for 3m0s (maxVUs: 100-200, gracefulStop: 30s)
|
||||
|
||||
|
||||
running (0m01.0s), 001/100 VUs, 0 complete and 0 interrupted iterations
|
||||
writes [ 0% ] 001/100 VUs 0m00.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m02.0s), 000/100 VUs, 51 complete and 0 interrupted iterations
|
||||
writes [ 1% ] 000/100 VUs 0m01.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m03.0s), 000/100 VUs, 101 complete and 0 interrupted iterations
|
||||
writes [ 1% ] 000/100 VUs 0m02.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m04.0s), 000/100 VUs, 151 complete and 0 interrupted iterations
|
||||
writes [ 2% ] 000/100 VUs 0m03.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m05.0s), 000/100 VUs, 201 complete and 0 interrupted iterations
|
||||
writes [ 2% ] 000/100 VUs 0m04.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m06.0s), 000/100 VUs, 251 complete and 0 interrupted iterations
|
||||
writes [ 3% ] 000/100 VUs 0m05.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m07.0s), 000/100 VUs, 301 complete and 0 interrupted iterations
|
||||
writes [ 3% ] 000/100 VUs 0m06.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m08.0s), 000/100 VUs, 351 complete and 0 interrupted iterations
|
||||
writes [ 4% ] 000/100 VUs 0m07.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m09.0s), 000/100 VUs, 401 complete and 0 interrupted iterations
|
||||
writes [ 4% ] 000/100 VUs 0m08.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m10.0s), 000/100 VUs, 451 complete and 0 interrupted iterations
|
||||
writes [ 5% ] 000/100 VUs 0m09.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m11.0s), 000/100 VUs, 501 complete and 0 interrupted iterations
|
||||
writes [ 6% ] 000/100 VUs 0m10.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m12.0s), 000/100 VUs, 551 complete and 0 interrupted iterations
|
||||
writes [ 6% ] 000/100 VUs 0m11.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m13.0s), 000/100 VUs, 601 complete and 0 interrupted iterations
|
||||
writes [ 7% ] 000/100 VUs 0m12.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m14.0s), 000/100 VUs, 651 complete and 0 interrupted iterations
|
||||
writes [ 7% ] 000/100 VUs 0m13.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m15.0s), 000/100 VUs, 701 complete and 0 interrupted iterations
|
||||
writes [ 8% ] 000/100 VUs 0m14.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m16.0s), 000/100 VUs, 751 complete and 0 interrupted iterations
|
||||
writes [ 8% ] 000/100 VUs 0m15.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m17.0s), 000/100 VUs, 801 complete and 0 interrupted iterations
|
||||
writes [ 9% ] 000/100 VUs 0m16.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m18.0s), 000/100 VUs, 851 complete and 0 interrupted iterations
|
||||
writes [ 9% ] 000/100 VUs 0m17.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m19.0s), 000/100 VUs, 901 complete and 0 interrupted iterations
|
||||
writes [ 10% ] 000/100 VUs 0m18.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m20.0s), 000/100 VUs, 951 complete and 0 interrupted iterations
|
||||
writes [ 11% ] 000/100 VUs 0m19.0s/3m0s 50.00 iters/s
|
||||
=== rolling update начинается ===
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-1 Up 2 minutes (healthy)
|
||||
mtusi-messenger-lab3-api-2 Up 2 minutes (healthy)
|
||||
|
||||
>>> раунд 1: останавливаем mtusi-messenger-lab3-api-1
|
||||
|
||||
running (0m21.0s), 000/100 VUs, 1001 complete and 0 interrupted iterations
|
||||
writes [ 11% ] 000/100 VUs 0m20.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m22.0s), 000/100 VUs, 1051 complete and 0 interrupted iterations
|
||||
writes [ 12% ] 000/100 VUs 0m21.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m23.0s), 000/100 VUs, 1101 complete and 0 interrupted iterations
|
||||
writes [ 12% ] 000/100 VUs 0m22.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m24.0s), 000/100 VUs, 1151 complete and 0 interrupted iterations
|
||||
writes [ 13% ] 000/100 VUs 0m23.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m25.0s), 018/100 VUs, 1183 complete and 0 interrupted iterations
|
||||
writes [ 13% ] 018/100 VUs 0m24.0s/3m0s 50.00 iters/s
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Running
|
||||
Container mtusi-messenger-lab3-api-2 Running
|
||||
Container mtusi-messenger-lab3-api-3 Creating
|
||||
Container mtusi-messenger-lab3-api-3 Created
|
||||
Container mtusi-messenger-lab3-lb-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Starting
|
||||
Container mtusi-messenger-lab3-migrate-1 Started
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-redis-1 Waiting
|
||||
Container mtusi-messenger-lab3-migrate-1 Waiting
|
||||
|
||||
running (0m26.0s), 034/100 VUs, 1217 complete and 0 interrupted iterations
|
||||
writes [ 14% ] 034/100 VUs 0m25.0s/3m0s 50.00 iters/s
|
||||
Container mtusi-messenger-lab3-redis-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Exited
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-api-3 Starting
|
||||
Container mtusi-messenger-lab3-api-3 Started
|
||||
|
||||
running (0m27.0s), 011/100 VUs, 1290 complete and 0 interrupted iterations
|
||||
writes [ 14% ] 011/100 VUs 0m26.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m28.0s), 000/100 VUs, 1351 complete and 0 interrupted iterations
|
||||
writes [ 15% ] 000/100 VUs 0m27.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m29.0s), 000/100 VUs, 1401 complete and 0 interrupted iterations
|
||||
writes [ 16% ] 000/100 VUs 0m28.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m30.0s), 000/100 VUs, 1451 complete and 0 interrupted iterations
|
||||
writes [ 16% ] 000/100 VUs 0m29.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m31.0s), 000/100 VUs, 1501 complete and 0 interrupted iterations
|
||||
writes [ 17% ] 000/100 VUs 0m30.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m32.0s), 000/100 VUs, 1551 complete and 0 interrupted iterations
|
||||
writes [ 17% ] 000/100 VUs 0m31.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m33.0s), 000/100 VUs, 1601 complete and 0 interrupted iterations
|
||||
writes [ 18% ] 000/100 VUs 0m32.0s/3m0s 50.00 iters/s
|
||||
восстановлено до 2 healthy
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-2 Up 2 minutes (healthy)
|
||||
mtusi-messenger-lab3-api-3 Up 6 seconds (healthy)
|
||||
|
||||
>>> раунд 2: останавливаем mtusi-messenger-lab3-api-2
|
||||
|
||||
running (0m34.0s), 000/100 VUs, 1651 complete and 0 interrupted iterations
|
||||
writes [ 18% ] 000/100 VUs 0m33.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m35.0s), 000/100 VUs, 1701 complete and 0 interrupted iterations
|
||||
writes [ 19% ] 000/100 VUs 0m34.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m36.0s), 000/100 VUs, 1751 complete and 0 interrupted iterations
|
||||
writes [ 19% ] 000/100 VUs 0m35.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m37.0s), 000/100 VUs, 1801 complete and 0 interrupted iterations
|
||||
writes [ 20% ] 000/100 VUs 0m36.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m38.0s), 013/100 VUs, 1838 complete and 0 interrupted iterations
|
||||
writes [ 21% ] 013/100 VUs 0m37.0s/3m0s 50.00 iters/s
|
||||
Container mtusi-messenger-lab3-postgres-1 Running
|
||||
Container mtusi-messenger-lab3-redis-1 Running
|
||||
Container mtusi-messenger-lab3-api-3 Running
|
||||
Container mtusi-messenger-lab3-api-4 Creating
|
||||
Container mtusi-messenger-lab3-api-4 Created
|
||||
Container mtusi-messenger-lab3-lb-1 Running
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Starting
|
||||
Container mtusi-messenger-lab3-migrate-1 Started
|
||||
Container mtusi-messenger-lab3-redis-1 Waiting
|
||||
Container mtusi-messenger-lab3-migrate-1 Waiting
|
||||
Container mtusi-messenger-lab3-postgres-1 Waiting
|
||||
|
||||
running (0m39.0s), 024/100 VUs, 1877 complete and 0 interrupted iterations
|
||||
writes [ 21% ] 024/100 VUs 0m38.0s/3m0s 50.00 iters/s
|
||||
Container mtusi-messenger-lab3-postgres-1 Healthy
|
||||
Container mtusi-messenger-lab3-migrate-1 Exited
|
||||
Container mtusi-messenger-lab3-redis-1 Healthy
|
||||
Container mtusi-messenger-lab3-api-4 Starting
|
||||
Container mtusi-messenger-lab3-api-4 Started
|
||||
|
||||
running (0m40.0s), 015/100 VUs, 1936 complete and 0 interrupted iterations
|
||||
writes [ 22% ] 015/100 VUs 0m39.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m41.0s), 000/100 VUs, 2001 complete and 0 interrupted iterations
|
||||
writes [ 22% ] 000/100 VUs 0m40.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m42.0s), 000/100 VUs, 2051 complete and 0 interrupted iterations
|
||||
writes [ 23% ] 000/100 VUs 0m41.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m43.0s), 000/100 VUs, 2101 complete and 0 interrupted iterations
|
||||
writes [ 23% ] 000/100 VUs 0m42.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m44.0s), 000/100 VUs, 2151 complete and 0 interrupted iterations
|
||||
writes [ 24% ] 000/100 VUs 0m43.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m45.0s), 000/100 VUs, 2201 complete and 0 interrupted iterations
|
||||
writes [ 24% ] 000/100 VUs 0m44.0s/3m0s 50.00 iters/s
|
||||
восстановлено до 2 healthy
|
||||
NAME STATUS
|
||||
mtusi-messenger-lab3-api-3 Up 20 seconds (healthy)
|
||||
mtusi-messenger-lab3-api-4 Up 5 seconds (healthy)
|
||||
|
||||
=== rolling update завершён ===
|
||||
>>> ждём завершения k6 (PID 4141)
|
||||
|
||||
running (0m46.0s), 000/100 VUs, 2251 complete and 0 interrupted iterations
|
||||
writes [ 25% ] 000/100 VUs 0m45.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m47.0s), 000/100 VUs, 2301 complete and 0 interrupted iterations
|
||||
writes [ 26% ] 000/100 VUs 0m46.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m48.0s), 000/100 VUs, 2351 complete and 0 interrupted iterations
|
||||
writes [ 26% ] 000/100 VUs 0m47.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m49.0s), 000/100 VUs, 2401 complete and 0 interrupted iterations
|
||||
writes [ 27% ] 000/100 VUs 0m48.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m50.0s), 000/100 VUs, 2451 complete and 0 interrupted iterations
|
||||
writes [ 27% ] 000/100 VUs 0m49.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m51.0s), 000/100 VUs, 2501 complete and 0 interrupted iterations
|
||||
writes [ 28% ] 000/100 VUs 0m50.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m52.0s), 000/100 VUs, 2551 complete and 0 interrupted iterations
|
||||
writes [ 28% ] 000/100 VUs 0m51.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m53.0s), 000/100 VUs, 2601 complete and 0 interrupted iterations
|
||||
writes [ 29% ] 000/100 VUs 0m52.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m54.0s), 000/100 VUs, 2651 complete and 0 interrupted iterations
|
||||
writes [ 29% ] 000/100 VUs 0m53.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m55.0s), 000/100 VUs, 2701 complete and 0 interrupted iterations
|
||||
writes [ 30% ] 000/100 VUs 0m54.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m56.0s), 000/100 VUs, 2751 complete and 0 interrupted iterations
|
||||
writes [ 31% ] 000/100 VUs 0m55.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m57.0s), 000/100 VUs, 2801 complete and 0 interrupted iterations
|
||||
writes [ 31% ] 000/100 VUs 0m56.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m58.0s), 000/100 VUs, 2851 complete and 0 interrupted iterations
|
||||
writes [ 32% ] 000/100 VUs 0m57.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (0m59.0s), 000/100 VUs, 2901 complete and 0 interrupted iterations
|
||||
writes [ 32% ] 000/100 VUs 0m58.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m00.0s), 000/100 VUs, 2951 complete and 0 interrupted iterations
|
||||
writes [ 33% ] 000/100 VUs 0m59.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m01.0s), 000/100 VUs, 3001 complete and 0 interrupted iterations
|
||||
writes [ 33% ] 000/100 VUs 1m00.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m02.0s), 000/100 VUs, 3051 complete and 0 interrupted iterations
|
||||
writes [ 34% ] 000/100 VUs 1m01.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m03.0s), 000/100 VUs, 3101 complete and 0 interrupted iterations
|
||||
writes [ 34% ] 000/100 VUs 1m02.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m04.0s), 000/100 VUs, 3151 complete and 0 interrupted iterations
|
||||
writes [ 35% ] 000/100 VUs 1m03.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m05.0s), 000/100 VUs, 3201 complete and 0 interrupted iterations
|
||||
writes [ 36% ] 000/100 VUs 1m04.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m06.0s), 000/100 VUs, 3251 complete and 0 interrupted iterations
|
||||
writes [ 36% ] 000/100 VUs 1m05.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m07.0s), 000/100 VUs, 3301 complete and 0 interrupted iterations
|
||||
writes [ 37% ] 000/100 VUs 1m06.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m08.0s), 000/100 VUs, 3351 complete and 0 interrupted iterations
|
||||
writes [ 37% ] 000/100 VUs 1m07.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m09.0s), 000/100 VUs, 3401 complete and 0 interrupted iterations
|
||||
writes [ 38% ] 000/100 VUs 1m08.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m10.0s), 000/100 VUs, 3451 complete and 0 interrupted iterations
|
||||
writes [ 38% ] 000/100 VUs 1m09.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m11.0s), 000/100 VUs, 3501 complete and 0 interrupted iterations
|
||||
writes [ 39% ] 000/100 VUs 1m10.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m12.0s), 000/100 VUs, 3551 complete and 0 interrupted iterations
|
||||
writes [ 39% ] 000/100 VUs 1m11.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m13.0s), 000/100 VUs, 3601 complete and 0 interrupted iterations
|
||||
writes [ 40% ] 000/100 VUs 1m12.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m14.0s), 000/100 VUs, 3651 complete and 0 interrupted iterations
|
||||
writes [ 41% ] 000/100 VUs 1m13.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m15.0s), 000/100 VUs, 3701 complete and 0 interrupted iterations
|
||||
writes [ 41% ] 000/100 VUs 1m14.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m16.0s), 000/100 VUs, 3751 complete and 0 interrupted iterations
|
||||
writes [ 42% ] 000/100 VUs 1m15.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m17.0s), 000/100 VUs, 3801 complete and 0 interrupted iterations
|
||||
writes [ 42% ] 000/100 VUs 1m16.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m18.0s), 000/100 VUs, 3851 complete and 0 interrupted iterations
|
||||
writes [ 43% ] 000/100 VUs 1m17.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m19.0s), 000/100 VUs, 3901 complete and 0 interrupted iterations
|
||||
writes [ 43% ] 000/100 VUs 1m18.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m20.0s), 000/100 VUs, 3951 complete and 0 interrupted iterations
|
||||
writes [ 44% ] 000/100 VUs 1m19.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m21.0s), 000/100 VUs, 4001 complete and 0 interrupted iterations
|
||||
writes [ 44% ] 000/100 VUs 1m20.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m22.0s), 000/100 VUs, 4051 complete and 0 interrupted iterations
|
||||
writes [ 45% ] 000/100 VUs 1m21.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m23.0s), 000/100 VUs, 4101 complete and 0 interrupted iterations
|
||||
writes [ 46% ] 000/100 VUs 1m22.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m24.0s), 000/100 VUs, 4151 complete and 0 interrupted iterations
|
||||
writes [ 46% ] 000/100 VUs 1m23.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m25.0s), 000/100 VUs, 4201 complete and 0 interrupted iterations
|
||||
writes [ 47% ] 000/100 VUs 1m24.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m26.0s), 000/100 VUs, 4251 complete and 0 interrupted iterations
|
||||
writes [ 47% ] 000/100 VUs 1m25.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m27.0s), 000/100 VUs, 4301 complete and 0 interrupted iterations
|
||||
writes [ 48% ] 000/100 VUs 1m26.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m28.0s), 000/100 VUs, 4351 complete and 0 interrupted iterations
|
||||
writes [ 48% ] 000/100 VUs 1m27.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m29.0s), 000/100 VUs, 4401 complete and 0 interrupted iterations
|
||||
writes [ 49% ] 000/100 VUs 1m28.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m30.0s), 000/100 VUs, 4451 complete and 0 interrupted iterations
|
||||
writes [ 49% ] 000/100 VUs 1m29.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m31.0s), 000/100 VUs, 4501 complete and 0 interrupted iterations
|
||||
writes [ 50% ] 000/100 VUs 1m30.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m32.0s), 000/100 VUs, 4551 complete and 0 interrupted iterations
|
||||
writes [ 51% ] 000/100 VUs 1m31.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m33.0s), 000/100 VUs, 4601 complete and 0 interrupted iterations
|
||||
writes [ 51% ] 000/100 VUs 1m32.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m34.0s), 000/100 VUs, 4651 complete and 0 interrupted iterations
|
||||
writes [ 52% ] 000/100 VUs 1m33.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m35.0s), 000/100 VUs, 4701 complete and 0 interrupted iterations
|
||||
writes [ 52% ] 000/100 VUs 1m34.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m36.0s), 000/100 VUs, 4751 complete and 0 interrupted iterations
|
||||
writes [ 53% ] 000/100 VUs 1m35.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m37.0s), 000/100 VUs, 4801 complete and 0 interrupted iterations
|
||||
writes [ 53% ] 000/100 VUs 1m36.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m38.0s), 000/100 VUs, 4851 complete and 0 interrupted iterations
|
||||
writes [ 54% ] 000/100 VUs 1m37.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m39.0s), 000/100 VUs, 4901 complete and 0 interrupted iterations
|
||||
writes [ 54% ] 000/100 VUs 1m38.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m40.0s), 000/100 VUs, 4951 complete and 0 interrupted iterations
|
||||
writes [ 55% ] 000/100 VUs 1m39.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m41.0s), 000/100 VUs, 5001 complete and 0 interrupted iterations
|
||||
writes [ 56% ] 000/100 VUs 1m40.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m42.0s), 000/100 VUs, 5051 complete and 0 interrupted iterations
|
||||
writes [ 56% ] 000/100 VUs 1m41.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m43.0s), 000/100 VUs, 5101 complete and 0 interrupted iterations
|
||||
writes [ 57% ] 000/100 VUs 1m42.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m44.0s), 000/100 VUs, 5151 complete and 0 interrupted iterations
|
||||
writes [ 57% ] 000/100 VUs 1m43.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m45.0s), 000/100 VUs, 5201 complete and 0 interrupted iterations
|
||||
writes [ 58% ] 000/100 VUs 1m44.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m46.0s), 000/100 VUs, 5251 complete and 0 interrupted iterations
|
||||
writes [ 58% ] 000/100 VUs 1m45.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m47.0s), 000/100 VUs, 5301 complete and 0 interrupted iterations
|
||||
writes [ 59% ] 000/100 VUs 1m46.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m48.0s), 000/100 VUs, 5351 complete and 0 interrupted iterations
|
||||
writes [ 59% ] 000/100 VUs 1m47.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m49.0s), 000/100 VUs, 5401 complete and 0 interrupted iterations
|
||||
writes [ 60% ] 000/100 VUs 1m48.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m50.0s), 000/100 VUs, 5451 complete and 0 interrupted iterations
|
||||
writes [ 61% ] 000/100 VUs 1m49.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m51.0s), 000/100 VUs, 5501 complete and 0 interrupted iterations
|
||||
writes [ 61% ] 000/100 VUs 1m50.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m52.0s), 000/100 VUs, 5551 complete and 0 interrupted iterations
|
||||
writes [ 62% ] 000/100 VUs 1m51.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m53.0s), 000/100 VUs, 5601 complete and 0 interrupted iterations
|
||||
writes [ 62% ] 000/100 VUs 1m52.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m54.0s), 000/100 VUs, 5651 complete and 0 interrupted iterations
|
||||
writes [ 63% ] 000/100 VUs 1m53.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m55.0s), 000/100 VUs, 5701 complete and 0 interrupted iterations
|
||||
writes [ 63% ] 000/100 VUs 1m54.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m56.0s), 000/100 VUs, 5751 complete and 0 interrupted iterations
|
||||
writes [ 64% ] 000/100 VUs 1m55.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m57.0s), 000/100 VUs, 5801 complete and 0 interrupted iterations
|
||||
writes [ 64% ] 000/100 VUs 1m56.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m58.0s), 000/100 VUs, 5851 complete and 0 interrupted iterations
|
||||
writes [ 65% ] 000/100 VUs 1m57.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (1m59.0s), 000/100 VUs, 5901 complete and 0 interrupted iterations
|
||||
writes [ 66% ] 000/100 VUs 1m58.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m00.0s), 000/100 VUs, 5951 complete and 0 interrupted iterations
|
||||
writes [ 66% ] 000/100 VUs 1m59.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m01.0s), 000/100 VUs, 6001 complete and 0 interrupted iterations
|
||||
writes [ 67% ] 000/100 VUs 2m00.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m02.0s), 000/100 VUs, 6051 complete and 0 interrupted iterations
|
||||
writes [ 67% ] 000/100 VUs 2m01.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m03.0s), 000/100 VUs, 6101 complete and 0 interrupted iterations
|
||||
writes [ 68% ] 000/100 VUs 2m02.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m04.0s), 000/100 VUs, 6151 complete and 0 interrupted iterations
|
||||
writes [ 68% ] 000/100 VUs 2m03.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m05.0s), 000/100 VUs, 6201 complete and 0 interrupted iterations
|
||||
writes [ 69% ] 000/100 VUs 2m04.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m06.0s), 000/100 VUs, 6251 complete and 0 interrupted iterations
|
||||
writes [ 69% ] 000/100 VUs 2m05.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m07.0s), 000/100 VUs, 6301 complete and 0 interrupted iterations
|
||||
writes [ 70% ] 000/100 VUs 2m06.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m08.0s), 000/100 VUs, 6351 complete and 0 interrupted iterations
|
||||
writes [ 71% ] 000/100 VUs 2m07.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m09.0s), 000/100 VUs, 6401 complete and 0 interrupted iterations
|
||||
writes [ 71% ] 000/100 VUs 2m08.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m10.0s), 000/100 VUs, 6451 complete and 0 interrupted iterations
|
||||
writes [ 72% ] 000/100 VUs 2m09.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m11.0s), 000/100 VUs, 6501 complete and 0 interrupted iterations
|
||||
writes [ 72% ] 000/100 VUs 2m10.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m12.0s), 000/100 VUs, 6551 complete and 0 interrupted iterations
|
||||
writes [ 73% ] 000/100 VUs 2m11.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m13.0s), 000/100 VUs, 6601 complete and 0 interrupted iterations
|
||||
writes [ 73% ] 000/100 VUs 2m12.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m14.0s), 000/100 VUs, 6651 complete and 0 interrupted iterations
|
||||
writes [ 74% ] 000/100 VUs 2m13.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m15.0s), 000/100 VUs, 6701 complete and 0 interrupted iterations
|
||||
writes [ 74% ] 000/100 VUs 2m14.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m16.0s), 000/100 VUs, 6751 complete and 0 interrupted iterations
|
||||
writes [ 75% ] 000/100 VUs 2m15.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m17.0s), 000/100 VUs, 6801 complete and 0 interrupted iterations
|
||||
writes [ 76% ] 000/100 VUs 2m16.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m18.0s), 000/100 VUs, 6851 complete and 0 interrupted iterations
|
||||
writes [ 76% ] 000/100 VUs 2m17.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m19.0s), 000/100 VUs, 6901 complete and 0 interrupted iterations
|
||||
writes [ 77% ] 000/100 VUs 2m18.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m20.0s), 000/100 VUs, 6951 complete and 0 interrupted iterations
|
||||
writes [ 77% ] 000/100 VUs 2m19.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m21.0s), 000/100 VUs, 7001 complete and 0 interrupted iterations
|
||||
writes [ 78% ] 000/100 VUs 2m20.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m22.0s), 000/100 VUs, 7051 complete and 0 interrupted iterations
|
||||
writes [ 78% ] 000/100 VUs 2m21.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m23.0s), 000/100 VUs, 7101 complete and 0 interrupted iterations
|
||||
writes [ 79% ] 000/100 VUs 2m22.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m24.0s), 000/100 VUs, 7151 complete and 0 interrupted iterations
|
||||
writes [ 79% ] 000/100 VUs 2m23.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m25.0s), 000/100 VUs, 7201 complete and 0 interrupted iterations
|
||||
writes [ 80% ] 000/100 VUs 2m24.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m26.0s), 000/100 VUs, 7251 complete and 0 interrupted iterations
|
||||
writes [ 81% ] 000/100 VUs 2m25.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m27.0s), 000/100 VUs, 7301 complete and 0 interrupted iterations
|
||||
writes [ 81% ] 000/100 VUs 2m26.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m28.0s), 000/100 VUs, 7351 complete and 0 interrupted iterations
|
||||
writes [ 82% ] 000/100 VUs 2m27.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m29.0s), 000/100 VUs, 7401 complete and 0 interrupted iterations
|
||||
writes [ 82% ] 000/100 VUs 2m28.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m30.0s), 000/100 VUs, 7451 complete and 0 interrupted iterations
|
||||
writes [ 83% ] 000/100 VUs 2m29.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m31.0s), 000/100 VUs, 7501 complete and 0 interrupted iterations
|
||||
writes [ 83% ] 000/100 VUs 2m30.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m32.0s), 000/100 VUs, 7551 complete and 0 interrupted iterations
|
||||
writes [ 84% ] 000/100 VUs 2m31.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m33.0s), 000/100 VUs, 7601 complete and 0 interrupted iterations
|
||||
writes [ 84% ] 000/100 VUs 2m32.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m34.0s), 000/100 VUs, 7651 complete and 0 interrupted iterations
|
||||
writes [ 85% ] 000/100 VUs 2m33.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m35.0s), 000/100 VUs, 7701 complete and 0 interrupted iterations
|
||||
writes [ 86% ] 000/100 VUs 2m34.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m36.0s), 000/100 VUs, 7751 complete and 0 interrupted iterations
|
||||
writes [ 86% ] 000/100 VUs 2m35.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m37.0s), 000/100 VUs, 7801 complete and 0 interrupted iterations
|
||||
writes [ 87% ] 000/100 VUs 2m36.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m38.0s), 000/100 VUs, 7851 complete and 0 interrupted iterations
|
||||
writes [ 87% ] 000/100 VUs 2m37.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m39.0s), 000/100 VUs, 7901 complete and 0 interrupted iterations
|
||||
writes [ 88% ] 000/100 VUs 2m38.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m40.0s), 000/100 VUs, 7951 complete and 0 interrupted iterations
|
||||
writes [ 88% ] 000/100 VUs 2m39.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m41.0s), 000/100 VUs, 8001 complete and 0 interrupted iterations
|
||||
writes [ 89% ] 000/100 VUs 2m40.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m42.0s), 000/100 VUs, 8051 complete and 0 interrupted iterations
|
||||
writes [ 89% ] 000/100 VUs 2m41.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m43.0s), 000/100 VUs, 8101 complete and 0 interrupted iterations
|
||||
writes [ 90% ] 000/100 VUs 2m42.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m44.0s), 000/100 VUs, 8151 complete and 0 interrupted iterations
|
||||
writes [ 91% ] 000/100 VUs 2m43.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m45.0s), 000/100 VUs, 8201 complete and 0 interrupted iterations
|
||||
writes [ 91% ] 000/100 VUs 2m44.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m46.0s), 000/100 VUs, 8251 complete and 0 interrupted iterations
|
||||
writes [ 92% ] 000/100 VUs 2m45.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m47.0s), 000/100 VUs, 8301 complete and 0 interrupted iterations
|
||||
writes [ 92% ] 000/100 VUs 2m46.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m48.0s), 000/100 VUs, 8351 complete and 0 interrupted iterations
|
||||
writes [ 93% ] 000/100 VUs 2m47.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m49.0s), 000/100 VUs, 8401 complete and 0 interrupted iterations
|
||||
writes [ 93% ] 000/100 VUs 2m48.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m50.0s), 000/100 VUs, 8451 complete and 0 interrupted iterations
|
||||
writes [ 94% ] 000/100 VUs 2m49.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m51.0s), 000/100 VUs, 8501 complete and 0 interrupted iterations
|
||||
writes [ 94% ] 000/100 VUs 2m50.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m52.0s), 000/100 VUs, 8551 complete and 0 interrupted iterations
|
||||
writes [ 95% ] 000/100 VUs 2m51.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m53.0s), 000/100 VUs, 8601 complete and 0 interrupted iterations
|
||||
writes [ 96% ] 000/100 VUs 2m52.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m54.0s), 000/100 VUs, 8651 complete and 0 interrupted iterations
|
||||
writes [ 96% ] 000/100 VUs 2m53.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m55.0s), 000/100 VUs, 8701 complete and 0 interrupted iterations
|
||||
writes [ 97% ] 000/100 VUs 2m54.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m56.0s), 000/100 VUs, 8751 complete and 0 interrupted iterations
|
||||
writes [ 97% ] 000/100 VUs 2m55.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m57.0s), 000/100 VUs, 8801 complete and 0 interrupted iterations
|
||||
writes [ 98% ] 000/100 VUs 2m56.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m58.0s), 000/100 VUs, 8851 complete and 0 interrupted iterations
|
||||
writes [ 98% ] 000/100 VUs 2m57.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (2m59.0s), 000/100 VUs, 8901 complete and 0 interrupted iterations
|
||||
writes [ 99% ] 000/100 VUs 2m58.0s/3m0s 50.00 iters/s
|
||||
|
||||
running (3m00.0s), 000/100 VUs, 8951 complete and 0 interrupted iterations
|
||||
writes [ 99% ] 000/100 VUs 2m59.0s/3m0s 50.00 iters/s
|
||||
|
||||
|
||||
█ THRESHOLDS
|
||||
|
||||
write_errors
|
||||
✓ 'rate<0.01' rate=0.26%
|
||||
|
||||
|
||||
█ TOTAL RESULTS
|
||||
|
||||
checks_total.......: 18000 99.462116/s
|
||||
checks_succeeded...: 99.73% 17952 out of 18000
|
||||
checks_failed......: 0.26% 48 out of 18000
|
||||
|
||||
✗ status is 201
|
||||
↳ 99% — ✓ 8976 / ✗ 24
|
||||
✗ has message id
|
||||
↳ 99% — ✓ 8976 / ✗ 24
|
||||
|
||||
CUSTOM
|
||||
write_errors...................: 0.26% 24 out of 9000
|
||||
write_latency_ms...............: avg=17.36ms min=2.67ms med=4.21ms max=2.19s p(90)=5.33ms p(95)=6.27ms
|
||||
write_total....................: 9000 49.731058/s
|
||||
|
||||
HTTP
|
||||
http_req_duration..............: avg=17.46ms min=2.67ms med=4.21ms max=2.19s p(90)=5.33ms p(95)=6.27ms
|
||||
{ expected_response:true }...: avg=11.91ms min=2.67ms med=4.21ms max=2.19s p(90)=5.31ms p(95)=6.17ms
|
||||
http_req_failed................: 0.26% 24 out of 9003
|
||||
http_reqs......................: 9003 49.747635/s
|
||||
|
||||
EXECUTION
|
||||
iteration_duration.............: avg=17.41ms min=2.67ms med=4.24ms max=2.19s p(90)=5.48ms p(95)=6.4ms
|
||||
iterations.....................: 9000 49.731058/s
|
||||
vus............................: 0 min=0 max=34
|
||||
vus_max........................: 100 min=100 max=100
|
||||
|
||||
NETWORK
|
||||
data_received..................: 4.0 MB 22 kB/s
|
||||
data_sent......................: 2.9 MB 16 kB/s
|
||||
|
||||
|
||||
|
||||
|
||||
running (3m01.0s), 000/100 VUs, 9000 complete and 0 interrupted iterations
|
||||
writes ✓ [ 100% ] 000/100 VUs 3m0s 50.00 iters/s
|
||||
>>> эксперимент завершён. summary: evidence/k6-rolling.json
|
||||
@@ -0,0 +1,26 @@
|
||||
# Лабораторная 3 — graceful drain на SIGTERM
|
||||
# Дата: 2026-10-07
|
||||
# Commit: a34c6e8
|
||||
# Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
# Метод: docker stop <container> + замер wall-clock + логи контейнера
|
||||
|
||||
# Замер 1 (api-2):
|
||||
# stop wall-clock seconds: 3.88
|
||||
# ожидаемое: ~3 c (SHUTDOWN_DRAIN_SECONDS) + 0.3-0.8 c на srv.Shutdown
|
||||
|
||||
# Логи api-2:
|
||||
# 18:41:53 Получен сигнал завершения; readiness выключен, drain 3s
|
||||
# 18:41:54 [GIN] 503 | GET "/health/ready" ← readiness мгновенно вернул 503
|
||||
# 18:41:56 Drain завершён, останавливаем HTTP-сервер...
|
||||
# 18:41:56 Сервер остановлен
|
||||
# 18:41:56 api-2 exited with code 0
|
||||
|
||||
# Логи api-1 (второй прогон, другая реплика):
|
||||
# 18:42:14 Получен сигнал завершения; readiness выключен, drain 3s
|
||||
# 18:42:16 [GIN] 503 | GET "/health/ready"
|
||||
# 18:42:17 Drain завершён, останавливаем HTTP-сервер...
|
||||
# 18:42:17 Сервер остановлен
|
||||
# 18:42:17 api-1 exited with code 0
|
||||
|
||||
# Вывод: обе реплики корректно снимают readiness до остановки HTTP-сервера,
|
||||
# ждут SHUTDOWN_DRAIN_SECONDS и завершаются с кодом 0.
|
||||
@@ -0,0 +1,12 @@
|
||||
# Лабораторная 3 — тест отказа (failover), прогон 2 (целевая реплика отличается от прогона 1)
|
||||
# Дата: 2026-10-07
|
||||
# Commit: a34c6e8
|
||||
# Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
# Команда: make test-failover ACTION_SCRIPT=scripts/stop-one.cmd
|
||||
# Пороги: first_recovery_seconds <= 10; observed_instances_before >= 2
|
||||
# Цель: доказать, что остановить можно любую реплику, а не только первую
|
||||
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.cmd" --base-url "http://localhost:8080"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 92, "failed_attempts": 2, "first_recovery_seconds": 2.487}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,12 @@
|
||||
# Лабораторная 3 — тест отказа (failover), прогон 1
|
||||
# Дата: 2026-10-07
|
||||
# Commit: a34c6e8
|
||||
# Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
# Команда: make test-failover ACTION_SCRIPT=scripts/stop-one.cmd
|
||||
# Пороги: first_recovery_seconds <= 10; observed_instances_before >= 2
|
||||
# Примечание: лог восстановлен из вывода терминала (первый прогон не был сохранён через tee)
|
||||
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.cmd" --base-url "http://localhost:8080"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 76, "failed_attempts": 3, "first_recovery_seconds": 2.466}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
@@ -0,0 +1,11 @@
|
||||
# Лабораторная 3 — тест сохранности данных (persistence)
|
||||
# Дата: 2026-10-07
|
||||
# Commit: a34c6e8
|
||||
# Хост: Windows 10, Docker Desktop (бэкенд WSL2)
|
||||
# Команда: make test-persistence ACTION_SCRIPT=scripts/restart.cmd
|
||||
# Action-скрипт: scripts/restart.cmd -> docker compose down && docker compose up -d
|
||||
# Примечание: .cmd — локальная обёртка для Windows; на Linux используется scripts/restart.sh
|
||||
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.cmd" --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.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 184 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
@@ -0,0 +1,162 @@
|
||||
{
|
||||
"setup_data": {
|
||||
"chatId": "1e1cfc3a-c08e-4393-a1ba-92ca2aab1ad4",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 28451,
|
||||
"fails": 17750,
|
||||
"name": "status is 201"
|
||||
},
|
||||
"has message id": {
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 28451,
|
||||
"fails": 17750,
|
||||
"name": "has message id",
|
||||
"path": "::has message id"
|
||||
}
|
||||
}
|
||||
},
|
||||
"metrics": {
|
||||
"dropped_iterations": {
|
||||
"count": 1799,
|
||||
"rate": 27.48776131110797
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"p(90)": 8554.35659,
|
||||
"p(95)": 13325.2044,
|
||||
"avg": 5704.310863133391,
|
||||
"min": 16.7645,
|
||||
"med": 5037.764499999999,
|
||||
"max": 16153.2907
|
||||
},
|
||||
"data_received": {
|
||||
"count": 14009308,
|
||||
"rate": 214054.76066581177
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5097699999999997,
|
||||
"avg": 0.047632228811358375,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 6.998
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"med": 4385.9256,
|
||||
"max": 16153.2907,
|
||||
"p(90)": 6107.5859,
|
||||
"p(95)": 12065.4618,
|
||||
"avg": 3725.108470284136,
|
||||
"min": 0
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 17750,
|
||||
"fails": 28454,
|
||||
"value": 0.38416587308458144
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 46204,
|
||||
"rate": 705.9724978423751
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 3724.806842359905,
|
||||
"min": 0,
|
||||
"med": 4385.92295,
|
||||
"max": 16153.2907,
|
||||
"p(90)": 6107.584559999999,
|
||||
"p(95)": 12064.898414999994
|
||||
},
|
||||
"iteration_duration": {
|
||||
"min": 0,
|
||||
"med": 4385.9256,
|
||||
"max": 16153.2907,
|
||||
"p(90)": 6107.9711,
|
||||
"p(95)": 12065.4618,
|
||||
"avg": 3725.735250278083
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 3121,
|
||||
"min": 1600,
|
||||
"max": 3121
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 17750,
|
||||
"fails": 28451,
|
||||
"thresholds": {
|
||||
"rate<0.01": true
|
||||
},
|
||||
"value": 0.3841908183805545
|
||||
},
|
||||
"iterations": {
|
||||
"count": 46201,
|
||||
"rate": 705.9266594410781
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.13397533763310535,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 47.2859,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.9997
|
||||
},
|
||||
"http_req_sending": {
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 78.3631,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.05702772920093503
|
||||
},
|
||||
"write_total": {
|
||||
"count": 46201,
|
||||
"rate": 705.9266594410781
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"checks": {
|
||||
"fails": 35500,
|
||||
"passes": 56902,
|
||||
"value": 0.6158091816194454
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"avg": 0.15823574149424294,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 47.2859,
|
||||
"p(90)": 0.5224,
|
||||
"p(95)": 1.0005
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 14752842,
|
||||
"rate": 225415.56395580253
|
||||
},
|
||||
"vus": {
|
||||
"value": 607,
|
||||
"min": 0,
|
||||
"max": 3061
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 3724.9115023179243,
|
||||
"min": 0,
|
||||
"med": 4385.924300000001,
|
||||
"max": 16153.2907,
|
||||
"p(90)": 6107.58557,
|
||||
"p(95)": 12064.898414999994
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
{
|
||||
"setup_data": {
|
||||
"chatId": "771f940d-484c-4a56-afac-dfaaf50e27b5",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"fails": 18179,
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 26673
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 26673,
|
||||
"fails": 18179
|
||||
}
|
||||
}
|
||||
},
|
||||
"metrics": {
|
||||
"http_req_waiting": {
|
||||
"p(95)": 13873.592879999998,
|
||||
"avg": 3136.833134669494,
|
||||
"min": 0,
|
||||
"med": 1680.7704,
|
||||
"max": 17731.4826,
|
||||
"p(90)": 9671.402439999996
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2099.3693,
|
||||
"p(90)": 0.0153,
|
||||
"p(95)": 0.9483899999999507,
|
||||
"avg": 0.25878698695797525
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 3141,
|
||||
"min": 1600,
|
||||
"max": 3141
|
||||
},
|
||||
"checks": {
|
||||
"passes": 53346,
|
||||
"fails": 36358,
|
||||
"value": 0.5946892000356728
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 44855,
|
||||
"rate": 688.7998976039945
|
||||
},
|
||||
"dropped_iterations": {
|
||||
"rate": 48.35650156180981,
|
||||
"count": 3149
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 3137.9256141767987,
|
||||
"min": 0,
|
||||
"med": 1680.7807,
|
||||
"max": 17731.4826,
|
||||
"p(90)": 9671.802559999998,
|
||||
"p(95)": 13873.592879999998
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"min": 10.8977,
|
||||
"med": 1866.1044,
|
||||
"max": 17731.4826,
|
||||
"p(90)": 13709.7933,
|
||||
"p(95)": 16626.5471,
|
||||
"avg": 4582.5020974209
|
||||
},
|
||||
"vus": {
|
||||
"min": 28,
|
||||
"max": 3102,
|
||||
"value": 230
|
||||
},
|
||||
"http_req_sending": {
|
||||
"max": 1443.3826,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.9995,
|
||||
"avg": 0.8336925203433269,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 18179,
|
||||
"fails": 26676,
|
||||
"value": 0.4052836918961097
|
||||
},
|
||||
"iteration_duration": {
|
||||
"min": 0.5124,
|
||||
"med": 1680.8745,
|
||||
"max": 17732.052,
|
||||
"p(90)": 9673.180170000005,
|
||||
"p(95)": 13873.624469999999,
|
||||
"avg": 3142.14869085662
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"p(95)": 1.0017,
|
||||
"avg": 0.548296205551222,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 235.7058,
|
||||
"p(90)": 0.9896199999999997
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 14274639,
|
||||
"rate": 219203.4306439413
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"p(95)": 13873.624469999999,
|
||||
"avg": 3138.1174555961898,
|
||||
"min": 0,
|
||||
"med": 1680.8027,
|
||||
"max": 17731.4826,
|
||||
"p(90)": 9672.275990000004
|
||||
},
|
||||
"iterations": {
|
||||
"count": 44852,
|
||||
"rate": 688.753829168083
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 18179,
|
||||
"fails": 26673,
|
||||
"thresholds": {
|
||||
"rate<0.01": true
|
||||
},
|
||||
"value": 0.4053107999643271
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(90)": 0.9998,
|
||||
"p(95)": 1.9988,
|
||||
"avg": 1.127186944599257,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1099.8935
|
||||
},
|
||||
"write_total": {
|
||||
"count": 44852,
|
||||
"rate": 688.753829168083
|
||||
},
|
||||
"data_received": {
|
||||
"count": 14254954,
|
||||
"rate": 218901.1449236351
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
config,run,metric,value
|
||||
rep1-cpu1.0-mem512M,1,http_reqs.rate,389.8183753976681
|
||||
rep1-cpu1.0-mem512M,1,write_total.count,48001
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.avg,7.19880763942424
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.p(90),5.0006
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.p(95),7.9982
|
||||
rep1-cpu1.0-mem512M,1,write_latency_ms.max,319.5508
|
||||
rep1-cpu1.0-mem512M,2,http_reqs.rate,395.21056400043983
|
||||
rep1-cpu1.0-mem512M,2,write_total.count,48001
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.avg,3.5735801254140336
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.p(90),4.1356
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.p(95),4.4514
|
||||
rep1-cpu1.0-mem512M,2,write_latency_ms.max,64.4719
|
||||
rep1-cpu1.0-mem512M,3,http_reqs.rate,398.43841986603536
|
||||
rep1-cpu1.0-mem512M,3,write_total.count,48001
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.avg,3.5612986250285945
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.p(90),4.0433
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.p(95),4.3335
|
||||
rep1-cpu1.0-mem512M,3,write_latency_ms.max,71.5367
|
||||
rep2-cpu0.5-mem256M,1,http_reqs.rate,397.26271350523626
|
||||
rep2-cpu0.5-mem256M,1,write_total.count,48000
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.avg,4.7920399583333175
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(90),4.2249
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.p(95),4.8426
|
||||
rep2-cpu0.5-mem256M,1,write_latency_ms.max,404.304
|
||||
rep2-cpu0.5-mem256M,2,http_reqs.rate,397.24748472370374
|
||||
rep2-cpu0.5-mem256M,2,write_total.count,48001
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.avg,3.975309997708413
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(90),4.8223
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.p(95),5.2307
|
||||
rep2-cpu0.5-mem256M,2,write_latency_ms.max,78.2792
|
||||
rep2-cpu0.5-mem256M,3,http_reqs.rate,398.07490333247614
|
||||
rep2-cpu0.5-mem256M,3,write_total.count,48001
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.avg,3.8704089081477413
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.p(90),4.3342
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.p(95),5.0008
|
||||
rep2-cpu0.5-mem256M,3,write_latency_ms.max,90.0337
|
||||
rep4-cpu0.25-mem128M,1,http_reqs.rate,394.44582642046197
|
||||
rep4-cpu0.25-mem128M,1,write_total.count,48000
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.avg,10.986670685416716
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.p(90),4.32282
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.p(95),5.685264999999916
|
||||
rep4-cpu0.25-mem128M,1,write_latency_ms.max,1153.6306
|
||||
rep4-cpu0.25-mem128M,2,http_reqs.rate,394.8533405884855
|
||||
rep4-cpu0.25-mem128M,2,write_total.count,48000
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.avg,4.591153127083303
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.p(90),4.2905299999999995
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.p(95),5.0021
|
||||
rep4-cpu0.25-mem128M,2,write_latency_ms.max,530.6913
|
||||
rep4-cpu0.25-mem128M,3,http_reqs.rate,393.6534825213471
|
||||
rep4-cpu0.25-mem128M,3,write_total.count,48000
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.avg,4.116295872916678
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.p(90),4.269909999999999
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.p(95),5.0002
|
||||
rep4-cpu0.25-mem128M,3,write_latency_ms.max,159.1295
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"write_total": {
|
||||
"rate": 389.7940137793406,
|
||||
"count": 48001
|
||||
},
|
||||
"iteration_duration": {
|
||||
"max": 319.5508,
|
||||
"p(90)": 5.0019,
|
||||
"p(95)": 8.0007,
|
||||
"avg": 7.300485116976765,
|
||||
"min": 1.9998,
|
||||
"med": 3.6818
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.0023834722106491116,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.5831,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.049724204232980615,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.0035,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5181
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 48004,
|
||||
"value": 0
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 7.263420796183727,
|
||||
"min": 1.9988,
|
||||
"med": 3.6119000000000003,
|
||||
"max": 1602.4323,
|
||||
"p(90)": 5.0006,
|
||||
"p(95)": 7.9983
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.007017383968002663,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 9.9991,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"max": 1602.4323,
|
||||
"p(90)": 5,
|
||||
"p(95)": 7.89252499999997,
|
||||
"avg": 7.211313119740036,
|
||||
"min": 1.9979,
|
||||
"med": 3.29235
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"med": 3.6116,
|
||||
"max": 319.5508,
|
||||
"p(90)": 5.0006,
|
||||
"p(95)": 7.9982,
|
||||
"avg": 7.19880763942424,
|
||||
"min": 1.9988
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 15284037,
|
||||
"rate": 124114.62529909692
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 800,
|
||||
"min": 800,
|
||||
"max": 800
|
||||
},
|
||||
"http_reqs": {
|
||||
"rate": 389.8183753976681,
|
||||
"count": 48004
|
||||
},
|
||||
"data_received": {
|
||||
"count": 21587294,
|
||||
"rate": 175300.47238379778
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"avg": 7.263420796183727,
|
||||
"min": 1.9988,
|
||||
"med": 3.6119000000000003,
|
||||
"max": 1602.4323,
|
||||
"p(90)": 5.0006,
|
||||
"p(95)": 7.9983
|
||||
},
|
||||
"iterations": {
|
||||
"rate": 389.7940137793406,
|
||||
"count": 48001
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96002,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48001,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"vus": {
|
||||
"value": 1,
|
||||
"min": 0,
|
||||
"max": 42
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0055500124989584215,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 9.067
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"token": "REDACTED",
|
||||
"chatId": "a7687238-af25-4716-85e0-ed9fd7f9cfd1"
|
||||
},
|
||||
"root_group": {
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 48001,
|
||||
"fails": 0,
|
||||
"name": "has message id",
|
||||
"path": "::has message id"
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545271,mtusi-messenger-lab3-lb-1,0.03%,8.082MiB / 7.691GiB
|
||||
1791545271,mtusi-messenger-lab3-api-1,101.70%,100.4MiB / 512MiB
|
||||
1791545271,mtusi-messenger-lab3-postgres-1,2.88%,23.13MiB / 1GiB
|
||||
1791545271,mtusi-messenger-lab3-redis-1,0.40%,5.148MiB / 256MiB
|
||||
1791545276,mtusi-messenger-lab3-lb-1,12.04%,13.41MiB / 7.691GiB
|
||||
1791545276,mtusi-messenger-lab3-api-1,65.13%,137MiB / 512MiB
|
||||
1791545276,mtusi-messenger-lab3-postgres-1,69.25%,47.95MiB / 1GiB
|
||||
1791545276,mtusi-messenger-lab3-redis-1,4.93%,5.598MiB / 256MiB
|
||||
1791545280,mtusi-messenger-lab3-lb-1,11.13%,13.4MiB / 7.691GiB
|
||||
1791545280,mtusi-messenger-lab3-api-1,66.75%,137.8MiB / 512MiB
|
||||
1791545280,mtusi-messenger-lab3-postgres-1,53.06%,50.26MiB / 1GiB
|
||||
1791545280,mtusi-messenger-lab3-redis-1,4.16%,5.477MiB / 256MiB
|
||||
1791545285,mtusi-messenger-lab3-lb-1,12.44%,13.43MiB / 7.691GiB
|
||||
1791545285,mtusi-messenger-lab3-api-1,70.28%,118.9MiB / 512MiB
|
||||
1791545285,mtusi-messenger-lab3-postgres-1,54.31%,51.03MiB / 1GiB
|
||||
1791545285,mtusi-messenger-lab3-redis-1,9.26%,5.695MiB / 256MiB
|
||||
1791545289,mtusi-messenger-lab3-lb-1,12.14%,13.18MiB / 7.691GiB
|
||||
1791545289,mtusi-messenger-lab3-api-1,70.26%,23.66MiB / 512MiB
|
||||
1791545289,mtusi-messenger-lab3-postgres-1,65.68%,52.91MiB / 1GiB
|
||||
1791545289,mtusi-messenger-lab3-redis-1,7.26%,5.617MiB / 256MiB
|
||||
1791545294,mtusi-messenger-lab3-lb-1,11.18%,13.25MiB / 7.691GiB
|
||||
1791545294,mtusi-messenger-lab3-api-1,64.37%,22.52MiB / 512MiB
|
||||
1791545294,mtusi-messenger-lab3-postgres-1,51.83%,55.24MiB / 1GiB
|
||||
1791545294,mtusi-messenger-lab3-redis-1,4.52%,5.859MiB / 256MiB
|
||||
1791545298,mtusi-messenger-lab3-lb-1,11.15%,13.53MiB / 7.691GiB
|
||||
1791545298,mtusi-messenger-lab3-api-1,56.33%,22.39MiB / 512MiB
|
||||
1791545298,mtusi-messenger-lab3-postgres-1,99.20%,74.34MiB / 1GiB
|
||||
1791545298,mtusi-messenger-lab3-redis-1,4.14%,5.758MiB / 256MiB
|
||||
1791545303,mtusi-messenger-lab3-lb-1,10.59%,13.34MiB / 7.691GiB
|
||||
1791545303,mtusi-messenger-lab3-api-1,66.57%,21.57MiB / 512MiB
|
||||
1791545303,mtusi-messenger-lab3-postgres-1,52.18%,59.31MiB / 1GiB
|
||||
1791545303,mtusi-messenger-lab3-redis-1,4.10%,5.859MiB / 256MiB
|
||||
1791545307,mtusi-messenger-lab3-lb-1,10.88%,13.51MiB / 7.691GiB
|
||||
1791545307,mtusi-messenger-lab3-api-1,62.86%,21.62MiB / 512MiB
|
||||
1791545307,mtusi-messenger-lab3-postgres-1,56.18%,61.1MiB / 1GiB
|
||||
1791545307,mtusi-messenger-lab3-redis-1,4.08%,5.488MiB / 256MiB
|
||||
1791545312,mtusi-messenger-lab3-lb-1,10.73%,13.01MiB / 7.691GiB
|
||||
1791545312,mtusi-messenger-lab3-api-1,64.23%,21.47MiB / 512MiB
|
||||
1791545312,mtusi-messenger-lab3-postgres-1,57.57%,62.07MiB / 1GiB
|
||||
1791545312,mtusi-messenger-lab3-redis-1,6.71%,5.547MiB / 256MiB
|
||||
1791545316,mtusi-messenger-lab3-lb-1,10.39%,13.39MiB / 7.691GiB
|
||||
1791545316,mtusi-messenger-lab3-api-1,60.73%,21.09MiB / 512MiB
|
||||
1791545316,mtusi-messenger-lab3-postgres-1,49.29%,64.02MiB / 1GiB
|
||||
1791545316,mtusi-messenger-lab3-redis-1,3.91%,6.02MiB / 256MiB
|
||||
1791545321,mtusi-messenger-lab3-lb-1,10.43%,13.42MiB / 7.691GiB
|
||||
1791545321,mtusi-messenger-lab3-api-1,61.19%,21.58MiB / 512MiB
|
||||
1791545321,mtusi-messenger-lab3-postgres-1,47.59%,65.51MiB / 1GiB
|
||||
1791545321,mtusi-messenger-lab3-redis-1,3.86%,5.887MiB / 256MiB
|
||||
1791545325,mtusi-messenger-lab3-lb-1,10.34%,13.31MiB / 7.691GiB
|
||||
1791545325,mtusi-messenger-lab3-api-1,65.23%,21.91MiB / 512MiB
|
||||
1791545325,mtusi-messenger-lab3-postgres-1,47.04%,67.1MiB / 1GiB
|
||||
1791545325,mtusi-messenger-lab3-redis-1,3.90%,5.742MiB / 256MiB
|
||||
1791545330,mtusi-messenger-lab3-lb-1,10.10%,13.34MiB / 7.691GiB
|
||||
1791545330,mtusi-messenger-lab3-api-1,64.30%,21.4MiB / 512MiB
|
||||
1791545330,mtusi-messenger-lab3-postgres-1,49.29%,68.53MiB / 1GiB
|
||||
1791545330,mtusi-messenger-lab3-redis-1,6.67%,5.695MiB / 256MiB
|
||||
1791545334,mtusi-messenger-lab3-lb-1,10.49%,13.66MiB / 7.691GiB
|
||||
1791545334,mtusi-messenger-lab3-api-1,60.87%,21.65MiB / 512MiB
|
||||
1791545334,mtusi-messenger-lab3-postgres-1,51.72%,69.92MiB / 1GiB
|
||||
1791545334,mtusi-messenger-lab3-redis-1,3.80%,5.734MiB / 256MiB
|
||||
1791545339,mtusi-messenger-lab3-lb-1,10.49%,13.65MiB / 7.691GiB
|
||||
1791545339,mtusi-messenger-lab3-api-1,61.10%,21.52MiB / 512MiB
|
||||
1791545339,mtusi-messenger-lab3-postgres-1,48.63%,72.11MiB / 1GiB
|
||||
1791545339,mtusi-messenger-lab3-redis-1,3.91%,5.91MiB / 256MiB
|
||||
1791545343,mtusi-messenger-lab3-lb-1,10.43%,13.54MiB / 7.691GiB
|
||||
1791545343,mtusi-messenger-lab3-api-1,58.69%,20.81MiB / 512MiB
|
||||
1791545343,mtusi-messenger-lab3-postgres-1,44.32%,74.35MiB / 1GiB
|
||||
1791545343,mtusi-messenger-lab3-redis-1,3.68%,5.602MiB / 256MiB
|
||||
1791545348,mtusi-messenger-lab3-lb-1,9.69%,13.94MiB / 7.691GiB
|
||||
1791545348,mtusi-messenger-lab3-api-1,58.25%,21.37MiB / 512MiB
|
||||
1791545348,mtusi-messenger-lab3-postgres-1,45.71%,75.57MiB / 1GiB
|
||||
1791545348,mtusi-messenger-lab3-redis-1,3.73%,5.996MiB / 256MiB
|
||||
1791545352,mtusi-messenger-lab3-lb-1,10.41%,13.76MiB / 7.691GiB
|
||||
1791545352,mtusi-messenger-lab3-api-1,58.03%,20.98MiB / 512MiB
|
||||
1791545352,mtusi-messenger-lab3-postgres-1,47.91%,77.48MiB / 1GiB
|
||||
1791545352,mtusi-messenger-lab3-redis-1,3.83%,5.551MiB / 256MiB
|
||||
1791545357,mtusi-messenger-lab3-lb-1,10.21%,13.65MiB / 7.691GiB
|
||||
1791545357,mtusi-messenger-lab3-api-1,60.14%,20.7MiB / 512MiB
|
||||
1791545357,mtusi-messenger-lab3-postgres-1,46.41%,78.37MiB / 1GiB
|
||||
1791545357,mtusi-messenger-lab3-redis-1,3.78%,5.414MiB / 256MiB
|
||||
1791545361,mtusi-messenger-lab3-lb-1,10.55%,13.04MiB / 7.691GiB
|
||||
1791545361,mtusi-messenger-lab3-api-1,58.42%,21.19MiB / 512MiB
|
||||
1791545361,mtusi-messenger-lab3-postgres-1,85.48%,98.86MiB / 1GiB
|
||||
1791545361,mtusi-messenger-lab3-redis-1,5.67%,5.125MiB / 256MiB
|
||||
1791545365,mtusi-messenger-lab3-lb-1,10.18%,13.16MiB / 7.691GiB
|
||||
1791545365,mtusi-messenger-lab3-api-1,59.45%,20MiB / 512MiB
|
||||
1791545365,mtusi-messenger-lab3-postgres-1,45.00%,81.89MiB / 1GiB
|
||||
1791545365,mtusi-messenger-lab3-redis-1,3.81%,5.75MiB / 256MiB
|
||||
1791545370,mtusi-messenger-lab3-lb-1,10.07%,13.48MiB / 7.691GiB
|
||||
1791545370,mtusi-messenger-lab3-api-1,62.40%,18.91MiB / 512MiB
|
||||
1791545370,mtusi-messenger-lab3-postgres-1,44.68%,83.02MiB / 1GiB
|
||||
1791545370,mtusi-messenger-lab3-redis-1,3.81%,5.375MiB / 256MiB
|
||||
1791545374,mtusi-messenger-lab3-lb-1,10.10%,13.38MiB / 7.691GiB
|
||||
1791545374,mtusi-messenger-lab3-api-1,62.77%,19MiB / 512MiB
|
||||
1791545374,mtusi-messenger-lab3-postgres-1,44.90%,84.21MiB / 1GiB
|
||||
1791545374,mtusi-messenger-lab3-redis-1,3.72%,4.93MiB / 256MiB
|
||||
1791545379,mtusi-messenger-lab3-lb-1,10.19%,12.91MiB / 7.691GiB
|
||||
1791545379,mtusi-messenger-lab3-api-1,60.14%,19.12MiB / 512MiB
|
||||
1791545379,mtusi-messenger-lab3-postgres-1,50.20%,85.37MiB / 1GiB
|
||||
1791545379,mtusi-messenger-lab3-redis-1,6.59%,5.777MiB / 256MiB
|
||||
1791545383,mtusi-messenger-lab3-lb-1,10.39%,13.03MiB / 7.691GiB
|
||||
1791545383,mtusi-messenger-lab3-api-1,60.48%,18.64MiB / 512MiB
|
||||
1791545383,mtusi-messenger-lab3-postgres-1,56.06%,88.52MiB / 1GiB
|
||||
1791545383,mtusi-messenger-lab3-redis-1,3.86%,5.777MiB / 256MiB
|
||||
1791545388,mtusi-messenger-lab3-lb-1,9.89%,12.92MiB / 7.691GiB
|
||||
1791545388,mtusi-messenger-lab3-api-1,60.52%,19.09MiB / 512MiB
|
||||
1791545388,mtusi-messenger-lab3-postgres-1,46.53%,89.93MiB / 1GiB
|
||||
1791545388,mtusi-messenger-lab3-redis-1,3.75%,5.406MiB / 256MiB
|
||||
1791545392,mtusi-messenger-lab3-lb-1,14.16%,9.742MiB / 7.691GiB
|
||||
1791545392,mtusi-messenger-lab3-api-1,40.99%,18.61MiB / 512MiB
|
||||
1791545392,mtusi-messenger-lab3-postgres-1,46.01%,91.22MiB / 1GiB
|
||||
1791545392,mtusi-messenger-lab3-redis-1,3.81%,5.363MiB / 256MiB
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"data_received": {
|
||||
"count": 21587296,
|
||||
"rate": 177725.34429223477
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"med": 3.1774,
|
||||
"max": 64.4719,
|
||||
"p(90)": 4.1356,
|
||||
"p(95)": 4.4514,
|
||||
"avg": 3.5735801254140336,
|
||||
"min": 1.9965
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.0009758603449712524,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 8.992,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 48004,
|
||||
"value": 0
|
||||
},
|
||||
"iteration_duration": {
|
||||
"avg": 3.6481168704818554,
|
||||
"min": 1.997,
|
||||
"med": 3.2543,
|
||||
"max": 64.4719,
|
||||
"p(90)": 4.2228,
|
||||
"p(95)": 4.7818
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 48004,
|
||||
"rate": 395.21056400043983
|
||||
},
|
||||
"http_req_sending": {
|
||||
"avg": 0.0007231668194317143,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.5169,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.04304010707441054,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.4796,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5147
|
||||
},
|
||||
"write_total": {
|
||||
"count": 48001,
|
||||
"rate": 395.18586539840663
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48001,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"med": 0,
|
||||
"max": 2.0018,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0005484980418298475,
|
||||
"min": 0
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96002,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 15284041,
|
||||
"rate": 125831.48203932685
|
||||
},
|
||||
"http_req_duration": {
|
||||
"max": 886.7193,
|
||||
"p(90)": 4.136990000000003,
|
||||
"p(95)": 4.454949999999998,
|
||||
"avg": 3.6035606241146425,
|
||||
"min": 1.9965,
|
||||
"med": 3.1774
|
||||
},
|
||||
"iterations": {
|
||||
"rate": 395.18586539840663,
|
||||
"count": 48001
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"p(95)": 4.454949999999998,
|
||||
"avg": 3.6035606241146425,
|
||||
"min": 1.9965,
|
||||
"med": 3.1774,
|
||||
"max": 886.7193,
|
||||
"p(90)": 4.136990000000003
|
||||
},
|
||||
"vus": {
|
||||
"min": 0,
|
||||
"max": 10,
|
||||
"value": 2
|
||||
},
|
||||
"vus_max": {
|
||||
"max": 800,
|
||||
"value": 800,
|
||||
"min": 800
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"p(90)": 4.003,
|
||||
"p(95)": 4.317,
|
||||
"avg": 3.5597973502207965,
|
||||
"min": 1.9965,
|
||||
"med": 3.1599500000000003,
|
||||
"max": 886.7193
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"token": "REDACTED",
|
||||
"chatId": "3826e574-42b0-4316-a90f-1dad0a5c6b9d"
|
||||
},
|
||||
"root_group": {
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"fails": 0,
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 48001
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545395,mtusi-messenger-lab3-lb-1,6.82%,10.82MiB / 7.691GiB
|
||||
1791545395,mtusi-messenger-lab3-api-1,80.41%,141.6MiB / 512MiB
|
||||
1791545395,mtusi-messenger-lab3-postgres-1,38.91%,92.45MiB / 1GiB
|
||||
1791545395,mtusi-messenger-lab3-redis-1,6.36%,5.203MiB / 256MiB
|
||||
1791545399,mtusi-messenger-lab3-lb-1,10.21%,13.22MiB / 7.691GiB
|
||||
1791545399,mtusi-messenger-lab3-api-1,60.76%,21.86MiB / 512MiB
|
||||
1791545399,mtusi-messenger-lab3-postgres-1,45.66%,93.43MiB / 1GiB
|
||||
1791545399,mtusi-messenger-lab3-redis-1,3.80%,5.371MiB / 256MiB
|
||||
1791545403,mtusi-messenger-lab3-lb-1,9.58%,12.93MiB / 7.691GiB
|
||||
1791545403,mtusi-messenger-lab3-api-1,62.42%,21.37MiB / 512MiB
|
||||
1791545403,mtusi-messenger-lab3-postgres-1,44.79%,95.41MiB / 1GiB
|
||||
1791545403,mtusi-messenger-lab3-redis-1,3.82%,5.215MiB / 256MiB
|
||||
1791545408,mtusi-messenger-lab3-lb-1,9.42%,12.79MiB / 7.691GiB
|
||||
1791545408,mtusi-messenger-lab3-api-1,58.71%,21.25MiB / 512MiB
|
||||
1791545408,mtusi-messenger-lab3-postgres-1,43.88%,96.85MiB / 1GiB
|
||||
1791545408,mtusi-messenger-lab3-redis-1,3.63%,5.867MiB / 256MiB
|
||||
1791545412,mtusi-messenger-lab3-lb-1,9.69%,13.24MiB / 7.691GiB
|
||||
1791545412,mtusi-messenger-lab3-api-1,61.32%,22.73MiB / 512MiB
|
||||
1791545412,mtusi-messenger-lab3-postgres-1,44.77%,98.29MiB / 1GiB
|
||||
1791545412,mtusi-messenger-lab3-redis-1,5.75%,5.492MiB / 256MiB
|
||||
1791545417,mtusi-messenger-lab3-lb-1,9.67%,12.99MiB / 7.691GiB
|
||||
1791545417,mtusi-messenger-lab3-api-1,59.71%,20.75MiB / 512MiB
|
||||
1791545417,mtusi-messenger-lab3-postgres-1,45.79%,100.2MiB / 1GiB
|
||||
1791545417,mtusi-messenger-lab3-redis-1,5.92%,5.512MiB / 256MiB
|
||||
1791545421,mtusi-messenger-lab3-lb-1,9.60%,12.91MiB / 7.691GiB
|
||||
1791545421,mtusi-messenger-lab3-api-1,59.94%,20.58MiB / 512MiB
|
||||
1791545421,mtusi-messenger-lab3-postgres-1,44.16%,102.5MiB / 1GiB
|
||||
1791545421,mtusi-messenger-lab3-redis-1,3.61%,5.754MiB / 256MiB
|
||||
1791545426,mtusi-messenger-lab3-lb-1,9.81%,12.98MiB / 7.691GiB
|
||||
1791545426,mtusi-messenger-lab3-api-1,60.02%,21.1MiB / 512MiB
|
||||
1791545426,mtusi-messenger-lab3-postgres-1,45.90%,104.5MiB / 1GiB
|
||||
1791545426,mtusi-messenger-lab3-redis-1,3.81%,5.801MiB / 256MiB
|
||||
1791545430,mtusi-messenger-lab3-lb-1,9.52%,12.88MiB / 7.691GiB
|
||||
1791545430,mtusi-messenger-lab3-api-1,58.96%,21.2MiB / 512MiB
|
||||
1791545430,mtusi-messenger-lab3-postgres-1,43.75%,106.5MiB / 1GiB
|
||||
1791545430,mtusi-messenger-lab3-redis-1,3.71%,5.512MiB / 256MiB
|
||||
1791545435,mtusi-messenger-lab3-lb-1,9.73%,13.01MiB / 7.691GiB
|
||||
1791545435,mtusi-messenger-lab3-api-1,61.72%,20.37MiB / 512MiB
|
||||
1791545435,mtusi-messenger-lab3-postgres-1,44.66%,107.6MiB / 1GiB
|
||||
1791545435,mtusi-messenger-lab3-redis-1,5.58%,5.234MiB / 256MiB
|
||||
1791545439,mtusi-messenger-lab3-lb-1,9.72%,13.24MiB / 7.691GiB
|
||||
1791545439,mtusi-messenger-lab3-api-1,60.33%,20.73MiB / 512MiB
|
||||
1791545439,mtusi-messenger-lab3-postgres-1,48.28%,108.9MiB / 1GiB
|
||||
1791545439,mtusi-messenger-lab3-redis-1,3.80%,5.281MiB / 256MiB
|
||||
1791545444,mtusi-messenger-lab3-lb-1,9.83%,12.72MiB / 7.691GiB
|
||||
1791545444,mtusi-messenger-lab3-api-1,60.25%,20.9MiB / 512MiB
|
||||
1791545444,mtusi-messenger-lab3-postgres-1,45.03%,110.9MiB / 1GiB
|
||||
1791545444,mtusi-messenger-lab3-redis-1,3.78%,5.742MiB / 256MiB
|
||||
1791545448,mtusi-messenger-lab3-lb-1,9.55%,12.81MiB / 7.691GiB
|
||||
1791545448,mtusi-messenger-lab3-api-1,60.04%,20.5MiB / 512MiB
|
||||
1791545448,mtusi-messenger-lab3-postgres-1,45.40%,113.3MiB / 1GiB
|
||||
1791545448,mtusi-messenger-lab3-redis-1,3.78%,5.348MiB / 256MiB
|
||||
1791545453,mtusi-messenger-lab3-lb-1,10.18%,12.83MiB / 7.691GiB
|
||||
1791545453,mtusi-messenger-lab3-api-1,64.85%,20.48MiB / 512MiB
|
||||
1791545453,mtusi-messenger-lab3-postgres-1,47.34%,114.7MiB / 1GiB
|
||||
1791545453,mtusi-messenger-lab3-redis-1,4.08%,5.203MiB / 256MiB
|
||||
1791545457,mtusi-messenger-lab3-lb-1,9.66%,12.52MiB / 7.691GiB
|
||||
1791545457,mtusi-messenger-lab3-api-1,61.81%,20.41MiB / 512MiB
|
||||
1791545457,mtusi-messenger-lab3-postgres-1,45.41%,116.7MiB / 1GiB
|
||||
1791545457,mtusi-messenger-lab3-redis-1,3.76%,5.391MiB / 256MiB
|
||||
1791545461,mtusi-messenger-lab3-lb-1,9.72%,13.23MiB / 7.691GiB
|
||||
1791545461,mtusi-messenger-lab3-api-1,63.27%,20.59MiB / 512MiB
|
||||
1791545461,mtusi-messenger-lab3-postgres-1,52.75%,119.1MiB / 1GiB
|
||||
1791545461,mtusi-messenger-lab3-redis-1,5.86%,4.914MiB / 256MiB
|
||||
1791545466,mtusi-messenger-lab3-lb-1,9.80%,12.96MiB / 7.691GiB
|
||||
1791545466,mtusi-messenger-lab3-api-1,59.72%,20.52MiB / 512MiB
|
||||
1791545466,mtusi-messenger-lab3-postgres-1,48.28%,122.4MiB / 1GiB
|
||||
1791545466,mtusi-messenger-lab3-redis-1,3.66%,5.473MiB / 256MiB
|
||||
1791545470,mtusi-messenger-lab3-lb-1,9.77%,12.84MiB / 7.691GiB
|
||||
1791545470,mtusi-messenger-lab3-api-1,59.99%,20.4MiB / 512MiB
|
||||
1791545470,mtusi-messenger-lab3-postgres-1,44.28%,121.5MiB / 1GiB
|
||||
1791545470,mtusi-messenger-lab3-redis-1,3.65%,5.359MiB / 256MiB
|
||||
1791545475,mtusi-messenger-lab3-lb-1,9.79%,13.28MiB / 7.691GiB
|
||||
1791545475,mtusi-messenger-lab3-api-1,60.42%,19.93MiB / 512MiB
|
||||
1791545475,mtusi-messenger-lab3-postgres-1,44.71%,123.1MiB / 1GiB
|
||||
1791545475,mtusi-messenger-lab3-redis-1,3.74%,5.191MiB / 256MiB
|
||||
1791545479,mtusi-messenger-lab3-lb-1,9.39%,12.7MiB / 7.691GiB
|
||||
1791545479,mtusi-messenger-lab3-api-1,58.62%,20.16MiB / 512MiB
|
||||
1791545479,mtusi-messenger-lab3-postgres-1,82.94%,125.3MiB / 1GiB
|
||||
1791545479,mtusi-messenger-lab3-redis-1,3.81%,5.805MiB / 256MiB
|
||||
1791545484,mtusi-messenger-lab3-lb-1,9.61%,13.05MiB / 7.691GiB
|
||||
1791545484,mtusi-messenger-lab3-api-1,58.68%,20.27MiB / 512MiB
|
||||
1791545484,mtusi-messenger-lab3-postgres-1,43.38%,127MiB / 1GiB
|
||||
1791545484,mtusi-messenger-lab3-redis-1,3.63%,5.18MiB / 256MiB
|
||||
1791545488,mtusi-messenger-lab3-lb-1,9.70%,12.93MiB / 7.691GiB
|
||||
1791545488,mtusi-messenger-lab3-api-1,60.00%,20.66MiB / 512MiB
|
||||
1791545488,mtusi-messenger-lab3-postgres-1,47.61%,128.7MiB / 1GiB
|
||||
1791545488,mtusi-messenger-lab3-redis-1,3.66%,5.184MiB / 256MiB
|
||||
1791545493,mtusi-messenger-lab3-lb-1,10.13%,13.02MiB / 7.691GiB
|
||||
1791545493,mtusi-messenger-lab3-api-1,58.64%,20.2MiB / 512MiB
|
||||
1791545493,mtusi-messenger-lab3-postgres-1,44.00%,129.7MiB / 1GiB
|
||||
1791545493,mtusi-messenger-lab3-redis-1,3.67%,5.801MiB / 256MiB
|
||||
1791545497,mtusi-messenger-lab3-lb-1,9.50%,12.52MiB / 7.691GiB
|
||||
1791545497,mtusi-messenger-lab3-api-1,58.74%,20.18MiB / 512MiB
|
||||
1791545497,mtusi-messenger-lab3-postgres-1,44.26%,130.6MiB / 1GiB
|
||||
1791545497,mtusi-messenger-lab3-redis-1,3.81%,5.238MiB / 256MiB
|
||||
1791545502,mtusi-messenger-lab3-lb-1,9.54%,12.38MiB / 7.691GiB
|
||||
1791545502,mtusi-messenger-lab3-api-1,60.94%,20.16MiB / 512MiB
|
||||
1791545502,mtusi-messenger-lab3-postgres-1,44.64%,132.5MiB / 1GiB
|
||||
1791545502,mtusi-messenger-lab3-redis-1,3.64%,5.961MiB / 256MiB
|
||||
1791545506,mtusi-messenger-lab3-lb-1,9.56%,13.36MiB / 7.691GiB
|
||||
1791545506,mtusi-messenger-lab3-api-1,59.52%,20.1MiB / 512MiB
|
||||
1791545506,mtusi-messenger-lab3-postgres-1,45.35%,134.5MiB / 1GiB
|
||||
1791545506,mtusi-messenger-lab3-redis-1,3.72%,5.93MiB / 256MiB
|
||||
1791545511,mtusi-messenger-lab3-lb-1,9.80%,12.95MiB / 7.691GiB
|
||||
1791545511,mtusi-messenger-lab3-api-1,61.34%,19.64MiB / 512MiB
|
||||
1791545511,mtusi-messenger-lab3-postgres-1,46.26%,136.1MiB / 1GiB
|
||||
1791545511,mtusi-messenger-lab3-redis-1,3.79%,6.164MiB / 256MiB
|
||||
1791545515,mtusi-messenger-lab3-lb-1,9.56%,13.17MiB / 7.691GiB
|
||||
1791545515,mtusi-messenger-lab3-api-1,48.38%,145.1MiB / 512MiB
|
||||
1791545515,mtusi-messenger-lab3-postgres-1,3.98%,137.7MiB / 1GiB
|
||||
1791545515,mtusi-messenger-lab3-redis-1,3.77%,6.012MiB / 256MiB
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"write_latency_ms": {
|
||||
"avg": 3.5612986250285945,
|
||||
"min": 1.9966,
|
||||
"med": 3.1786,
|
||||
"max": 71.5367,
|
||||
"p(90)": 4.0433,
|
||||
"p(95)": 4.3335
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 3.5280449004249252,
|
||||
"min": 1.99,
|
||||
"med": 3.16135,
|
||||
"max": 257.2494,
|
||||
"p(90)": 4.0026,
|
||||
"p(95)": 4.29057
|
||||
},
|
||||
"iteration_duration": {
|
||||
"avg": 3.635744090748078,
|
||||
"min": 1.9966,
|
||||
"med": 3.2653,
|
||||
"max": 71.5367,
|
||||
"p(90)": 4.2184,
|
||||
"p(95)": 4.7438
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"avg": 3.57076428422627,
|
||||
"min": 1.9966,
|
||||
"med": 3.1786,
|
||||
"max": 257.2494,
|
||||
"p(90)": 4.043990000000003,
|
||||
"p(95)": 4.33367
|
||||
},
|
||||
"http_req_duration": {
|
||||
"med": 3.1786,
|
||||
"max": 257.2494,
|
||||
"p(90)": 4.043990000000003,
|
||||
"p(95)": 4.33367,
|
||||
"avg": 3.57076428422627,
|
||||
"min": 1.9966
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 48004,
|
||||
"value": 0
|
||||
},
|
||||
"vus": {
|
||||
"value": 2,
|
||||
"min": 1,
|
||||
"max": 12
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48001,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0005998000166652777,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0044
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.042119583784684736,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.4113,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5143
|
||||
},
|
||||
"iterations": {
|
||||
"count": 48001,
|
||||
"rate": 398.4135195398209
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"avg": 0.0010866677776851929,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 9.521,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0
|
||||
},
|
||||
"data_received": {
|
||||
"count": 21587296,
|
||||
"rate": 179176.90416257782
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96002,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"vus_max": {
|
||||
"min": 800,
|
||||
"max": 800,
|
||||
"value": 800
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.0007127676860261646,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.0027,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"write_total": {
|
||||
"count": 48001,
|
||||
"rate": 398.4135195398209
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 48004,
|
||||
"rate": 398.43841986603536
|
||||
},
|
||||
"data_sent": {
|
||||
"rate": 126859.20225830554,
|
||||
"count": 15284041
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "0b41d2de-e877-4417-a4fd-88028e430397",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48001,
|
||||
"fails": 0,
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201"
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545517,mtusi-messenger-lab3-lb-1,11.73%,12.27MiB / 7.691GiB
|
||||
1791545517,mtusi-messenger-lab3-api-1,63.56%,17.84MiB / 512MiB
|
||||
1791545517,mtusi-messenger-lab3-postgres-1,53.43%,138.9MiB / 1GiB
|
||||
1791545517,mtusi-messenger-lab3-redis-1,5.99%,5.637MiB / 256MiB
|
||||
1791545521,mtusi-messenger-lab3-lb-1,9.39%,12.93MiB / 7.691GiB
|
||||
1791545521,mtusi-messenger-lab3-api-1,58.17%,17.45MiB / 512MiB
|
||||
1791545521,mtusi-messenger-lab3-postgres-1,43.39%,139.9MiB / 1GiB
|
||||
1791545521,mtusi-messenger-lab3-redis-1,3.81%,5.637MiB / 256MiB
|
||||
1791545525,mtusi-messenger-lab3-lb-1,9.46%,13.62MiB / 7.691GiB
|
||||
1791545525,mtusi-messenger-lab3-api-1,60.85%,17.96MiB / 512MiB
|
||||
1791545525,mtusi-messenger-lab3-postgres-1,45.93%,141.5MiB / 1GiB
|
||||
1791545525,mtusi-messenger-lab3-redis-1,3.70%,5.246MiB / 256MiB
|
||||
1791545529,mtusi-messenger-lab3-lb-1,9.86%,12.82MiB / 7.691GiB
|
||||
1791545529,mtusi-messenger-lab3-api-1,61.03%,17.89MiB / 512MiB
|
||||
1791545529,mtusi-messenger-lab3-postgres-1,46.97%,143.2MiB / 1GiB
|
||||
1791545529,mtusi-messenger-lab3-redis-1,3.72%,6.098MiB / 256MiB
|
||||
1791545534,mtusi-messenger-lab3-lb-1,9.64%,12.99MiB / 7.691GiB
|
||||
1791545534,mtusi-messenger-lab3-api-1,59.92%,17.8MiB / 512MiB
|
||||
1791545534,mtusi-messenger-lab3-postgres-1,44.54%,144.5MiB / 1GiB
|
||||
1791545534,mtusi-messenger-lab3-redis-1,3.74%,6.215MiB / 256MiB
|
||||
1791545538,mtusi-messenger-lab3-lb-1,10.04%,12.96MiB / 7.691GiB
|
||||
1791545538,mtusi-messenger-lab3-api-1,59.50%,17.67MiB / 512MiB
|
||||
1791545538,mtusi-messenger-lab3-postgres-1,77.56%,166.2MiB / 1GiB
|
||||
1791545538,mtusi-messenger-lab3-redis-1,3.79%,6.199MiB / 256MiB
|
||||
1791545543,mtusi-messenger-lab3-lb-1,9.59%,13.21MiB / 7.691GiB
|
||||
1791545543,mtusi-messenger-lab3-api-1,59.21%,18.53MiB / 512MiB
|
||||
1791545543,mtusi-messenger-lab3-postgres-1,44.71%,148MiB / 1GiB
|
||||
1791545543,mtusi-messenger-lab3-redis-1,5.43%,6.02MiB / 256MiB
|
||||
1791545547,mtusi-messenger-lab3-lb-1,9.78%,12.82MiB / 7.691GiB
|
||||
1791545547,mtusi-messenger-lab3-api-1,60.43%,17.59MiB / 512MiB
|
||||
1791545547,mtusi-messenger-lab3-postgres-1,45.40%,149.9MiB / 1GiB
|
||||
1791545547,mtusi-messenger-lab3-redis-1,3.72%,6.008MiB / 256MiB
|
||||
1791545552,mtusi-messenger-lab3-lb-1,9.91%,12.94MiB / 7.691GiB
|
||||
1791545552,mtusi-messenger-lab3-api-1,61.24%,18.27MiB / 512MiB
|
||||
1791545552,mtusi-messenger-lab3-postgres-1,46.39%,152.1MiB / 1GiB
|
||||
1791545552,mtusi-messenger-lab3-redis-1,4.25%,5.617MiB / 256MiB
|
||||
1791545556,mtusi-messenger-lab3-lb-1,9.70%,13.07MiB / 7.691GiB
|
||||
1791545556,mtusi-messenger-lab3-api-1,63.06%,18.04MiB / 512MiB
|
||||
1791545556,mtusi-messenger-lab3-postgres-1,46.16%,153.9MiB / 1GiB
|
||||
1791545556,mtusi-messenger-lab3-redis-1,3.73%,5.469MiB / 256MiB
|
||||
1791545561,mtusi-messenger-lab3-lb-1,9.64%,12.44MiB / 7.691GiB
|
||||
1791545561,mtusi-messenger-lab3-api-1,59.91%,18.4MiB / 512MiB
|
||||
1791545561,mtusi-messenger-lab3-postgres-1,44.96%,154.6MiB / 1GiB
|
||||
1791545561,mtusi-messenger-lab3-redis-1,3.72%,4.992MiB / 256MiB
|
||||
1791545565,mtusi-messenger-lab3-lb-1,9.71%,13.11MiB / 7.691GiB
|
||||
1791545565,mtusi-messenger-lab3-api-1,59.12%,18.7MiB / 512MiB
|
||||
1791545565,mtusi-messenger-lab3-postgres-1,45.83%,156.7MiB / 1GiB
|
||||
1791545565,mtusi-messenger-lab3-redis-1,5.68%,5.047MiB / 256MiB
|
||||
1791545570,mtusi-messenger-lab3-lb-1,9.68%,13.06MiB / 7.691GiB
|
||||
1791545570,mtusi-messenger-lab3-api-1,59.71%,18.15MiB / 512MiB
|
||||
1791545570,mtusi-messenger-lab3-postgres-1,45.36%,158.6MiB / 1GiB
|
||||
1791545570,mtusi-messenger-lab3-redis-1,3.75%,5.594MiB / 256MiB
|
||||
1791545574,mtusi-messenger-lab3-lb-1,9.46%,13.52MiB / 7.691GiB
|
||||
1791545574,mtusi-messenger-lab3-api-1,61.73%,18.4MiB / 512MiB
|
||||
1791545574,mtusi-messenger-lab3-postgres-1,44.72%,160MiB / 1GiB
|
||||
1791545574,mtusi-messenger-lab3-redis-1,3.77%,5.465MiB / 256MiB
|
||||
1791545578,mtusi-messenger-lab3-lb-1,9.74%,13.17MiB / 7.691GiB
|
||||
1791545578,mtusi-messenger-lab3-api-1,61.49%,18.18MiB / 512MiB
|
||||
1791545578,mtusi-messenger-lab3-postgres-1,45.37%,162MiB / 1GiB
|
||||
1791545578,mtusi-messenger-lab3-redis-1,3.76%,5.578MiB / 256MiB
|
||||
1791545583,mtusi-messenger-lab3-lb-1,9.69%,12.8MiB / 7.691GiB
|
||||
1791545583,mtusi-messenger-lab3-api-1,59.49%,18.18MiB / 512MiB
|
||||
1791545583,mtusi-messenger-lab3-postgres-1,44.63%,164.6MiB / 1GiB
|
||||
1791545583,mtusi-messenger-lab3-redis-1,5.54%,5.77MiB / 256MiB
|
||||
1791545587,mtusi-messenger-lab3-lb-1,9.99%,13.04MiB / 7.691GiB
|
||||
1791545587,mtusi-messenger-lab3-api-1,59.72%,18.18MiB / 512MiB
|
||||
1791545587,mtusi-messenger-lab3-postgres-1,47.69%,166.7MiB / 1GiB
|
||||
1791545587,mtusi-messenger-lab3-redis-1,3.75%,5.758MiB / 256MiB
|
||||
1791545592,mtusi-messenger-lab3-lb-1,10.01%,12.81MiB / 7.691GiB
|
||||
1791545592,mtusi-messenger-lab3-api-1,61.22%,18.75MiB / 512MiB
|
||||
1791545592,mtusi-messenger-lab3-postgres-1,47.66%,167.9MiB / 1GiB
|
||||
1791545592,mtusi-messenger-lab3-redis-1,3.62%,5.672MiB / 256MiB
|
||||
1791545596,mtusi-messenger-lab3-lb-1,9.69%,13.55MiB / 7.691GiB
|
||||
1791545596,mtusi-messenger-lab3-api-1,61.26%,18.48MiB / 512MiB
|
||||
1791545596,mtusi-messenger-lab3-postgres-1,45.33%,169.3MiB / 1GiB
|
||||
1791545596,mtusi-messenger-lab3-redis-1,3.70%,5.984MiB / 256MiB
|
||||
1791545601,mtusi-messenger-lab3-lb-1,10.01%,13.05MiB / 7.691GiB
|
||||
1791545601,mtusi-messenger-lab3-api-1,62.55%,18.05MiB / 512MiB
|
||||
1791545601,mtusi-messenger-lab3-postgres-1,64.24%,188.5MiB / 1GiB
|
||||
1791545601,mtusi-messenger-lab3-redis-1,3.85%,4.512MiB / 256MiB
|
||||
1791545605,mtusi-messenger-lab3-lb-1,10.22%,12.7MiB / 7.691GiB
|
||||
1791545605,mtusi-messenger-lab3-api-1,61.39%,18.13MiB / 512MiB
|
||||
1791545605,mtusi-messenger-lab3-postgres-1,47.98%,172MiB / 1GiB
|
||||
1791545605,mtusi-messenger-lab3-redis-1,5.58%,5.297MiB / 256MiB
|
||||
1791545610,mtusi-messenger-lab3-lb-1,9.66%,12.87MiB / 7.691GiB
|
||||
1791545610,mtusi-messenger-lab3-api-1,59.13%,17.9MiB / 512MiB
|
||||
1791545610,mtusi-messenger-lab3-postgres-1,47.33%,173.8MiB / 1GiB
|
||||
1791545610,mtusi-messenger-lab3-redis-1,5.40%,5.59MiB / 256MiB
|
||||
1791545614,mtusi-messenger-lab3-lb-1,9.41%,12.97MiB / 7.691GiB
|
||||
1791545614,mtusi-messenger-lab3-api-1,58.77%,18.14MiB / 512MiB
|
||||
1791545614,mtusi-messenger-lab3-postgres-1,43.60%,174.5MiB / 1GiB
|
||||
1791545614,mtusi-messenger-lab3-redis-1,3.68%,5.586MiB / 256MiB
|
||||
1791545619,mtusi-messenger-lab3-lb-1,9.57%,12.77MiB / 7.691GiB
|
||||
1791545619,mtusi-messenger-lab3-api-1,59.13%,17.25MiB / 512MiB
|
||||
1791545619,mtusi-messenger-lab3-postgres-1,45.80%,177.2MiB / 1GiB
|
||||
1791545619,mtusi-messenger-lab3-redis-1,3.71%,5.742MiB / 256MiB
|
||||
1791545623,mtusi-messenger-lab3-lb-1,9.58%,12.59MiB / 7.691GiB
|
||||
1791545623,mtusi-messenger-lab3-api-1,59.05%,17.5MiB / 512MiB
|
||||
1791545623,mtusi-messenger-lab3-postgres-1,44.47%,177.6MiB / 1GiB
|
||||
1791545623,mtusi-messenger-lab3-redis-1,3.66%,5.543MiB / 256MiB
|
||||
1791545628,mtusi-messenger-lab3-lb-1,9.65%,13.28MiB / 7.691GiB
|
||||
1791545628,mtusi-messenger-lab3-api-1,62.19%,17.71MiB / 512MiB
|
||||
1791545628,mtusi-messenger-lab3-postgres-1,45.00%,179.7MiB / 1GiB
|
||||
1791545628,mtusi-messenger-lab3-redis-1,3.78%,5.234MiB / 256MiB
|
||||
1791545632,mtusi-messenger-lab3-lb-1,9.73%,12.82MiB / 7.691GiB
|
||||
1791545632,mtusi-messenger-lab3-api-1,59.69%,17.68MiB / 512MiB
|
||||
1791545632,mtusi-messenger-lab3-postgres-1,47.44%,180.9MiB / 1GiB
|
||||
1791545632,mtusi-messenger-lab3-redis-1,5.44%,5.074MiB / 256MiB
|
||||
1791545636,mtusi-messenger-lab3-api-1,0.60%,15.73MiB / 512MiB
|
||||
1791545636,mtusi-messenger-lab3-postgres-1,0.10%,180.1MiB / 1GiB
|
||||
1791545636,mtusi-messenger-lab3-redis-1,2.25%,5.316MiB / 256MiB
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"vus_max": {
|
||||
"min": 800,
|
||||
"max": 800,
|
||||
"value": 800
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 48003,
|
||||
"rate": 397.26271350523626
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 48003,
|
||||
"value": 0
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"max": 2.8566,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5143,
|
||||
"avg": 0.04216435847759514,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 15283726,
|
||||
"rate": 126484.89601130203
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"p(95)": 4.8433600000000006,
|
||||
"avg": 4.808899862508581,
|
||||
"min": 1.9984,
|
||||
"med": 3.2347,
|
||||
"max": 430.8061,
|
||||
"p(90)": 4.2249
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48000,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"vus": {
|
||||
"value": 2,
|
||||
"min": 1,
|
||||
"max": 41
|
||||
},
|
||||
"iteration_duration": {
|
||||
"avg": 4.877503056250002,
|
||||
"min": 1.9984,
|
||||
"med": 3.56995,
|
||||
"max": 404.304,
|
||||
"p(90)": 4.25681,
|
||||
"p(95)": 4.9982
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96000,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0008071516363560609,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.9049
|
||||
},
|
||||
"write_total": {
|
||||
"count": 48000,
|
||||
"rate": 397.2378861373527
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.0016880153323750602,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 3.2643,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"p(90)": 4.2249,
|
||||
"p(95)": 4.8426,
|
||||
"avg": 4.7920399583333175,
|
||||
"min": 1.9984,
|
||||
"med": 3.2346,
|
||||
"max": 404.304
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"avg": 0.0024069912297148095,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 7.7688,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 4.808899862508581,
|
||||
"min": 1.9984,
|
||||
"med": 3.2347,
|
||||
"max": 430.8061,
|
||||
"p(90)": 4.2249,
|
||||
"p(95)": 4.8433600000000006
|
||||
},
|
||||
"data_received": {
|
||||
"count": 21586848,
|
||||
"rate": 178648.2055810071
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 4.765928352394636,
|
||||
"min": 1.9975,
|
||||
"med": 3.1791,
|
||||
"max": 430.8061,
|
||||
"p(90)": 4.207,
|
||||
"p(95)": 4.791790000000001
|
||||
},
|
||||
"iterations": {
|
||||
"count": 48000,
|
||||
"rate": 397.2378861373527
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "3c8e38e3-9f80-4a75-b0df-d333fcc49cf2",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48000,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"passes": 48000,
|
||||
"fails": 0,
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650"
|
||||
}
|
||||
},
|
||||
"name": "",
|
||||
"path": ""
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545656,mtusi-messenger-lab3-lb-1,13.80%,12.14MiB / 7.691GiB
|
||||
1791545656,mtusi-messenger-lab3-api-1,21.69%,72.42MiB / 256MiB
|
||||
1791545656,mtusi-messenger-lab3-api-2,31.02%,72.8MiB / 256MiB
|
||||
1791545656,mtusi-messenger-lab3-postgres-1,70.00%,69.04MiB / 1GiB
|
||||
1791545656,mtusi-messenger-lab3-redis-1,3.86%,5.816MiB / 256MiB
|
||||
1791545661,mtusi-messenger-lab3-lb-1,10.11%,13.59MiB / 7.691GiB
|
||||
1791545661,mtusi-messenger-lab3-api-1,32.66%,89.2MiB / 256MiB
|
||||
1791545661,mtusi-messenger-lab3-api-2,35.53%,86.36MiB / 256MiB
|
||||
1791545661,mtusi-messenger-lab3-postgres-1,46.85%,74.95MiB / 1GiB
|
||||
1791545661,mtusi-messenger-lab3-redis-1,3.92%,5.184MiB / 256MiB
|
||||
1791545665,mtusi-messenger-lab3-lb-1,10.52%,13.14MiB / 7.691GiB
|
||||
1791545665,mtusi-messenger-lab3-api-1,35.83%,101.6MiB / 256MiB
|
||||
1791545665,mtusi-messenger-lab3-api-2,35.79%,101.5MiB / 256MiB
|
||||
1791545665,mtusi-messenger-lab3-postgres-1,48.92%,77.68MiB / 1GiB
|
||||
1791545665,mtusi-messenger-lab3-redis-1,5.93%,5.273MiB / 256MiB
|
||||
1791545670,mtusi-messenger-lab3-lb-1,10.32%,13MiB / 7.691GiB
|
||||
1791545670,mtusi-messenger-lab3-api-1,32.27%,113.3MiB / 256MiB
|
||||
1791545670,mtusi-messenger-lab3-api-2,33.37%,110.8MiB / 256MiB
|
||||
1791545670,mtusi-messenger-lab3-postgres-1,48.01%,80.2MiB / 1GiB
|
||||
1791545670,mtusi-messenger-lab3-redis-1,5.57%,5.129MiB / 256MiB
|
||||
1791545674,mtusi-messenger-lab3-lb-1,10.03%,13.7MiB / 7.691GiB
|
||||
1791545674,mtusi-messenger-lab3-api-1,32.54%,125.8MiB / 256MiB
|
||||
1791545674,mtusi-messenger-lab3-api-2,33.26%,122.8MiB / 256MiB
|
||||
1791545674,mtusi-messenger-lab3-postgres-1,45.54%,81.28MiB / 1GiB
|
||||
1791545674,mtusi-messenger-lab3-redis-1,3.87%,6.25MiB / 256MiB
|
||||
1791545679,mtusi-messenger-lab3-lb-1,10.21%,13.14MiB / 7.691GiB
|
||||
1791545679,mtusi-messenger-lab3-api-1,32.69%,136.8MiB / 256MiB
|
||||
1791545679,mtusi-messenger-lab3-api-2,32.52%,136MiB / 256MiB
|
||||
1791545679,mtusi-messenger-lab3-postgres-1,45.88%,83.05MiB / 1GiB
|
||||
1791545679,mtusi-messenger-lab3-redis-1,3.71%,6.008MiB / 256MiB
|
||||
1791545683,mtusi-messenger-lab3-lb-1,10.02%,13.12MiB / 7.691GiB
|
||||
1791545683,mtusi-messenger-lab3-api-1,31.85%,17.01MiB / 256MiB
|
||||
1791545683,mtusi-messenger-lab3-api-2,32.15%,19.52MiB / 256MiB
|
||||
1791545683,mtusi-messenger-lab3-postgres-1,86.36%,87.28MiB / 1GiB
|
||||
1791545683,mtusi-messenger-lab3-redis-1,3.81%,5.418MiB / 256MiB
|
||||
1791545688,mtusi-messenger-lab3-lb-1,10.58%,13.47MiB / 7.691GiB
|
||||
1791545688,mtusi-messenger-lab3-api-1,35.53%,17.58MiB / 256MiB
|
||||
1791545688,mtusi-messenger-lab3-api-2,35.32%,17.67MiB / 256MiB
|
||||
1791545688,mtusi-messenger-lab3-postgres-1,47.13%,87.63MiB / 1GiB
|
||||
1791545688,mtusi-messenger-lab3-redis-1,3.91%,5.445MiB / 256MiB
|
||||
1791545692,mtusi-messenger-lab3-lb-1,10.31%,13.23MiB / 7.691GiB
|
||||
1791545692,mtusi-messenger-lab3-api-1,32.74%,17.45MiB / 256MiB
|
||||
1791545692,mtusi-messenger-lab3-api-2,32.85%,17.26MiB / 256MiB
|
||||
1791545692,mtusi-messenger-lab3-postgres-1,45.59%,88.96MiB / 1GiB
|
||||
1791545692,mtusi-messenger-lab3-redis-1,5.64%,4.949MiB / 256MiB
|
||||
1791545697,mtusi-messenger-lab3-lb-1,11.26%,13.09MiB / 7.691GiB
|
||||
1791545697,mtusi-messenger-lab3-api-1,36.60%,16.47MiB / 256MiB
|
||||
1791545697,mtusi-messenger-lab3-api-2,36.36%,16.61MiB / 256MiB
|
||||
1791545697,mtusi-messenger-lab3-postgres-1,46.77%,89.86MiB / 1GiB
|
||||
1791545697,mtusi-messenger-lab3-redis-1,3.80%,6.254MiB / 256MiB
|
||||
1791545701,mtusi-messenger-lab3-lb-1,10.31%,13.38MiB / 7.691GiB
|
||||
1791545701,mtusi-messenger-lab3-api-1,31.83%,17.63MiB / 256MiB
|
||||
1791545701,mtusi-messenger-lab3-api-2,32.53%,17.04MiB / 256MiB
|
||||
1791545701,mtusi-messenger-lab3-postgres-1,44.42%,91.44MiB / 1GiB
|
||||
1791545701,mtusi-messenger-lab3-redis-1,3.62%,6.258MiB / 256MiB
|
||||
1791545705,mtusi-messenger-lab3-lb-1,10.36%,12.96MiB / 7.691GiB
|
||||
1791545705,mtusi-messenger-lab3-api-1,33.03%,16.97MiB / 256MiB
|
||||
1791545705,mtusi-messenger-lab3-api-2,33.18%,16.91MiB / 256MiB
|
||||
1791545705,mtusi-messenger-lab3-postgres-1,46.56%,94.17MiB / 1GiB
|
||||
1791545705,mtusi-messenger-lab3-redis-1,3.84%,5.266MiB / 256MiB
|
||||
1791545710,mtusi-messenger-lab3-lb-1,10.07%,12.95MiB / 7.691GiB
|
||||
1791545710,mtusi-messenger-lab3-api-1,32.49%,16.52MiB / 256MiB
|
||||
1791545710,mtusi-messenger-lab3-api-2,32.54%,16.55MiB / 256MiB
|
||||
1791545710,mtusi-messenger-lab3-postgres-1,45.86%,94.73MiB / 1GiB
|
||||
1791545710,mtusi-messenger-lab3-redis-1,3.81%,5.156MiB / 256MiB
|
||||
1791545714,mtusi-messenger-lab3-lb-1,10.34%,13.9MiB / 7.691GiB
|
||||
1791545714,mtusi-messenger-lab3-api-1,34.84%,16.22MiB / 256MiB
|
||||
1791545714,mtusi-messenger-lab3-api-2,33.62%,17.1MiB / 256MiB
|
||||
1791545714,mtusi-messenger-lab3-postgres-1,46.51%,97.36MiB / 1GiB
|
||||
1791545714,mtusi-messenger-lab3-redis-1,3.76%,5.43MiB / 256MiB
|
||||
1791545719,mtusi-messenger-lab3-lb-1,10.34%,13.41MiB / 7.691GiB
|
||||
1791545719,mtusi-messenger-lab3-api-1,32.78%,16.29MiB / 256MiB
|
||||
1791545719,mtusi-messenger-lab3-api-2,32.81%,17.15MiB / 256MiB
|
||||
1791545719,mtusi-messenger-lab3-postgres-1,46.34%,98.41MiB / 1GiB
|
||||
1791545719,mtusi-messenger-lab3-redis-1,5.72%,5.156MiB / 256MiB
|
||||
1791545723,mtusi-messenger-lab3-lb-1,10.06%,12.96MiB / 7.691GiB
|
||||
1791545723,mtusi-messenger-lab3-api-1,32.88%,16.05MiB / 256MiB
|
||||
1791545723,mtusi-messenger-lab3-api-2,33.01%,14.9MiB / 256MiB
|
||||
1791545723,mtusi-messenger-lab3-postgres-1,45.91%,101.8MiB / 1GiB
|
||||
1791545723,mtusi-messenger-lab3-redis-1,3.74%,5.559MiB / 256MiB
|
||||
1791545728,mtusi-messenger-lab3-lb-1,10.71%,13.06MiB / 7.691GiB
|
||||
1791545728,mtusi-messenger-lab3-api-1,34.35%,15.49MiB / 256MiB
|
||||
1791545728,mtusi-messenger-lab3-api-2,32.47%,15.47MiB / 256MiB
|
||||
1791545728,mtusi-messenger-lab3-postgres-1,48.54%,103MiB / 1GiB
|
||||
1791545728,mtusi-messenger-lab3-redis-1,3.76%,5.984MiB / 256MiB
|
||||
1791545732,mtusi-messenger-lab3-lb-1,10.71%,12.95MiB / 7.691GiB
|
||||
1791545732,mtusi-messenger-lab3-api-1,34.29%,15.21MiB / 256MiB
|
||||
1791545732,mtusi-messenger-lab3-api-2,34.11%,15.68MiB / 256MiB
|
||||
1791545732,mtusi-messenger-lab3-postgres-1,48.31%,104.4MiB / 1GiB
|
||||
1791545732,mtusi-messenger-lab3-redis-1,3.90%,4.637MiB / 256MiB
|
||||
1791545737,mtusi-messenger-lab3-lb-1,10.15%,13.08MiB / 7.691GiB
|
||||
1791545737,mtusi-messenger-lab3-api-1,34.75%,14.8MiB / 256MiB
|
||||
1791545737,mtusi-messenger-lab3-api-2,35.03%,15.58MiB / 256MiB
|
||||
1791545737,mtusi-messenger-lab3-postgres-1,46.61%,105.4MiB / 1GiB
|
||||
1791545737,mtusi-messenger-lab3-redis-1,6.76%,4.969MiB / 256MiB
|
||||
1791545741,mtusi-messenger-lab3-lb-1,10.46%,13.3MiB / 7.691GiB
|
||||
1791545741,mtusi-messenger-lab3-api-1,33.80%,14.71MiB / 256MiB
|
||||
1791545741,mtusi-messenger-lab3-api-2,33.59%,15.07MiB / 256MiB
|
||||
1791545741,mtusi-messenger-lab3-postgres-1,50.05%,106.7MiB / 1GiB
|
||||
1791545741,mtusi-messenger-lab3-redis-1,3.75%,5.977MiB / 256MiB
|
||||
1791545746,mtusi-messenger-lab3-lb-1,9.80%,13.2MiB / 7.691GiB
|
||||
1791545746,mtusi-messenger-lab3-api-1,32.85%,14.93MiB / 256MiB
|
||||
1791545746,mtusi-messenger-lab3-api-2,32.85%,15.7MiB / 256MiB
|
||||
1791545746,mtusi-messenger-lab3-postgres-1,46.51%,108.5MiB / 1GiB
|
||||
1791545746,mtusi-messenger-lab3-redis-1,3.78%,5.738MiB / 256MiB
|
||||
1791545750,mtusi-messenger-lab3-lb-1,10.49%,13.25MiB / 7.691GiB
|
||||
1791545750,mtusi-messenger-lab3-api-1,33.75%,15.34MiB / 256MiB
|
||||
1791545750,mtusi-messenger-lab3-api-2,33.06%,13.84MiB / 256MiB
|
||||
1791545750,mtusi-messenger-lab3-postgres-1,46.88%,109.9MiB / 1GiB
|
||||
1791545750,mtusi-messenger-lab3-redis-1,3.86%,6.074MiB / 256MiB
|
||||
1791545755,mtusi-messenger-lab3-lb-1,10.32%,13.12MiB / 7.691GiB
|
||||
1791545755,mtusi-messenger-lab3-api-1,35.01%,14.29MiB / 256MiB
|
||||
1791545755,mtusi-messenger-lab3-api-2,32.60%,15.15MiB / 256MiB
|
||||
1791545755,mtusi-messenger-lab3-postgres-1,46.18%,111.1MiB / 1GiB
|
||||
1791545755,mtusi-messenger-lab3-redis-1,3.79%,5.902MiB / 256MiB
|
||||
1791545759,mtusi-messenger-lab3-lb-1,10.48%,13.29MiB / 7.691GiB
|
||||
1791545759,mtusi-messenger-lab3-api-1,35.61%,14.7MiB / 256MiB
|
||||
1791545759,mtusi-messenger-lab3-api-2,36.26%,14.18MiB / 256MiB
|
||||
1791545759,mtusi-messenger-lab3-postgres-1,51.72%,112.5MiB / 1GiB
|
||||
1791545759,mtusi-messenger-lab3-redis-1,3.93%,5.09MiB / 256MiB
|
||||
1791545763,mtusi-messenger-lab3-lb-1,10.20%,12.77MiB / 7.691GiB
|
||||
1791545763,mtusi-messenger-lab3-api-1,33.54%,14.73MiB / 256MiB
|
||||
1791545763,mtusi-messenger-lab3-api-2,32.69%,13.93MiB / 256MiB
|
||||
1791545763,mtusi-messenger-lab3-postgres-1,49.37%,114.3MiB / 1GiB
|
||||
1791545763,mtusi-messenger-lab3-redis-1,5.94%,5.316MiB / 256MiB
|
||||
1791545768,mtusi-messenger-lab3-lb-1,10.65%,13.38MiB / 7.691GiB
|
||||
1791545768,mtusi-messenger-lab3-api-1,32.75%,14.92MiB / 256MiB
|
||||
1791545768,mtusi-messenger-lab3-api-2,34.22%,14.23MiB / 256MiB
|
||||
1791545768,mtusi-messenger-lab3-postgres-1,51.55%,118.2MiB / 1GiB
|
||||
1791545768,mtusi-messenger-lab3-redis-1,6.02%,5.715MiB / 256MiB
|
||||
1791545772,mtusi-messenger-lab3-lb-1,10.16%,12.89MiB / 7.691GiB
|
||||
1791545772,mtusi-messenger-lab3-api-1,32.72%,15MiB / 256MiB
|
||||
1791545772,mtusi-messenger-lab3-api-2,32.90%,14.2MiB / 256MiB
|
||||
1791545772,mtusi-messenger-lab3-postgres-1,46.27%,117.5MiB / 1GiB
|
||||
1791545772,mtusi-messenger-lab3-redis-1,3.88%,5.504MiB / 256MiB
|
||||
1791545777,mtusi-messenger-lab3-lb-1,3.88%,9.609MiB / 7.691GiB
|
||||
1791545777,mtusi-messenger-lab3-api-1,36.44%,78.54MiB / 256MiB
|
||||
1791545777,mtusi-messenger-lab3-api-2,24.00%,78.59MiB / 256MiB
|
||||
1791545777,mtusi-messenger-lab3-postgres-1,3.61%,118.4MiB / 1GiB
|
||||
1791545777,mtusi-messenger-lab3-redis-1,2.89%,5.344MiB / 256MiB
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"metrics": {
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"min": 1.9996,
|
||||
"med": 3.59695,
|
||||
"max": 439.7073,
|
||||
"p(90)": 4.823130000000004,
|
||||
"p(95)": 5.2460499999999985,
|
||||
"avg": 3.992316525706226
|
||||
},
|
||||
"data_received": {
|
||||
"count": 21587296,
|
||||
"rate": 178641.34317944487
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48001,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 48004,
|
||||
"rate": 397.24748472370374
|
||||
},
|
||||
"iteration_duration": {
|
||||
"p(95)": 5.5069,
|
||||
"avg": 4.0696828232745546,
|
||||
"min": 1.9996,
|
||||
"med": 3.6808,
|
||||
"max": 78.2792,
|
||||
"p(90)": 4.9984
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"max": 439.7073,
|
||||
"p(90)": 4.7345,
|
||||
"p(95)": 5.005484999999999,
|
||||
"avg": 3.9449540079993577,
|
||||
"min": 1.9996,
|
||||
"med": 3.3043
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96002,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.001025064577951837,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 7.1534
|
||||
},
|
||||
"write_latency_ms": {
|
||||
"p(95)": 5.2307,
|
||||
"avg": 3.975309997708413,
|
||||
"min": 1.9996,
|
||||
"med": 3.5967,
|
||||
"max": 78.2792,
|
||||
"p(90)": 4.8223
|
||||
},
|
||||
"vus": {
|
||||
"value": 2,
|
||||
"min": 1,
|
||||
"max": 4
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.0010935484542954753,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 3.1655,
|
||||
"p(90)": 0
|
||||
},
|
||||
"write_total": {
|
||||
"rate": 397.22265882473346,
|
||||
"count": 48001
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"p(95)": 0.5155,
|
||||
"avg": 0.046268969252562346,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.002,
|
||||
"p(90)": 0
|
||||
},
|
||||
"iterations": {
|
||||
"count": 48001,
|
||||
"rate": 397.22265882473346
|
||||
},
|
||||
"http_req_failed": {
|
||||
"fails": 48004,
|
||||
"passes": 0,
|
||||
"value": 0
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 15284041,
|
||||
"rate": 126480.01924139576
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 3.992316525706226,
|
||||
"min": 1.9996,
|
||||
"med": 3.59695,
|
||||
"max": 439.7073,
|
||||
"p(90)": 4.823130000000004,
|
||||
"p(95)": 5.2460499999999985
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"avg": 0.0006252645612865597,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.007,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
},
|
||||
"vus_max": {
|
||||
"value": 800,
|
||||
"min": 800,
|
||||
"max": 800
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "729408f5-6c54-4ed1-aa6a-8f9b04218748",
|
||||
"token": "REDACTED"
|
||||
},
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545778,mtusi-messenger-lab3-lb-1,8.42%,10.64MiB / 7.691GiB
|
||||
1791545778,mtusi-messenger-lab3-api-1,36.44%,78.54MiB / 256MiB
|
||||
1791545778,mtusi-messenger-lab3-api-2,24.00%,78.59MiB / 256MiB
|
||||
1791545778,mtusi-messenger-lab3-postgres-1,36.21%,118.9MiB / 1GiB
|
||||
1791545778,mtusi-messenger-lab3-redis-1,2.89%,5.344MiB / 256MiB
|
||||
1791545781,mtusi-messenger-lab3-lb-1,10.12%,13.02MiB / 7.691GiB
|
||||
1791545781,mtusi-messenger-lab3-api-1,34.14%,89.39MiB / 256MiB
|
||||
1791545781,mtusi-messenger-lab3-api-2,34.11%,88.55MiB / 256MiB
|
||||
1791545781,mtusi-messenger-lab3-postgres-1,46.73%,120.4MiB / 1GiB
|
||||
1791545781,mtusi-messenger-lab3-redis-1,3.75%,5.379MiB / 256MiB
|
||||
1791545786,mtusi-messenger-lab3-lb-1,10.10%,12.96MiB / 7.691GiB
|
||||
1791545786,mtusi-messenger-lab3-api-1,33.05%,100.8MiB / 256MiB
|
||||
1791545786,mtusi-messenger-lab3-api-2,33.31%,100.9MiB / 256MiB
|
||||
1791545786,mtusi-messenger-lab3-postgres-1,47.18%,122MiB / 1GiB
|
||||
1791545786,mtusi-messenger-lab3-redis-1,6.35%,5.285MiB / 256MiB
|
||||
1791545790,mtusi-messenger-lab3-lb-1,10.17%,13.12MiB / 7.691GiB
|
||||
1791545790,mtusi-messenger-lab3-api-1,33.37%,113.5MiB / 256MiB
|
||||
1791545790,mtusi-messenger-lab3-api-2,33.38%,112.4MiB / 256MiB
|
||||
1791545790,mtusi-messenger-lab3-postgres-1,48.47%,123.6MiB / 1GiB
|
||||
1791545790,mtusi-messenger-lab3-redis-1,3.94%,5.25MiB / 256MiB
|
||||
1791545795,mtusi-messenger-lab3-lb-1,9.94%,13.09MiB / 7.691GiB
|
||||
1791545795,mtusi-messenger-lab3-api-1,32.48%,125.2MiB / 256MiB
|
||||
1791545795,mtusi-messenger-lab3-api-2,32.49%,121.6MiB / 256MiB
|
||||
1791545795,mtusi-messenger-lab3-postgres-1,45.93%,126.1MiB / 1GiB
|
||||
1791545795,mtusi-messenger-lab3-redis-1,3.79%,5.723MiB / 256MiB
|
||||
1791545799,mtusi-messenger-lab3-lb-1,12.96%,12.81MiB / 7.691GiB
|
||||
1791545799,mtusi-messenger-lab3-api-1,41.01%,137.2MiB / 256MiB
|
||||
1791545799,mtusi-messenger-lab3-api-2,41.68%,137.2MiB / 256MiB
|
||||
1791545799,mtusi-messenger-lab3-postgres-1,72.91%,127.1MiB / 1GiB
|
||||
1791545799,mtusi-messenger-lab3-redis-1,3.80%,5.562MiB / 256MiB
|
||||
1791545804,mtusi-messenger-lab3-lb-1,10.44%,13.05MiB / 7.691GiB
|
||||
1791545804,mtusi-messenger-lab3-api-1,32.71%,20.49MiB / 256MiB
|
||||
1791545804,mtusi-messenger-lab3-api-2,34.92%,22.65MiB / 256MiB
|
||||
1791545804,mtusi-messenger-lab3-postgres-1,54.87%,129.1MiB / 1GiB
|
||||
1791545804,mtusi-messenger-lab3-redis-1,3.92%,4.445MiB / 256MiB
|
||||
1791545808,mtusi-messenger-lab3-lb-1,10.31%,13.4MiB / 7.691GiB
|
||||
1791545808,mtusi-messenger-lab3-api-1,35.57%,18.05MiB / 256MiB
|
||||
1791545808,mtusi-messenger-lab3-api-2,35.91%,18.82MiB / 256MiB
|
||||
1791545808,mtusi-messenger-lab3-postgres-1,48.85%,131.5MiB / 1GiB
|
||||
1791545808,mtusi-messenger-lab3-redis-1,5.83%,5.133MiB / 256MiB
|
||||
1791545813,mtusi-messenger-lab3-lb-1,10.52%,13.32MiB / 7.691GiB
|
||||
1791545813,mtusi-messenger-lab3-api-1,33.70%,17.56MiB / 256MiB
|
||||
1791545813,mtusi-messenger-lab3-api-2,33.61%,20.52MiB / 256MiB
|
||||
1791545813,mtusi-messenger-lab3-postgres-1,53.10%,133.2MiB / 1GiB
|
||||
1791545813,mtusi-messenger-lab3-redis-1,6.23%,5.168MiB / 256MiB
|
||||
1791545817,mtusi-messenger-lab3-lb-1,10.55%,12.82MiB / 7.691GiB
|
||||
1791545817,mtusi-messenger-lab3-api-1,33.52%,17.91MiB / 256MiB
|
||||
1791545817,mtusi-messenger-lab3-api-2,33.69%,20.28MiB / 256MiB
|
||||
1791545817,mtusi-messenger-lab3-postgres-1,47.38%,134.5MiB / 1GiB
|
||||
1791545817,mtusi-messenger-lab3-redis-1,3.84%,5.48MiB / 256MiB
|
||||
1791545822,mtusi-messenger-lab3-lb-1,10.04%,13.41MiB / 7.691GiB
|
||||
1791545822,mtusi-messenger-lab3-api-1,32.60%,17.69MiB / 256MiB
|
||||
1791545822,mtusi-messenger-lab3-api-2,33.04%,19.91MiB / 256MiB
|
||||
1791545822,mtusi-messenger-lab3-postgres-1,47.07%,135.9MiB / 1GiB
|
||||
1791545822,mtusi-messenger-lab3-redis-1,3.89%,4.195MiB / 256MiB
|
||||
1791545826,mtusi-messenger-lab3-lb-1,10.27%,13.42MiB / 7.691GiB
|
||||
1791545826,mtusi-messenger-lab3-api-1,32.47%,17.95MiB / 256MiB
|
||||
1791545826,mtusi-messenger-lab3-api-2,34.97%,19.49MiB / 256MiB
|
||||
1791545826,mtusi-messenger-lab3-postgres-1,45.45%,137.5MiB / 1GiB
|
||||
1791545826,mtusi-messenger-lab3-redis-1,3.77%,5.598MiB / 256MiB
|
||||
1791545831,mtusi-messenger-lab3-lb-1,10.35%,13.31MiB / 7.691GiB
|
||||
1791545831,mtusi-messenger-lab3-api-1,35.16%,18.13MiB / 256MiB
|
||||
1791545831,mtusi-messenger-lab3-api-2,35.33%,19.18MiB / 256MiB
|
||||
1791545831,mtusi-messenger-lab3-postgres-1,47.56%,139.1MiB / 1GiB
|
||||
1791545831,mtusi-messenger-lab3-redis-1,5.70%,4.879MiB / 256MiB
|
||||
1791545835,mtusi-messenger-lab3-lb-1,9.98%,12.92MiB / 7.691GiB
|
||||
1791545835,mtusi-messenger-lab3-api-1,34.15%,17.83MiB / 256MiB
|
||||
1791545835,mtusi-messenger-lab3-api-2,34.35%,19.45MiB / 256MiB
|
||||
1791545835,mtusi-messenger-lab3-postgres-1,50.91%,140.6MiB / 1GiB
|
||||
1791545835,mtusi-messenger-lab3-redis-1,6.21%,5.297MiB / 256MiB
|
||||
1791545840,mtusi-messenger-lab3-lb-1,10.35%,13.21MiB / 7.691GiB
|
||||
1791545840,mtusi-messenger-lab3-api-1,33.72%,16.94MiB / 256MiB
|
||||
1791545840,mtusi-messenger-lab3-api-2,33.76%,17.27MiB / 256MiB
|
||||
1791545840,mtusi-messenger-lab3-postgres-1,50.25%,145MiB / 1GiB
|
||||
1791545840,mtusi-messenger-lab3-redis-1,6.02%,6.77MiB / 256MiB
|
||||
1791545844,mtusi-messenger-lab3-lb-1,10.23%,13.02MiB / 7.691GiB
|
||||
1791545844,mtusi-messenger-lab3-api-1,33.65%,17.06MiB / 256MiB
|
||||
1791545844,mtusi-messenger-lab3-api-2,33.75%,18.76MiB / 256MiB
|
||||
1791545844,mtusi-messenger-lab3-postgres-1,48.64%,144.9MiB / 1GiB
|
||||
1791545844,mtusi-messenger-lab3-redis-1,3.94%,5.996MiB / 256MiB
|
||||
1791545849,mtusi-messenger-lab3-lb-1,11.97%,13.63MiB / 7.691GiB
|
||||
1791545849,mtusi-messenger-lab3-api-1,38.59%,17.36MiB / 256MiB
|
||||
1791545849,mtusi-messenger-lab3-api-2,42.26%,18.76MiB / 256MiB
|
||||
1791545849,mtusi-messenger-lab3-postgres-1,56.52%,147.2MiB / 1GiB
|
||||
1791545849,mtusi-messenger-lab3-redis-1,4.67%,5.523MiB / 256MiB
|
||||
1791545853,mtusi-messenger-lab3-lb-1,10.58%,13.42MiB / 7.691GiB
|
||||
1791545853,mtusi-messenger-lab3-api-1,39.43%,17.65MiB / 256MiB
|
||||
1791545853,mtusi-messenger-lab3-api-2,39.94%,19.52MiB / 256MiB
|
||||
1791545853,mtusi-messenger-lab3-postgres-1,49.39%,148.3MiB / 1GiB
|
||||
1791545853,mtusi-messenger-lab3-redis-1,4.45%,5.605MiB / 256MiB
|
||||
1791545858,mtusi-messenger-lab3-lb-1,8.87%,13.04MiB / 7.691GiB
|
||||
1791545858,mtusi-messenger-lab3-api-1,29.36%,17.84MiB / 256MiB
|
||||
1791545858,mtusi-messenger-lab3-api-2,30.98%,19.59MiB / 256MiB
|
||||
1791545858,mtusi-messenger-lab3-postgres-1,41.69%,149.8MiB / 1GiB
|
||||
1791545858,mtusi-messenger-lab3-redis-1,3.59%,5.301MiB / 256MiB
|
||||
1791545862,mtusi-messenger-lab3-lb-1,8.95%,13.18MiB / 7.691GiB
|
||||
1791545862,mtusi-messenger-lab3-api-1,28.87%,17.76MiB / 256MiB
|
||||
1791545862,mtusi-messenger-lab3-api-2,29.06%,19.55MiB / 256MiB
|
||||
1791545862,mtusi-messenger-lab3-postgres-1,40.83%,151.3MiB / 1GiB
|
||||
1791545862,mtusi-messenger-lab3-redis-1,3.35%,5.5MiB / 256MiB
|
||||
1791545866,mtusi-messenger-lab3-lb-1,9.14%,13.23MiB / 7.691GiB
|
||||
1791545866,mtusi-messenger-lab3-api-1,30.45%,17MiB / 256MiB
|
||||
1791545866,mtusi-messenger-lab3-api-2,30.21%,19.01MiB / 256MiB
|
||||
1791545866,mtusi-messenger-lab3-postgres-1,46.90%,152.6MiB / 1GiB
|
||||
1791545866,mtusi-messenger-lab3-redis-1,5.65%,5.738MiB / 256MiB
|
||||
1791545870,mtusi-messenger-lab3-lb-1,10.01%,12.55MiB / 7.691GiB
|
||||
1791545870,mtusi-messenger-lab3-api-1,32.70%,16.32MiB / 256MiB
|
||||
1791545870,mtusi-messenger-lab3-api-2,32.64%,18.52MiB / 256MiB
|
||||
1791545870,mtusi-messenger-lab3-postgres-1,47.05%,153.7MiB / 1GiB
|
||||
1791545870,mtusi-messenger-lab3-redis-1,3.69%,6.324MiB / 256MiB
|
||||
1791545874,mtusi-messenger-lab3-lb-1,10.65%,12.77MiB / 7.691GiB
|
||||
1791545874,mtusi-messenger-lab3-api-1,35.43%,16.86MiB / 256MiB
|
||||
1791545874,mtusi-messenger-lab3-api-2,35.27%,18.79MiB / 256MiB
|
||||
1791545874,mtusi-messenger-lab3-postgres-1,47.94%,155MiB / 1GiB
|
||||
1791545874,mtusi-messenger-lab3-redis-1,3.82%,6.043MiB / 256MiB
|
||||
1791545879,mtusi-messenger-lab3-lb-1,10.93%,12.97MiB / 7.691GiB
|
||||
1791545879,mtusi-messenger-lab3-api-1,34.09%,16.78MiB / 256MiB
|
||||
1791545879,mtusi-messenger-lab3-api-2,38.20%,18.11MiB / 256MiB
|
||||
1791545879,mtusi-messenger-lab3-postgres-1,48.08%,156.5MiB / 1GiB
|
||||
1791545879,mtusi-messenger-lab3-redis-1,3.98%,5.367MiB / 256MiB
|
||||
1791545883,mtusi-messenger-lab3-lb-1,11.11%,13.21MiB / 7.691GiB
|
||||
1791545883,mtusi-messenger-lab3-api-1,36.85%,17.09MiB / 256MiB
|
||||
1791545883,mtusi-messenger-lab3-api-2,37.33%,18.18MiB / 256MiB
|
||||
1791545883,mtusi-messenger-lab3-postgres-1,55.66%,157.9MiB / 1GiB
|
||||
1791545883,mtusi-messenger-lab3-redis-1,4.16%,4.613MiB / 256MiB
|
||||
1791545888,mtusi-messenger-lab3-lb-1,10.60%,12.83MiB / 7.691GiB
|
||||
1791545888,mtusi-messenger-lab3-api-1,36.73%,18.64MiB / 256MiB
|
||||
1791545888,mtusi-messenger-lab3-api-2,34.71%,18.66MiB / 256MiB
|
||||
1791545888,mtusi-messenger-lab3-postgres-1,49.20%,160MiB / 1GiB
|
||||
1791545888,mtusi-messenger-lab3-redis-1,6.28%,5.016MiB / 256MiB
|
||||
1791545892,mtusi-messenger-lab3-lb-1,12.51%,12.73MiB / 7.691GiB
|
||||
1791545892,mtusi-messenger-lab3-api-1,35.40%,16.73MiB / 256MiB
|
||||
1791545892,mtusi-messenger-lab3-api-2,41.68%,18.02MiB / 256MiB
|
||||
1791545892,mtusi-messenger-lab3-postgres-1,51.43%,161.1MiB / 1GiB
|
||||
1791545892,mtusi-messenger-lab3-redis-1,7.29%,4.711MiB / 256MiB
|
||||
1791545897,mtusi-messenger-lab3-lb-1,5.88%,9.758MiB / 7.691GiB
|
||||
1791545897,mtusi-messenger-lab3-api-1,8.21%,25.38MiB / 256MiB
|
||||
1791545897,mtusi-messenger-lab3-api-2,37.29%,18.79MiB / 256MiB
|
||||
1791545897,mtusi-messenger-lab3-postgres-1,10.76%,162.8MiB / 1GiB
|
||||
1791545897,mtusi-messenger-lab3-redis-1,4.28%,5.766MiB / 256MiB
|
||||
|
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"root_group": {
|
||||
"name": "",
|
||||
"path": "",
|
||||
"id": "d41d8cd98f00b204e9800998ecf8427e",
|
||||
"groups": {},
|
||||
"checks": {
|
||||
"status is 201": {
|
||||
"name": "status is 201",
|
||||
"path": "::status is 201",
|
||||
"id": "ec8c9afd59577ad0eb26fbf150ecf791",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
},
|
||||
"has message id": {
|
||||
"name": "has message id",
|
||||
"path": "::has message id",
|
||||
"id": "b68aced36d580a28d7f34396032f1650",
|
||||
"passes": 48001,
|
||||
"fails": 0
|
||||
}
|
||||
}
|
||||
},
|
||||
"metrics": {
|
||||
"write_latency_ms": {
|
||||
"avg": 3.8704089081477413,
|
||||
"min": 1.7358,
|
||||
"med": 3.6668,
|
||||
"max": 90.0337,
|
||||
"p(90)": 4.3342,
|
||||
"p(95)": 5.0008
|
||||
},
|
||||
"http_req_failed": {
|
||||
"passes": 0,
|
||||
"fails": 48004,
|
||||
"value": 0
|
||||
},
|
||||
"http_reqs": {
|
||||
"count": 48004,
|
||||
"rate": 398.07490333247614
|
||||
},
|
||||
"http_req_waiting": {
|
||||
"avg": 3.8336158299308347,
|
||||
"min": 1.7358,
|
||||
"med": 3.52,
|
||||
"max": 312.4519,
|
||||
"p(90)": 4.2837,
|
||||
"p(95)": 5.0002
|
||||
},
|
||||
"http_req_receiving": {
|
||||
"avg": 0.04766511957336902,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 1.4804,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0.5175
|
||||
},
|
||||
"vus": {
|
||||
"value": 2,
|
||||
"min": 1,
|
||||
"max": 26
|
||||
},
|
||||
"data_received": {
|
||||
"count": 21587292,
|
||||
"rate": 179013.39838575816
|
||||
},
|
||||
"http_req_blocked": {
|
||||
"max": 9.0009,
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0012070952420631612,
|
||||
"min": 0,
|
||||
"med": 0
|
||||
},
|
||||
"write_total": {
|
||||
"count": 48001,
|
||||
"rate": 398.05002572415185
|
||||
},
|
||||
"http_req_tls_handshaking": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 0
|
||||
},
|
||||
"http_req_connecting": {
|
||||
"p(95)": 0,
|
||||
"avg": 0.0006467544371302393,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.0006,
|
||||
"p(90)": 0
|
||||
},
|
||||
"http_req_duration": {
|
||||
"avg": 3.8821593596366935,
|
||||
"min": 1.7358,
|
||||
"med": 3.6668,
|
||||
"max": 312.4519,
|
||||
"p(90)": 4.3343,
|
||||
"p(95)": 5.0008
|
||||
},
|
||||
"http_req_sending": {
|
||||
"p(90)": 0,
|
||||
"p(95)": 0,
|
||||
"avg": 0.0008784101324889593,
|
||||
"min": 0,
|
||||
"med": 0,
|
||||
"max": 2.0012
|
||||
},
|
||||
"checks": {
|
||||
"passes": 96002,
|
||||
"fails": 0,
|
||||
"value": 1
|
||||
},
|
||||
"iterations": {
|
||||
"count": 48001,
|
||||
"rate": 398.05002572415185
|
||||
},
|
||||
"vus_max": {
|
||||
"min": 800,
|
||||
"max": 800,
|
||||
"value": 800
|
||||
},
|
||||
"http_req_duration{expected_response:true}": {
|
||||
"p(95)": 5.0008,
|
||||
"avg": 3.8821593596366935,
|
||||
"min": 1.7358,
|
||||
"med": 3.6668,
|
||||
"max": 312.4519,
|
||||
"p(90)": 4.3343
|
||||
},
|
||||
"iteration_duration": {
|
||||
"p(90)": 4.7665,
|
||||
"p(95)": 5.0027,
|
||||
"avg": 3.963674442199132,
|
||||
"min": 2.218,
|
||||
"med": 3.6913,
|
||||
"max": 91.0347
|
||||
},
|
||||
"write_errors": {
|
||||
"passes": 0,
|
||||
"fails": 48001,
|
||||
"thresholds": {
|
||||
"rate<0.01": false
|
||||
},
|
||||
"value": 0
|
||||
},
|
||||
"data_sent": {
|
||||
"count": 15284033,
|
||||
"rate": 126743.39552965117
|
||||
}
|
||||
},
|
||||
"setup_data": {
|
||||
"chatId": "7bfea3d2-db1b-471d-82fb-2eb7681b61a7",
|
||||
"token": "REDACTED"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
timestamp,name,cpu_perc,mem_usage,mem_limit
|
||||
1791545899,mtusi-messenger-lab3-lb-1,9.19%,11.25MiB / 7.691GiB
|
||||
1791545899,mtusi-messenger-lab3-api-1,42.86%,79.54MiB / 256MiB
|
||||
1791545899,mtusi-messenger-lab3-api-2,26.33%,80.18MiB / 256MiB
|
||||
1791545899,mtusi-messenger-lab3-postgres-1,42.85%,163.4MiB / 1GiB
|
||||
1791545899,mtusi-messenger-lab3-redis-1,5.63%,4.727MiB / 256MiB
|
||||
1791545903,mtusi-messenger-lab3-lb-1,10.50%,13.01MiB / 7.691GiB
|
||||
1791545903,mtusi-messenger-lab3-api-1,37.07%,90.04MiB / 256MiB
|
||||
1791545903,mtusi-messenger-lab3-api-2,37.25%,89.82MiB / 256MiB
|
||||
1791545903,mtusi-messenger-lab3-postgres-1,57.20%,165.8MiB / 1GiB
|
||||
1791545903,mtusi-messenger-lab3-redis-1,4.05%,5.051MiB / 256MiB
|
||||
1791545907,mtusi-messenger-lab3-lb-1,10.19%,12.74MiB / 7.691GiB
|
||||
1791545907,mtusi-messenger-lab3-api-1,35.28%,101.9MiB / 256MiB
|
||||
1791545907,mtusi-messenger-lab3-api-2,35.24%,102MiB / 256MiB
|
||||
1791545907,mtusi-messenger-lab3-postgres-1,50.68%,166.8MiB / 1GiB
|
||||
1791545907,mtusi-messenger-lab3-redis-1,3.86%,5.566MiB / 256MiB
|
||||
1791545912,mtusi-messenger-lab3-lb-1,11.17%,13.07MiB / 7.691GiB
|
||||
1791545912,mtusi-messenger-lab3-api-1,37.61%,114.7MiB / 256MiB
|
||||
1791545912,mtusi-messenger-lab3-api-2,37.97%,114.2MiB / 256MiB
|
||||
1791545912,mtusi-messenger-lab3-postgres-1,56.34%,168.9MiB / 1GiB
|
||||
1791545912,mtusi-messenger-lab3-redis-1,4.46%,6.043MiB / 256MiB
|
||||
1791545916,mtusi-messenger-lab3-lb-1,11.22%,13.38MiB / 7.691GiB
|
||||
1791545916,mtusi-messenger-lab3-api-1,37.65%,123.7MiB / 256MiB
|
||||
1791545916,mtusi-messenger-lab3-api-2,41.06%,126.5MiB / 256MiB
|
||||
1791545916,mtusi-messenger-lab3-postgres-1,57.57%,170.4MiB / 1GiB
|
||||
1791545916,mtusi-messenger-lab3-redis-1,4.50%,4.633MiB / 256MiB
|
||||
1791545921,mtusi-messenger-lab3-lb-1,10.19%,12.81MiB / 7.691GiB
|
||||
1791545921,mtusi-messenger-lab3-api-1,33.67%,138.2MiB / 256MiB
|
||||
1791545921,mtusi-messenger-lab3-api-2,33.99%,138.5MiB / 256MiB
|
||||
1791545921,mtusi-messenger-lab3-postgres-1,50.23%,171.9MiB / 1GiB
|
||||
1791545921,mtusi-messenger-lab3-redis-1,3.82%,6.578MiB / 256MiB
|
||||
1791545925,mtusi-messenger-lab3-lb-1,10.50%,13.02MiB / 7.691GiB
|
||||
1791545925,mtusi-messenger-lab3-api-1,33.96%,22.19MiB / 256MiB
|
||||
1791545925,mtusi-messenger-lab3-api-2,34.68%,22.23MiB / 256MiB
|
||||
1791545925,mtusi-messenger-lab3-postgres-1,51.38%,174.2MiB / 1GiB
|
||||
1791545925,mtusi-messenger-lab3-redis-1,3.95%,6.086MiB / 256MiB
|
||||
1791545930,mtusi-messenger-lab3-lb-1,10.30%,13.52MiB / 7.691GiB
|
||||
1791545930,mtusi-messenger-lab3-api-1,33.80%,20.63MiB / 256MiB
|
||||
1791545930,mtusi-messenger-lab3-api-2,34.02%,20.08MiB / 256MiB
|
||||
1791545930,mtusi-messenger-lab3-postgres-1,48.53%,176.6MiB / 1GiB
|
||||
1791545930,mtusi-messenger-lab3-redis-1,3.84%,6.047MiB / 256MiB
|
||||
1791545934,mtusi-messenger-lab3-lb-1,10.22%,13.14MiB / 7.691GiB
|
||||
1791545934,mtusi-messenger-lab3-api-1,32.96%,20.64MiB / 256MiB
|
||||
1791545934,mtusi-messenger-lab3-api-2,35.25%,19.95MiB / 256MiB
|
||||
1791545934,mtusi-messenger-lab3-postgres-1,47.35%,178MiB / 1GiB
|
||||
1791545934,mtusi-messenger-lab3-redis-1,3.87%,5.625MiB / 256MiB
|
||||
1791545939,mtusi-messenger-lab3-lb-1,10.21%,13.44MiB / 7.691GiB
|
||||
1791545939,mtusi-messenger-lab3-api-1,36.70%,19.47MiB / 256MiB
|
||||
1791545939,mtusi-messenger-lab3-api-2,37.25%,19.07MiB / 256MiB
|
||||
1791545939,mtusi-messenger-lab3-postgres-1,47.06%,179.3MiB / 1GiB
|
||||
1791545939,mtusi-messenger-lab3-redis-1,3.86%,5.496MiB / 256MiB
|
||||
1791545943,mtusi-messenger-lab3-lb-1,10.28%,13.29MiB / 7.691GiB
|
||||
1791545943,mtusi-messenger-lab3-api-1,35.64%,20.71MiB / 256MiB
|
||||
1791545943,mtusi-messenger-lab3-api-2,35.79%,19.07MiB / 256MiB
|
||||
1791545943,mtusi-messenger-lab3-postgres-1,47.50%,180.1MiB / 1GiB
|
||||
1791545943,mtusi-messenger-lab3-redis-1,3.97%,4.848MiB / 256MiB
|
||||
1791545948,mtusi-messenger-lab3-lb-1,10.10%,12.75MiB / 7.691GiB
|
||||
1791545948,mtusi-messenger-lab3-api-1,33.58%,19.02MiB / 256MiB
|
||||
1791545948,mtusi-messenger-lab3-api-2,33.85%,18.06MiB / 256MiB
|
||||
1791545948,mtusi-messenger-lab3-postgres-1,50.00%,181.7MiB / 1GiB
|
||||
1791545948,mtusi-messenger-lab3-redis-1,5.97%,4.902MiB / 256MiB
|
||||
1791545952,mtusi-messenger-lab3-lb-1,10.33%,13.27MiB / 7.691GiB
|
||||
1791545952,mtusi-messenger-lab3-api-1,34.13%,19.29MiB / 256MiB
|
||||
1791545952,mtusi-messenger-lab3-api-2,33.59%,18.37MiB / 256MiB
|
||||
1791545952,mtusi-messenger-lab3-postgres-1,49.78%,184.1MiB / 1GiB
|
||||
1791545952,mtusi-messenger-lab3-redis-1,3.99%,6.324MiB / 256MiB
|
||||
1791545956,mtusi-messenger-lab3-lb-1,10.10%,13.17MiB / 7.691GiB
|
||||
1791545956,mtusi-messenger-lab3-api-1,33.35%,19.02MiB / 256MiB
|
||||
1791545956,mtusi-messenger-lab3-api-2,32.90%,18.34MiB / 256MiB
|
||||
1791545956,mtusi-messenger-lab3-postgres-1,46.23%,185.5MiB / 1GiB
|
||||
1791545956,mtusi-messenger-lab3-redis-1,3.76%,5.973MiB / 256MiB
|
||||
1791545961,mtusi-messenger-lab3-lb-1,10.23%,13.45MiB / 7.691GiB
|
||||
1791545961,mtusi-messenger-lab3-api-1,34.77%,18MiB / 256MiB
|
||||
1791545961,mtusi-messenger-lab3-api-2,33.18%,18.31MiB / 256MiB
|
||||
1791545961,mtusi-messenger-lab3-postgres-1,48.01%,188.2MiB / 1GiB
|
||||
1791545961,mtusi-messenger-lab3-redis-1,3.86%,5.695MiB / 256MiB
|
||||
1791545965,mtusi-messenger-lab3-lb-1,10.21%,13.24MiB / 7.691GiB
|
||||
1791545965,mtusi-messenger-lab3-api-1,34.88%,17.73MiB / 256MiB
|
||||
1791545965,mtusi-messenger-lab3-api-2,35.32%,17.62MiB / 256MiB
|
||||
1791545965,mtusi-messenger-lab3-postgres-1,51.04%,189.7MiB / 1GiB
|
||||
1791545965,mtusi-messenger-lab3-redis-1,6.07%,5.34MiB / 256MiB
|
||||
1791545970,mtusi-messenger-lab3-lb-1,10.38%,12.85MiB / 7.691GiB
|
||||
1791545970,mtusi-messenger-lab3-api-1,34.14%,18.17MiB / 256MiB
|
||||
1791545970,mtusi-messenger-lab3-api-2,33.90%,17.78MiB / 256MiB
|
||||
1791545970,mtusi-messenger-lab3-postgres-1,50.56%,192MiB / 1GiB
|
||||
1791545970,mtusi-messenger-lab3-redis-1,3.88%,5.637MiB / 256MiB
|
||||
1791545974,mtusi-messenger-lab3-lb-1,10.42%,13.35MiB / 7.691GiB
|
||||
1791545974,mtusi-messenger-lab3-api-1,33.78%,18.37MiB / 256MiB
|
||||
1791545974,mtusi-messenger-lab3-api-2,34.41%,17.68MiB / 256MiB
|
||||
1791545974,mtusi-messenger-lab3-postgres-1,47.73%,193.2MiB / 1GiB
|
||||
1791545974,mtusi-messenger-lab3-redis-1,3.97%,6.039MiB / 256MiB
|
||||
1791545979,mtusi-messenger-lab3-lb-1,9.88%,13.19MiB / 7.691GiB
|
||||
1791545979,mtusi-messenger-lab3-api-1,32.77%,17.11MiB / 256MiB
|
||||
1791545979,mtusi-messenger-lab3-api-2,33.06%,17.84MiB / 256MiB
|
||||
1791545979,mtusi-messenger-lab3-postgres-1,46.85%,194.8MiB / 1GiB
|
||||
1791545979,mtusi-messenger-lab3-redis-1,3.81%,5.824MiB / 256MiB
|
||||
1791545983,mtusi-messenger-lab3-lb-1,10.22%,13.09MiB / 7.691GiB
|
||||
1791545983,mtusi-messenger-lab3-api-1,37.31%,17.85MiB / 256MiB
|
||||
1791545983,mtusi-messenger-lab3-api-2,37.36%,18.02MiB / 256MiB
|
||||
1791545983,mtusi-messenger-lab3-postgres-1,50.54%,195.9MiB / 1GiB
|
||||
1791545983,mtusi-messenger-lab3-redis-1,3.77%,5.848MiB / 256MiB
|
||||
1791545988,mtusi-messenger-lab3-lb-1,10.31%,13.03MiB / 7.691GiB
|
||||
1791545988,mtusi-messenger-lab3-api-1,33.33%,17.39MiB / 256MiB
|
||||
1791545988,mtusi-messenger-lab3-api-2,35.79%,17.2MiB / 256MiB
|
||||
1791545988,mtusi-messenger-lab3-postgres-1,48.72%,197.7MiB / 1GiB
|
||||
1791545988,mtusi-messenger-lab3-redis-1,3.83%,5.113MiB / 256MiB
|
||||
1791545992,mtusi-messenger-lab3-lb-1,10.31%,12.86MiB / 7.691GiB
|
||||
1791545992,mtusi-messenger-lab3-api-1,33.59%,17.21MiB / 256MiB
|
||||
1791545992,mtusi-messenger-lab3-api-2,33.02%,17.57MiB / 256MiB
|
||||
1791545992,mtusi-messenger-lab3-postgres-1,49.79%,199.1MiB / 1GiB
|
||||
1791545992,mtusi-messenger-lab3-redis-1,5.83%,5.938MiB / 256MiB
|
||||
1791545997,mtusi-messenger-lab3-lb-1,10.06%,12.62MiB / 7.691GiB
|
||||
1791545997,mtusi-messenger-lab3-api-1,35.94%,17.07MiB / 256MiB
|
||||
1791545997,mtusi-messenger-lab3-api-2,35.75%,17.46MiB / 256MiB
|
||||
1791545997,mtusi-messenger-lab3-postgres-1,46.56%,200MiB / 1GiB
|
||||
1791545997,mtusi-messenger-lab3-redis-1,4.13%,6.094MiB / 256MiB
|
||||
1791546001,mtusi-messenger-lab3-lb-1,10.04%,12.66MiB / 7.691GiB
|
||||
1791546001,mtusi-messenger-lab3-api-1,32.67%,16.98MiB / 256MiB
|
||||
1791546001,mtusi-messenger-lab3-api-2,33.28%,16.87MiB / 256MiB
|
||||
1791546001,mtusi-messenger-lab3-postgres-1,47.10%,200.7MiB / 1GiB
|
||||
1791546001,mtusi-messenger-lab3-redis-1,4.30%,6.262MiB / 256MiB
|
||||
1791546006,mtusi-messenger-lab3-lb-1,10.34%,12.64MiB / 7.691GiB
|
||||
1791546006,mtusi-messenger-lab3-api-1,33.57%,16.93MiB / 256MiB
|
||||
1791546006,mtusi-messenger-lab3-api-2,33.86%,16.32MiB / 256MiB
|
||||
1791546006,mtusi-messenger-lab3-postgres-1,48.36%,201.2MiB / 1GiB
|
||||
1791546006,mtusi-messenger-lab3-redis-1,3.90%,5.125MiB / 256MiB
|
||||
1791546010,mtusi-messenger-lab3-lb-1,10.43%,13.12MiB / 7.691GiB
|
||||
1791546010,mtusi-messenger-lab3-api-1,33.46%,17.26MiB / 256MiB
|
||||
1791546010,mtusi-messenger-lab3-api-2,35.96%,16.07MiB / 256MiB
|
||||
1791546010,mtusi-messenger-lab3-postgres-1,49.52%,202MiB / 1GiB
|
||||
1791546010,mtusi-messenger-lab3-redis-1,3.98%,5.594MiB / 256MiB
|
||||
1791546015,mtusi-messenger-lab3-lb-1,10.46%,12.73MiB / 7.691GiB
|
||||
1791546015,mtusi-messenger-lab3-api-1,34.11%,16.75MiB / 256MiB
|
||||
1791546015,mtusi-messenger-lab3-api-2,34.01%,16.06MiB / 256MiB
|
||||
1791546015,mtusi-messenger-lab3-postgres-1,47.73%,201MiB / 1GiB
|
||||
1791546015,mtusi-messenger-lab3-redis-1,5.89%,5.277MiB / 256MiB
|
||||
1791546019,mtusi-messenger-lab3-api-1,15.90%,16.66MiB / 256MiB
|
||||
1791546019,mtusi-messenger-lab3-api-2,0.36%,14.25MiB / 256MiB
|
||||
1791546019,mtusi-messenger-lab3-postgres-1,2.90%,201.9MiB / 1GiB
|
||||
1791546019,mtusi-messenger-lab3-redis-1,1.99%,5.559MiB / 256MiB
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user