docs: add lab4 report and evidence

This commit is contained in:
2026-11-05 17:45:51 +03:00
parent f8e41b1195
commit 9141873b04
14 changed files with 2056 additions and 14 deletions
+76
View File
@@ -0,0 +1,76 @@
# Вложения: сценарий защиты, остановка загрузившей реплики, прерванная загрузка, отказ между S3 и БД
# date: 2026-11-05T13:59:24Z
# commit: f8e41b1
$ python3 scripts/attachment-scenario.py
## 1. Сценарий защиты: загрузка, сообщение, второй участник, посторонний, S3 мимо API
POST /attachments -> 201 status=ready variants=[] error_code=None sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
POST /messages text="" -> 201 attachment_ids совпадают: True
Bob GET /content -> 200 image/png sha256 совпадает: True
Eve GET /attachments/{id} -> 404
Eve GET /attachments/{id}/content -> 404
object_key в БД: attachments/<uuid>, filename в ключ не входит: True
Анонимный GET объекта напрямую в S3 -> 403
## 2. Остановка реплики, обслужившей загрузку; скачивание через другую
upload -> 201, обслужила реплика 0900a35b199d
stop-one.sh: /messenger-lab4-api-2 exited finished=2026-11-05T13:59:28.482320827Z
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
download -> 200 реплика=bb4424f819bb sha256 совпадает: True
остановленная реплика среди обслуживших: False ; 0.05s
Файл оригинала на диске обслужившей реплики (поиск по точному размеру 111817 байт):
bb4424f819bb -> нет
реплика 0900a35b199d возвращена
upload -> 201, обслужила реплика bb4424f819bb
stop-one.sh: /messenger-lab4-api-1 exited finished=2026-11-05T13:59:35.788929779Z
download -> 200 реплика=0900a35b199d sha256 совпадает: True
download -> 200 реплика=0900a35b199d sha256 совпадает: True
download -> 200 реплика=0900a35b199d sha256 совпадает: True
download -> 200 реплика=0900a35b199d sha256 совпадает: True
download -> 200 реплика=0900a35b199d sha256 совпадает: True
download -> 200 реплика=0900a35b199d sha256 совпадает: True
остановленная реплика среди обслуживших: False ; 0.12s
Файл оригинала на диске обслужившей реплики (поиск по точному размеру 111817 байт):
0900a35b199d -> нет
реплика bb4424f819bb возвращена
## 3. Прерванная загрузка через LB: ни строки, ни объекта, ни временного файла
$ reconcile --grace-seconds=3600
{"mode":"dry-run","grace_seconds":3600,"scanned":7,"fresh_skipped":7,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":207}
$ reconcile --grace-seconds=3600
{"mode":"dry-run","grace_seconds":3600,"scanned":7,"fresh_skipped":7,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":218}
строк attachments: 7 -> 7; объектов: 7 -> 7
временных каталогов в bb4424f819bb: 0
временных каталогов в 0900a35b199d: 0
## 4. Реальный отказ PostgreSQL между PUT и INSERT: триггер отклоняет вставку
$ reconcile --grace-seconds=3600
{"mode":"dry-run","grace_seconds":3600,"scanned":7,"fresh_skipped":7,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":208}
upload при отказе INSERT -> 503 unavailable
строк attachments: 7 -> 7
$ reconcile --apply --grace-seconds=3600
{"mode":"apply","grace_seconds":3600,"scanned":8,"fresh_skipped":8,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":207}
объектов было 7, стало 8; свежий объект защищён grace: удалено 0
$ reconcile --apply --grace-seconds=1
{"mode":"apply","grace_seconds":1,"scanned":8,"fresh_skipped":0,"referenced":7,"orphans":1,"deleted":1,"failed":0,"orphan_keys":["attachments/2e115516-6a91-4d6a-8b18-577663eebebe"],"duration_ms":300}
после grace: сирот 1, удалено 1, привязанные объекты не тронуты: 7
следующая загрузка без отказа -> 201
## 5. Потеря соединения с PostgreSQL между PUT и INSERT: исход неясен, объект остаётся до сверки
$ reconcile --grace-seconds=3600
{"mode":"dry-run","grace_seconds":3600,"scanned":8,"fresh_skipped":8,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":210}
upload при отказе INSERT -> 503 unavailable
строк attachments: 8 -> 8
$ reconcile --apply --grace-seconds=3600
{"mode":"apply","grace_seconds":3600,"scanned":9,"fresh_skipped":9,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":214}
объектов было 8, стало 9; свежий объект защищён grace: удалено 0
$ reconcile --apply --grace-seconds=1
{"mode":"apply","grace_seconds":1,"scanned":9,"fresh_skipped":0,"referenced":8,"orphans":1,"deleted":1,"failed":0,"orphan_keys":["attachments/38b788ac-03f5-4bb4-88cf-813b8445c686"],"duration_ms":221}
после grace: сирот 1, удалено 1, привязанные объекты не тронуты: 8
следующая загрузка без отказа -> 201
+163
View File
@@ -0,0 +1,163 @@
# Стенд: сервисы, порты, лимиты, секреты, миграции
# date: 2026-11-05T13:56:38Z
# commit: f8e41b1
$ docker compose ps -a --format table {{.Service}}\t{{.Name}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}
SERVICE NAME IMAGE STATUS PORTS
api messenger-lab4-api-1 mtusi-messenger-lab4-api:dev Up 11 seconds (healthy) 8080/tcp
api messenger-lab4-api-2 mtusi-messenger-lab4-api:dev Up 11 seconds (healthy) 8080/tcp
lb messenger-lab4-lb-1 haproxy:3.0.6-alpine Up 5 seconds 127.0.0.1:8080->8080/tcp
migrate messenger-lab4-migrate-1 mtusi-messenger-lab4-migrate:dev Exited (0) 12 seconds ago
postgres messenger-lab4-postgres-1 postgres:17.2-alpine Up 21 seconds (healthy) 5432/tcp
reconciler messenger-lab4-reconciler-1 mtusi-messenger-lab4-api:dev Up 11 seconds 8080/tcp
redis messenger-lab4-redis-1 redis:7.4.1-alpine Up 21 seconds (healthy) 6379/tcp
s3 messenger-lab4-s3-1 pgsty/minio:RELEASE.2026-08-04T00-00-00Z@sha256:b6bfe7239bfc83fb90d31612d9704d86039dd714f7904b3f1ad68f211e602372 Up 21 seconds (healthy) 9000/tcp
s3-init messenger-lab4-s3-init-1 pgsty/mc:RELEASE.2026-10-26T00-00-00Z@sha256:ce62c9053c69ce12a527a322345b5ad9f44b5f8a7b8189f82e516f2e3f30f1d8 Exited (0) 12 seconds ago
secrets-init messenger-lab4-secrets-init-1 alpine:3.20.3 Exited (0) 21 seconds ago
tools messenger-lab4-tools-run-3ba5514e0d22 mtusi-messenger-lab4-tools:dev Up 4 seconds
## CPU/RAM-лимиты (NanoCpus: 1e9 = 1 CPU; Memory в байтах)
$ sh -c docker inspect -f '{{.Name}} cpus={{.HostConfig.NanoCpus}} memory={{.HostConfig.Memory}}' $(docker compose ps -aq)
/messenger-lab4-api-1 cpus=500000000 memory=268435456
/messenger-lab4-api-2 cpus=500000000 memory=268435456
/messenger-lab4-lb-1 cpus=250000000 memory=67108864
/messenger-lab4-migrate-1 cpus=500000000 memory=536870912
/messenger-lab4-postgres-1 cpus=1000000000 memory=536870912
/messenger-lab4-reconciler-1 cpus=250000000 memory=134217728
/messenger-lab4-redis-1 cpus=250000000 memory=134217728
/messenger-lab4-s3-1 cpus=500000000 memory=536870912
/messenger-lab4-s3-init-1 cpus=250000000 memory=268435456
/messenger-lab4-secrets-init-1 cpus=100000000 memory=33554432
/messenger-lab4-tools-run-3ba5514e0d22 cpus=1000000000 memory=268435456
## container_name не задан (одно имя сервиса масштабируется)
$ sh -c docker compose config | grep -c container_name || true
0
## Секреты: каждый сервис видит только свои файлы
$ docker compose exec -T postgres ls /run/secrets
pg_password
$ docker compose exec -T redis ls /run/secrets
redis_password
$ docker compose exec -T s3 ls /run/secrets
s3_root_password
s3_root_user
$ docker compose exec -T api ls /run/secrets
cache_url
database_url
s3_access_key_id
s3_secret_access_key
$ docker compose exec -T reconciler ls /run/secrets
database_url
s3_access_key_id
s3_secret_access_key
$ docker compose run --rm --no-deps -T --entrypoint ls s3-init /run/secrets
s3_access_key_id
s3_root_password
s3_root_user
s3_secret_access_key
$ docker compose exec -T lb sh -c ls /run/secrets 2>/dev/null || echo "no /run/secrets"
no /run/secrets
$ docker compose exec -T lb haproxy -v
HAProxy version 3.0.6-c2c0090 2024/11/07 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2029.
Known bugs: http://www.haproxy.org/bugs/bugs-3.0.6.html
Running on: Linux 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64
$ docker compose exec -T postgres postgres --version
postgres (PostgreSQL) 17.2
$ docker compose exec -T redis redis-server --version
Redis server v=7.4.1 sha=00000000:0 malloc=jemalloc-5.3.0 bits=64 build=a93ce81042b3a6d7
$ docker compose exec -T s3 minio --version
minio version RELEASE.2026-08-04T00-00-00Z (commit-id=d88f46ccee345a9c2fabe2d221d9a9e56bc11aec)
Runtime: go1.26.5 linux/amd64
License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html
Copyright: 2015-2026 MinIO, Inc.
## Таблицы вложений
$ docker compose exec -T postgres psql -U messenger -d messenger -c \d attachments -c \d message_attachments
Table "public.attachments"
Column | Type | Collation | Nullable | Default
--------------+-----------------------------+-----------+----------+-------------------
id | uuid | | not null |
chat_id | uuid | | not null |
owner_id | uuid | | not null |
filename | character varying(255) | | not null |
content_type | character varying(32) | | not null |
size_bytes | integer | | not null |
sha256 | character(64) | | not null |
object_key | character varying(128) | | not null |
created_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
updated_at | timestamp(3) with time zone | | not null | CURRENT_TIMESTAMP
Indexes:
"attachments_pkey" PRIMARY KEY, btree (id)
"attachments_chat_id_idx" btree (chat_id)
"attachments_object_key_key" UNIQUE, btree (object_key)
"attachments_owner_id_idx" btree (owner_id)
Check constraints:
"attachments_content_type_allowed" CHECK (content_type::text = ANY (ARRAY['image/png'::character varying, 'image/jpeg'::character varying]::text[]))
"attachments_filename_not_blank" CHECK (btrim(filename::text) <> ''::text)
"attachments_sha256_format" CHECK (sha256 ~ '^[a-f0-9]{64}$'::text)
"attachments_size_range" CHECK (size_bytes >= 1 AND size_bytes <= 10485760)
Foreign-key constraints:
"attachments_chat_id_fkey" FOREIGN KEY (chat_id) REFERENCES chats(id) ON UPDATE CASCADE ON DELETE CASCADE
"attachments_owner_id_fkey" FOREIGN KEY (owner_id) REFERENCES users(id) ON UPDATE CASCADE ON DELETE RESTRICT
Referenced by:
TABLE "message_attachments" CONSTRAINT "message_attachments_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE
Table "public.message_attachments"
Column | Type | Collation | Nullable | Default
---------------+----------+-----------+----------+---------
message_id | uuid | | not null |
position | smallint | | not null |
attachment_id | uuid | | not null |
Indexes:
"message_attachments_pkey" PRIMARY KEY, btree (message_id, "position")
"message_attachments_attachment_id_idx" btree (attachment_id)
"message_attachments_message_id_attachment_id_key" UNIQUE, btree (message_id, attachment_id)
Check constraints:
"message_attachments_position_range" CHECK ("position" >= 0 AND "position" <= 9)
Foreign-key constraints:
"message_attachments_attachment_id_fkey" FOREIGN KEY (attachment_id) REFERENCES attachments(id) ON UPDATE CASCADE
"message_attachments_message_id_fkey" FOREIGN KEY (message_id) REFERENCES messages(id) ON UPDATE CASCADE ON DELETE CASCADE
## Миграции: отдельный one-shot сервис, повторный запуск ничего не применяет
$ docker compose run --rm migrate
Container messenger-lab4-secrets-init-1 Created
Container messenger-lab4-postgres-1 Running
Container messenger-lab4-secrets-init-1 Starting
Container messenger-lab4-secrets-init-1 Started
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "messenger", schema "public" at "postgres:5432"
4 migrations found in prisma/migrations
No pending migrations to apply.
$ docker compose run --rm --no-deps migrate sh -c export DATABASE_URL="$(cat "$DATABASE_URL_FILE")"; npx prisma migrate diff --from-url "$DATABASE_URL" --to-schema-datamodel prisma/schema.prisma --exit-code
No difference detected.
$ docker compose exec -T postgres psql -U messenger -d messenger -c SELECT migration_name, finished_at FROM _prisma_migrations ORDER BY started_at
migration_name | finished_at
---------------------------------+-------------------------------
20261021000000_init | 2026-11-05 13:56:26.122879+00
20261021010000_auth_sessions | 2026-11-05 13:56:26.136187+00
20261101000000_idempotency_keys | 2026-11-05 13:56:26.145579+00
20261105000000_attachments | 2026-11-05 13:56:26.159672+00
(4 rows)
+148
View File
@@ -0,0 +1,148 @@
{
"scenario": "sequential failover of each api replica",
"resources_under_load": [
"messenger-lab4-api-1 cpu=44.15% mem=105MiB / 256MiB",
"messenger-lab4-api-2 cpu=49.51% mem=122.1MiB / 256MiB",
"messenger-lab4-lb-1 cpu=13.85% mem=15.72MiB / 64MiB",
"messenger-lab4-postgres-1 cpu=26.52% mem=65.75MiB / 512MiB",
"messenger-lab4-reconciler-1 cpu=0.00% mem=32.57MiB / 128MiB",
"messenger-lab4-redis-1 cpu=1.89% mem=8.105MiB / 128MiB",
"messenger-lab4-s3-1 cpu=0.09% mem=248.8MiB / 512MiB"
],
"replicas": [
{
"container": "/messenger-lab4-api-1 running image=0387c3cfc941",
"action": "docker kill (SIGKILL)",
"before": {
"seconds": 5.0,
"successful_writes": 789,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 157.8,
"latency_ms_successful": {
"p50": 11.3,
"p95": 80.0,
"p99": 117.2
},
"max_write_gap_seconds": 0.155,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"stop_command_seconds": 0.444,
"target_last_success_after_stop_seconds": null,
"outage_window": {
"seconds": 10.444,
"successful_writes": 828,
"failed_attempts": 2,
"error_ratio": 0.0024,
"successful_rps": 79.3,
"latency_ms_successful": {
"p50": 13.4,
"p95": 92.9,
"p99": 1012.3
},
"max_write_gap_seconds": 0.916,
"instances": [
"0900a35b199d"
]
},
"restore_until_healthy_seconds": 5.742,
"restore_until_serving_seconds": 3.928,
"after_restore": {
"seconds": 5.027,
"successful_writes": 791,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 157.4,
"latency_ms_successful": {
"p50": 11.9,
"p95": 74.7,
"p99": 85.1
},
"max_write_gap_seconds": 0.143,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
}
},
{
"container": "/messenger-lab4-api-2 running image=0387c3cfc941",
"action": "docker kill (SIGKILL)",
"before": {
"seconds": 5.0,
"successful_writes": 790,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 158.0,
"latency_ms_successful": {
"p50": 11.9,
"p95": 74.7,
"p99": 85.1
},
"max_write_gap_seconds": 0.143,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"stop_command_seconds": 0.444,
"target_last_success_after_stop_seconds": null,
"outage_window": {
"seconds": 10.444,
"successful_writes": 670,
"failed_attempts": 2,
"error_ratio": 0.003,
"successful_rps": 64.2,
"latency_ms_successful": {
"p50": 14.1,
"p95": 95.5,
"p99": 1010.9
},
"max_write_gap_seconds": 0.989,
"instances": [
"bb4424f819bb"
]
},
"restore_until_healthy_seconds": 5.757,
"restore_until_serving_seconds": 4.112,
"after_restore": {
"seconds": 5.032,
"successful_writes": 720,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 143.1,
"latency_ms_successful": {
"p50": 13.2,
"p95": 77.0,
"p99": 90.7
},
"max_write_gap_seconds": 0.082,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
}
}
],
"dataset": {
"messages_in_db_before": 7276,
"messages_in_db_after": 12641
},
"history": {
"confirmed": 5365,
"stored": 5365,
"lost_confirmed": 0,
"duplicates": 0
},
"load": {
"workers": 4,
"model": "closed loop, POST message",
"warmup_seconds": 5,
"client_timeout_seconds": 2,
"retry": "same Idempotency-Key until success"
},
"date": "2026-11-05T14:08:00Z"
}
+150
View File
@@ -0,0 +1,150 @@
{
"scenario": "sequential failover of each api replica",
"resources_under_load": [
"messenger-lab4-api-1 cpu=44.28% mem=180MiB / 256MiB",
"messenger-lab4-api-2 cpu=47.97% mem=137MiB / 256MiB",
"messenger-lab4-lb-1 cpu=10.58% mem=13.88MiB / 64MiB",
"messenger-lab4-postgres-1 cpu=25.75% mem=76.62MiB / 512MiB",
"messenger-lab4-reconciler-1 cpu=0.00% mem=30.15MiB / 128MiB",
"messenger-lab4-redis-1 cpu=1.84% mem=8.105MiB / 128MiB",
"messenger-lab4-s3-1 cpu=2.26% mem=248.7MiB / 512MiB"
],
"replicas": [
{
"container": "/messenger-lab4-api-1 running image=0387c3cfc941",
"action": "docker stop (SIGTERM, graceful)",
"before": {
"seconds": 5.0,
"successful_writes": 669,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 133.8,
"latency_ms_successful": {
"p50": 12.7,
"p95": 87.9,
"p99": 101.1
},
"max_write_gap_seconds": 0.085,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"stop_command_seconds": 3.527,
"target_last_success_after_stop_seconds": 1.476,
"outage_window": {
"seconds": 13.527,
"successful_writes": 1452,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 107.3,
"latency_ms_successful": {
"p50": 13.7,
"p95": 90.9,
"p99": 99.1
},
"max_write_gap_seconds": 0.106,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"restore_until_healthy_seconds": 5.401,
"restore_until_serving_seconds": 4.045,
"after_restore": {
"seconds": 5.025,
"successful_writes": 781,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 155.4,
"latency_ms_successful": {
"p50": 11.4,
"p95": 80.3,
"p99": 106.7
},
"max_write_gap_seconds": 0.091,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
}
},
{
"container": "/messenger-lab4-api-2 running image=0387c3cfc941",
"action": "docker stop (SIGTERM, graceful)",
"before": {
"seconds": 5.0,
"successful_writes": 777,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 155.4,
"latency_ms_successful": {
"p50": 11.4,
"p95": 80.2,
"p99": 106.7
},
"max_write_gap_seconds": 0.091,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"stop_command_seconds": 3.588,
"target_last_success_after_stop_seconds": 1.931,
"outage_window": {
"seconds": 13.588,
"successful_writes": 1560,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 114.8,
"latency_ms_successful": {
"p50": 12.6,
"p95": 90.6,
"p99": 149.4
},
"max_write_gap_seconds": 0.103,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
},
"restore_until_healthy_seconds": 5.974,
"restore_until_serving_seconds": 3.539,
"after_restore": {
"seconds": 5.035,
"successful_writes": 793,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 157.5,
"latency_ms_successful": {
"p50": 11.1,
"p95": 79.5,
"p99": 94.0
},
"max_write_gap_seconds": 0.148,
"instances": [
"0900a35b199d",
"bb4424f819bb"
]
}
}
],
"dataset": {
"messages_in_db_before": 265,
"messages_in_db_after": 7276
},
"history": {
"confirmed": 7011,
"stored": 7011,
"lost_confirmed": 0,
"duplicates": 0
},
"load": {
"workers": 4,
"model": "closed loop, POST message",
"warmup_seconds": 5,
"client_timeout_seconds": 2,
"retry": "same Idempotency-Key until success"
},
"date": "2026-11-05T14:07:08Z"
}
+52
View File
@@ -0,0 +1,52 @@
# make test-failover: stop-one.sh останавливает реплику, обслужившую тест; затем вторую
# date: 2026-11-05T13:58:43Z
# commit: f8e41b1
## Прогон 1
### до
/messenger-lab4-api-1 id=bb4424f819bb running exit=0 finished=2026-11-05T13:58:37.640782752Z
/messenger-lab4-api-2 id=0900a35b199d running exit=0 finished=2026-11-05T13:58:37.58216166Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://lb:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 125, "failed_attempts": 0, "first_recovery_seconds": 3.558}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
### после: остановленная реплика Exited (0) — штатное завершение по SIGTERM
/messenger-lab4-api-1 id=bb4424f819bb running exit=0 finished=2026-11-05T13:58:37.640782752Z
/messenger-lab4-api-2 id=0900a35b199d exited exit=0 finished=2026-11-05T13:58:47.981063522Z
### журнал HAProxy
Server api/api1 is DOWN, reason: Layer7 wrong status, code: 503, info: "Service Unavailable", check duration: 1ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server api/api1 was DOWN and now enters maintenance (No IP for server ).
остановлена реплика: 0900a35b199d
## Прогон 2
### до
/messenger-lab4-api-1 id=bb4424f819bb running exit=0 finished=2026-11-05T13:58:37.640782752Z
/messenger-lab4-api-2 id=0900a35b199d running exit=0 finished=2026-11-05T13:58:47.981063522Z
$ make test-failover ACTION_SCRIPT=scripts/stop-one.sh
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://lb:8080"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 130, "failed_attempts": 0, "first_recovery_seconds": 3.575}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
### после: остановленная реплика Exited (0) — штатное завершение по SIGTERM
/messenger-lab4-api-1 id=bb4424f819bb exited exit=0 finished=2026-11-05T13:59:08.399118281Z
/messenger-lab4-api-2 id=0900a35b199d running exit=0 finished=2026-11-05T13:58:47.981063522Z
### журнал HAProxy
Server api/api1 is UP, reason: Layer7 check passed, code: 200, check duration: 2ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Server api/api2 is DOWN, reason: Layer7 wrong status, code: 503, info: "Service Unavailable", check duration: 1ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
Server api/api2 was DOWN and now enters maintenance (No IP for server ).
остановлена реплика: bb4424f819bb
## Проверка guard: stop-one.sh отказывается останавливать не api
$ env TARGET_INSTANCE_ID=6285848df28a sh scripts/stop-one.sh
refusing to stop 6285848df28a: not an api replica of messenger-lab4 (messenger-lab4/postgres)
EXIT CODE 1
+143
View File
@@ -0,0 +1,143 @@
# Отказы зависимостей, ошибки LB, expiry
# date: 2026-11-05T14:08:50Z
# commit: f8e41b1
## 1. Redis остановлен: вход и Bearer через PostgreSQL; logout — 503 без отзыва (токен остаётся действующим)
$ docker compose stop redis
Container messenger-lab4-redis-1 Stopping
Container messenger-lab4-redis-1 Stopped
$ python3 scripts/probe.py logout
register -> 201
login -> 201 expires_at: 2026-11-05T15:08:51.406Z
GET /api/v1/users/me -> 200
DELETE /api/v1/auth/sessions/current -> 503 {"error": {"code": "unavailable", "message": "session cache unavailable", "request_id": "34e10540-6a85-41d2-a969-d375e95ede98"}}
GET /api/v1/users/me -> 200
$ docker compose start redis
Container messenger-lab4-secrets-init-1 Starting
Container messenger-lab4-secrets-init-1 Started
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Container messenger-lab4-redis-1 Starting
Container messenger-lab4-redis-1 Started
## 2. Redis снова доступен: logout отзывает токен на всех репликах
$ python3 scripts/probe.py logout
register -> 201
login -> 201 expires_at: 2026-11-05T15:08:56.699Z
GET /api/v1/users/me -> 200
DELETE /api/v1/auth/sessions/current -> 204
GET /api/v1/users/me -> 401
## 3. PostgreSQL остановлен: live 200, запрос с токеном — 503 без внутренних деталей, аноним — 401
$ docker compose stop postgres
Container messenger-lab4-postgres-1 Stopping
Container messenger-lab4-postgres-1 Stopped
$ python3 scripts/probe.py status GET /health/live
GET /health/live (anonymous) -> 200 {"status": "ok"}
$ python3 scripts/probe.py status GET /api/v1/chats Bearer unknown-token
GET /api/v1/chats (Bearer unknown-token) -> 503 {"error": {"code": "unavailable", "message": "database unavailable", "request_id": "1613a3ed-45d9-4d26-bdef-16d6a2a111fd"}}
$ python3 scripts/probe.py status GET /api/v1/users/me
GET /api/v1/users/me (anonymous) -> 401 {"error": {"code": "unauthorized", "message": "missing or invalid session", "request_id": "947900bb-f8b7-4dc9-8f17-4b049c7747dc"}}
$ docker compose start postgres
Container messenger-lab4-secrets-init-1 Starting
Container messenger-lab4-secrets-init-1 Started
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Container messenger-lab4-postgres-1 Starting
Container messenger-lab4-postgres-1 Started
$ python3 scripts/probe.py ready
ready
## 4. Все реплики API остановлены: LB отвечает 503 в формате ошибки контракта
$ docker compose stop api
Container messenger-lab4-api-3 Stopping
Container messenger-lab4-api-4 Stopping
Container messenger-lab4-api-4 Stopped
Container messenger-lab4-api-3 Stopped
$ python3 scripts/probe.py status GET /api/v1/users/me
GET /api/v1/users/me (anonymous) -> 503 {"error": {"code": "unavailable", "message": "no API replica available", "request_id": "483476c1-5e87-4bbe-8d77-3a172f3c8934"}}
$ docker compose start api
Container messenger-lab4-secrets-init-1 Starting
Container messenger-lab4-secrets-init-1 Started
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Container messenger-lab4-secrets-init-1 Exited
Container messenger-lab4-postgres-1 Waiting
Container messenger-lab4-secrets-init-1 Exited
Container messenger-lab4-s3-1 Waiting
Container messenger-lab4-postgres-1 Healthy
Container messenger-lab4-migrate-1 Starting
Container messenger-lab4-s3-1 Healthy
Container messenger-lab4-s3-init-1 Starting
Container messenger-lab4-migrate-1 Started
Container messenger-lab4-s3-init-1 Started
Container messenger-lab4-s3-init-1 Waiting
Container messenger-lab4-migrate-1 Waiting
Container messenger-lab4-s3-init-1 Exited
Container messenger-lab4-migrate-1 Exited
Container messenger-lab4-api-4 Starting
Container messenger-lab4-api-4 Started
Container messenger-lab4-api-3 Starting
Container messenger-lab4-api-3 Started
$ python3 scripts/probe.py ready
ready
## 5. Живая, но неготовая реплика: PostgreSQL отклоняет подключения только от одной API (pg_hba reject)
target=4f49dcd66a29 ip=172.27.0.7
$ docker exec 4f49dcd66a29 node -e let n=0;const g=p=>require('http').get('http://127.0.0.1:8080'+p,r=>{console.log(p,r.statusCode);r.resume();if(++n===2)process.exit(0)});g('/health/live');g('/health/core')
/health/live 200
/health/core 503
$ python3 scripts/probe.py instances 10
register -> 201
login -> 201 expires_at: 2026-11-05T15:09:17.986Z
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
Server api/api1 is UP, reason: Layer7 check passed, code: 200, check duration: 2ms. 2 active and 0 backup servers online. 0 sessions requeued, 0 total in queue.
Server api/api2 is DOWN, reason: Layer7 wrong status, code: 503, info: "Service Unavailable", check duration: 4ms. 1 active and 0 backup servers left. 0 sessions active, 0 requeued, 0 remaining in queue.
### доступ возвращён: реплика снова готова и получает запросы
$ python3 scripts/probe.py instances 6
register -> 201
login -> 201 expires_at: 2026-11-05T15:09:22.744Z
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 4f49dcd66a29
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 4f49dcd66a29
GET /api/v1/users/me -> 200 X-Instance-Id: 984f0bba8d26
GET /api/v1/users/me -> 200 X-Instance-Id: 4f49dcd66a29
## 6. Expiry: реплики пересозданы с SESSION_TTL_SECONDS=2
$ sh -c docker exec $(docker compose ps -q api | head -1) printenv SESSION_TTL_SECONDS
2
$ python3 scripts/probe.py expiry 2
register -> 201
login -> 201 expires_at: 2026-11-05T14:09:35.576Z
GET /api/v1/users/me (fresh) -> 200
GET /api/v1/users/me (after 3s) -> 401
$ python3 scripts/probe.py ready
ready
+12
View File
@@ -0,0 +1,12 @@
{
"scenario": "parallel POST with one Idempotency-Key through LB",
"requests": 20,
"all_201": true,
"distinct_message_ids": 1,
"instances": [
"0900a35b199d",
"bb4424f819bb"
],
"messages_in_history": 1,
"date": "2026-11-05T14:06:10Z"
}
+24
View File
@@ -0,0 +1,24 @@
# make test-persistence: restart.sh перезапускает postgres, redis, s3, api, lb с сохранением volumes
# date: 2026-11-05T13:58:32Z
# commit: f8e41b1
## до
/messenger-lab4-api-1 running started=2026-11-05T13:56:27.073950909Z
/messenger-lab4-api-2 running started=2026-11-05T13:56:27.359178642Z
/messenger-lab4-lb-1 running started=2026-11-05T13:56:33.130552561Z
/messenger-lab4-postgres-1 running started=2026-11-05T13:56:17.503936862Z
/messenger-lab4-redis-1 running started=2026-11-05T13:56:17.512981001Z
/messenger-lab4-s3-1 running started=2026-11-05T13:56:17.516358837Z
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://lb: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.
## после
/messenger-lab4-api-1 running started=2026-11-05T13:58:38.339108415Z
/messenger-lab4-api-2 running started=2026-11-05T13:58:38.170906453Z
/messenger-lab4-lb-1 running started=2026-11-05T13:58:36.012363468Z
/messenger-lab4-postgres-1 running started=2026-11-05T13:58:35.944741705Z
/messenger-lab4-redis-1 running started=2026-11-05T13:58:35.661397483Z
/messenger-lab4-s3-1 running started=2026-11-05T13:58:35.410755983Z
+69
View File
@@ -0,0 +1,69 @@
{
"scenario": "rolling replacement: migrate once, then add new replica, wait healthy, stop old one",
"resources_under_load": [
"messenger-lab4-api-1 cpu=49.37% mem=104.1MiB / 256MiB",
"messenger-lab4-api-2 cpu=50.09% mem=121.8MiB / 256MiB",
"messenger-lab4-lb-1 cpu=10.88% mem=16.03MiB / 64MiB",
"messenger-lab4-postgres-1 cpu=24.86% mem=68.67MiB / 512MiB",
"messenger-lab4-reconciler-1 cpu=0.00% mem=32.57MiB / 128MiB",
"messenger-lab4-redis-1 cpu=1.69% mem=8.105MiB / 128MiB",
"messenger-lab4-s3-1 cpu=0.09% mem=248.8MiB / 512MiB"
],
"before": [
"/messenger-lab4-api-1 running image=0387c3cfc941",
"/messenger-lab4-api-2 running image=0387c3cfc941"
],
"after": [
"/messenger-lab4-api-3 running image=b352fc8e08ea",
"/messenger-lab4-api-4 running image=b352fc8e08ea"
],
"steps": [
{
"replaced": "bb4424f819bb",
"new_replica_ready_seconds": 6.727,
"step_seconds": 10.356
},
{
"replaced": "0900a35b199d",
"new_replica_ready_seconds": 6.775,
"step_seconds": 10.466
}
],
"during_update": {
"seconds": 33.715,
"successful_writes": 4320,
"failed_attempts": 0,
"error_ratio": 0.0,
"successful_rps": 128.1,
"latency_ms_successful": {
"p50": 15.2,
"p95": 83.5,
"p99": 110.6
},
"max_write_gap_seconds": 0.215,
"instances": [
"0900a35b199d",
"4f49dcd66a29",
"984f0bba8d26",
"bb4424f819bb"
]
},
"dataset": {
"messages_in_db_before": 12641,
"messages_in_db_after": 17944
},
"history": {
"confirmed": 5303,
"stored": 5303,
"lost_confirmed": 0,
"duplicates": 0
},
"load": {
"workers": 4,
"model": "closed loop, POST message",
"warmup_seconds": 5,
"client_timeout_seconds": 2,
"retry": "same Idempotency-Key until success"
},
"date": "2026-11-05T14:08:50Z"
}
+88
View File
@@ -0,0 +1,88 @@
# S3: идемпотентный bootstrap, приватность мимо API, отказ S3, сверка
# date: 2026-11-05T14:00:11Z
# commit: f8e41b1
## Повторный bootstrap ничего не ломает
$ docker compose run --rm --no-deps -T s3-init
Bucket created successfully `root/messenger-attachments`.
Access permission for `root/messenger-attachments` is set to `private`
Created policy `messenger-api` successfully.
bucket messenger-attachments ready
$ docker compose run --rm --no-deps -T s3-init
Bucket created successfully `root/messenger-attachments`.
Access permission for `root/messenger-attachments` is set to `private`
Created policy `messenger-api` successfully.
bucket messenger-attachments ready
$ sh scripts/check-s3.sh
## S3 не опубликован наружу, консоль выключена
s3 ports=9000/tcp
MINIO_BROWSER=off
## Права пользователя API: только свой bucket
PUT в свой bucket -> allowed
GET из своего bucket -> allowed
создание другого bucket -> denied
GET из другого bucket -> denied
PUT в другой bucket -> denied
изменение политики bucket -> denied
администрирование пользователей -> denied
## Анонимный доступ напрямую к S3, мимо API
GET messenger-attachments/<object> -> 403
GET messenger-attachments/ -> 403
PUT messenger-attachments/anon.txt -> 403
PASS: bucket приватный, у API нет прав вне своего bucket
## Отказ: контейнер S3 остановлен
$ sh scripts/s3-outage.sh stop
## S3: stop
GET /health/live -> 200 0.01s X-Instance-Id=yes
GET /health/ready -> 503 unavailable 1.01s X-Instance-Id=yes
GET /attachments/{id} -> 200 0.01s X-Instance-Id=yes
GET /attachments/{id}/content -> 503 unavailable 1.01s X-Instance-Id=yes
POST /attachments -> 503 unavailable 1.03s X-Instance-Id=yes
POST /messages (текст) -> 201 0.03s X-Instance-Id=yes
## S3 восстановлен
GET /health/ready -> 200 0.01s X-Instance-Id=yes
GET /attachments/{id}/content -> 200 0.01s X-Instance-Id=yes
sha256 совпадает: True
## Отказ: контейнер S3 завис (docker pause)
$ sh scripts/s3-outage.sh pause
## S3: pause
GET /health/live -> 200 0.01s X-Instance-Id=yes
GET /health/ready -> 503 unavailable 1.01s X-Instance-Id=yes
GET /attachments/{id} -> 200 0.01s X-Instance-Id=yes
GET /attachments/{id}/content -> 503 unavailable 5.01s X-Instance-Id=yes
POST /attachments -> 503 unavailable 5.02s X-Instance-Id=yes
POST /messages (текст) -> 201 0.01s X-Instance-Id=yes
## S3 восстановлен
GET /health/ready -> 200 0.01s X-Instance-Id=yes
GET /attachments/{id}/content -> 200 0.01s X-Instance-Id=yes
sha256 совпадает: True
## Сверка: объект без метаданных
$ sh scripts/reconcile-demo.sh
## Отказ между S3 и БД: объект есть, строки нет
Name : orphan-1793887242
## Свежий объект, grace 3600 с, --apply: не удалён
{"mode":"apply","grace_seconds":3600,"scanned":12,"fresh_skipped":12,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":294}
объект на месте
## Dry-run, grace 1 с: найден, не удалён
{"mode":"dry-run","grace_seconds":1,"scanned":12,"fresh_skipped":0,"referenced":11,"orphans":1,"deleted":0,"failed":0,"orphan_keys":["attachments/orphan-1793887242"],"duration_ms":299}
объект на месте
## --apply, grace 1 с: удалён только он
{"mode":"apply","grace_seconds":1,"scanned":12,"fresh_skipped":0,"referenced":11,"orphans":1,"deleted":1,"failed":0,"orphan_keys":["attachments/orphan-1793887242"],"duration_ms":305}
объект удалён
## Повторный запуск: удалять нечего
{"mode":"apply","grace_seconds":1,"scanned":11,"fresh_skipped":0,"referenced":11,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":292}
## Журнал постоянного сервиса reconciler
{"mode":"apply","grace_seconds":3600,"scanned":0,"fresh_skipped":0,"referenced":0,"orphans":0,"deleted":0,"failed":0,"orphan_keys":[],"duration_ms":219}
+26
View File
@@ -0,0 +1,26 @@
# Публичные проверки через LB; разные реплики обслуживают одну сессию
# date: 2026-11-05T13:58:22Z
# commit: f8e41b1
$ make check
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
$ make test
python3 tests/smoke.py --base-url "http://lb:8080"
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
$ sh -c docker compose ps -q api | cut -c1-12
bb4424f819bb
0900a35b199d
$ python3 scripts/probe.py instances 6
register -> 201
login -> 201 expires_at: 2026-11-05T14:58:32.678Z
GET /api/v1/users/me -> 200 X-Instance-Id: 0900a35b199d
GET /api/v1/users/me -> 200 X-Instance-Id: bb4424f819bb
GET /api/v1/users/me -> 200 X-Instance-Id: 0900a35b199d
GET /api/v1/users/me -> 200 X-Instance-Id: bb4424f819bb
GET /api/v1/users/me -> 200 X-Instance-Id: 0900a35b199d
GET /api/v1/users/me -> 200 X-Instance-Id: bb4424f819bb
+300
View File
@@ -0,0 +1,300 @@
# Собственные e2e-тесты (PostgreSQL + Redis + MinIO из compose.test.yaml)
# date: 2026-11-05T13:56:52Z
# commit: f8e41b1
$ docker compose -f compose.test.yaml run --rm tests npx jest --config ./test/jest-e2e.json --verbose
Network messenger-lab4-test_default Creating
Network messenger-lab4-test_default Created
Container messenger-lab4-test-redis-1 Creating
Container messenger-lab4-test-postgres-1 Creating
Container messenger-lab4-test-s3-1 Creating
Container messenger-lab4-test-s3-1 Created
Container messenger-lab4-test-redis-1 Created
Container messenger-lab4-test-postgres-1 Created
Container messenger-lab4-test-s3-1 Starting
Container messenger-lab4-test-postgres-1 Starting
Container messenger-lab4-test-redis-1 Starting
Container messenger-lab4-test-s3-1 Started
Container messenger-lab4-test-postgres-1 Started
Container messenger-lab4-test-redis-1 Started
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "messenger_test", schema "public" at "postgres:5432"
4 migrations found in prisma/migrations
Applying migration `20261021000000_init`
Applying migration `20261021010000_auth_sessions`
Applying migration `20261101000000_idempotency_keys`
Applying migration `20261105000000_attachments`
The following migration(s) have been applied:
migrations/
└─ 20261021000000_init/
└─ migration.sql
└─ 20261021010000_auth_sessions/
└─ migration.sql
└─ 20261101000000_idempotency_keys/
└─ migration.sql
└─ 20261105000000_attachments/
└─ migration.sql
All migrations have been successfully applied.
PASS test/docs.e2e-spec.ts (36.929 s)
Swagger UI и примеры (e2e)
✓ отдаёт Swagger UI и документ контракта со всеми путями (129 ms)
✓ каждый пример запроса и ответа проходит JSON Schema контракта (1216 ms)
[Nest] 199 - 11/05/2026, 1:57:48 PM  ERROR [HttpExceptionFilter] DELETE /api/v1/auth/sessions/current -> 503: session cache unavailable
PASS test/concurrency.e2e-spec.ts (39.993 s)
Безопасность при конкурентном доступе (e2e)
✓ принимает 100 конкурентных сообщений от 10 клиентов и сохраняет ровно 100 уникальных (6695 ms)
✓ регистрирует ровно одного пользователя при гонке 10 запросов за один и тот же username (255 ms)
PASS test/auth.e2e-spec.ts (40.18 s)
Аутентификация и сессии (e2e)
регистрация
✓ требует password (1114 ms)
✓ отклоняет password короче 12 code points (39 ms)
✓ хранит пароль как Argon2id-хеш, а не открытым текстом (1457 ms)
POST /api/v1/auth/sessions
✓ выдаёт непрозрачный Bearer-токен с expires_at и пользователем (1872 ms)
✓ принимает пароль с двоеточием и не-ASCII символами (212 ms)
✓ отвечает одинаковым 401 на неверный пароль и неизвестного пользователя (1050 ms)
✓ отклоняет JSON body при входе даже с верным Basic (222 ms)
✓ отвечает 401 без заголовка Authorization (87 ms)
защищённые endpoint
✓ не принимают Basic (274 ms)
✓ не принимают X-User-Id сам по себе (367 ms)
✓ игнорируют X-User-Id рядом с Bearer (368 ms)
✓ отвечают 401 на неизвестный токен (12 ms)
DELETE /api/v1/auth/sessions/current
✓ отзывает только текущий токен: 204, затем 401 на повтор (286 ms)
[Nest] 186 - 11/05/2026, 1:57:48 PM  ERROR [HttpExceptionFilter] GET /health/ready -> 503: object storage unavailable
PASS test/reconciler.e2e-spec.ts (40.637 s)
Сверка объектов S3 с метаданными (e2e)
✓ dry-run сообщает о сироте и ничего не удаляет, apply удаляет, повторный запуск ничего не делает (1848 ms)
✓ не трогает свежий объект внутри grace period (882 ms)
✓ не трогает старый объект, на который есть метаданные (431 ms)
✓ при отказе PostgreSQL проход прерывается и ничего не удаляет (304 ms)
✓ сбой удаления считается и повторяется на следующем проходе (709 ms)
✓ обходит все страницы листинга (276 ms)
✓ реальная загрузка остаётся доступной после сверки всего bucket префикса вложений (280 ms)
Готовность при отказе S3 (e2e)
✓ ready — 503 с заголовками за короткое время, live и core — 200 (214 ms)
✓ при рабочем S3 ready — 200 (151 ms)
[Nest] 199 - 11/05/2026, 1:57:49 PM  ERROR [HttpExceptionFilter] DELETE /api/v1/auth/sessions/current -> 503: session cache unavailable
[Nest] 180 - 11/05/2026, 1:57:49 PM  ERROR [S3Service] get attachments/c5c757b1-4a1e-4d7d-bd28-bde4aac0ba5b failed: Error
[Nest] 180 - 11/05/2026, 1:57:49 PM  ERROR [HttpExceptionFilter] GET /api/v1/attachments/c5c757b1-4a1e-4d7d-bd28-bde4aac0ba5b/content -> 503: object storage unavailable
[Nest] 180 - 11/05/2026, 1:57:49 PM  ERROR [S3Service] get attachments/3895acb2-be69-4f6a-a6fa-7152175fcc99 failed: NoSuchKey
[Nest] 180 - 11/05/2026, 1:57:49 PM  ERROR [HttpExceptionFilter] GET /api/v1/attachments/3895acb2-be69-4f6a-a6fa-7152175fcc99/content -> 500: Internal server error
[Nest] 199 - 11/05/2026, 1:57:50 PM  ERROR [HttpExceptionFilter] GET /health/ready -> 503: database unavailable
[Nest] 199 - 11/05/2026, 1:57:50 PM  ERROR [HttpExceptionFilter] GET /api/v1/chats -> 503: database unavailable
[Nest] 199 - 11/05/2026, 1:57:50 PM  ERROR [HttpExceptionFilter] GET /api/v1/chats -> 503: database unavailable
[Nest] 199 - 11/05/2026, 1:57:50 PM  ERROR [HttpExceptionFilter] POST /api/v1/users -> 503: database unavailable
[Nest] 199 - 11/05/2026, 1:57:50 PM  ERROR [HttpExceptionFilter] GET /api/v1/chats -> 500: Internal server error
PASS test/failures.e2e-spec.ts (42.799 s)
Уровень 4: expiry, отказы зависимостей, rollback (e2e)
✓ сессия истекает при коротком SESSION_TTL_SECONDS, в том числе из кэша (6117 ms)
✓ без Redis вход и проверка сессии работают через PostgreSQL, logout — 503 без отзыва (1677 ms)
✓ logout через реплику без связи с Redis не создаёт расхождения с репликой, у которой сессия в кэше (1178 ms)
✓ без PostgreSQL отвечает ограниченным 503 и не пускает анонима (996 ms)
✓ неожиданное исключение — 500 internal_error без деталей, с X-Request-Id и X-Instance-Id (319 ms)
✓ откатывает создание чата целиком, если один из участников не существует (343 ms)
PASS test/idempotency.e2e-spec.ts (42.892 s)
Идемпотентность отправки и X-Instance-Id (e2e)
✓ требует Idempotency-Key правильного формата (2420 ms)
✓ повтор с тем же ключом и телом возвращает тот же 201 и то же сообщение (2546 ms)
✓ тот же ключ с другим телом — 409, сообщение не создаётся (1433 ms)
✓ 20 параллельных запросов с одним ключом через два экземпляра создают ровно одно сообщение (601 ms)
✓ область ключа — пользователь и чат: одинаковый ключ у разных пользователей и чатов независим (393 ms)
✓ повтор заново проверяет сессию (162 ms)
✓ после IDEMPOTENCY_TTL_SECONDS ключ можно использовать заново (1780 ms)
✓ X-Instance-Id есть в успешных ответах, ошибках и health и стабилен в процессе (177 ms)
PASS test/attachment-access.e2e-spec.ts (44.094 s)
Скачивание и привязка вложений (e2e)
чтение
✓ участник получает метаданные и оригинал побайтно (1434 ms)
✓ JPEG отдаётся с истинным Content-Type (178 ms)
✓ посторонний и неизвестный ID получают одинаковый 404 (191 ms)
✓ без токена 401, неверный UUID 400 (88 ms)
✓ variant: original явно, отсутствующий 404, неизвестный и повторённый 400 (219 ms)
✓ нет доступа к S3 — метаданные 200, content 503 с заголовками (298 ms)
✓ объект пропал из S3 — 500 без внутренних деталей (156 ms)
attachment_ids в сообщениях
✓ text="" с вложением принимается, Message читается вторым участником (136 ms)
✓ порядок [B, A] сохраняется в ответе, истории и повторе; перестановка с тем же ключом — 409 (539 ms)
✓ отсутствующий attachment_ids и [] равны при повторе, изменение списка — 409 (159 ms)
✓ вложение другого чата и неизвестное — одинаковый 404, сообщение не создаётся (141 ms)
✓ смесь своего и чужого вложения — 404 (214 ms)
✓ посторонний не может отправить вложение в чужой чат (106 ms)
✓ любой участник может сослаться на вложение чата, вложение можно использовать повторно (142 ms)
✓ ровно 10 вложений принимается, 11 — 400 (677 ms)
✓ UUID в другом регистре — тот же ID и дубль (102 ms)
✓ text отсутствует — 400 (93 ms)
✓ text null — 400 (77 ms)
✓ attachment_ids null — 400 (61 ms)
✓ attachment_ids строка — 400 (133 ms)
✓ элемент не UUID — 400 (77 ms)
✓ элемент число — 400 (112 ms)
✓ дубликат — 400 (95 ms)
✓ пустой текст без вложений — 400 (126 ms)
✓ пробельный текст без вложений — 400 (84 ms)
PASS test/api.e2e-spec.ts (48.453 s)
API мессенджера (e2e) — граничные случаи сверх публичного smoke
POST /api/v1/users
✓ отклоняет некорректный JSON с кодом 400 (565 ms)
✓ отклоняет тело с лишними полями (716 ms)
✓ отклоняет username с заглавными буквами (35 ms)
✓ отклоняет display_name из одних пробелов (17 ms)
✓ отклоняет дубликат username с кодом 409 (2341 ms)
✓ никогда не возвращает поле пароля или его хэша (139 ms)
✓ отклоняет username короче 3 символов (9 ms)
✓ отклоняет username длиннее 32 символов (12 ms)
✓ отклоняет username с недопустимыми символами (дефис) (12 ms)
✓ принимает username ровно на границах длины 3 и 32 символа (237 ms)
✓ отклоняет display_name длиннее 100 Unicode code points (39 ms)
✓ принимает display_name ровно из 100 code points, считая эмодзи вне BMP за один символ (69 ms)
✓ отклоняет display_name из 101 code point, состоящий из эмодзи вне BMP (8 ms)
контроль доступа
✓ возвращает 401 раньше 404, если и актор, и ресурс невалидны (23 ms)
✓ возвращает 404 (не 403), когда чат запрашивает не его участник (2329 ms)
✓ отклоняет создание чата, если вызывающий не входит в member_ids (409 ms)
✓ отклоняет создание чата с дублирующимися member_ids (134 ms)
✓ считает один UUID в разном регистре дубликатом и узнаёт вызывающего в верхнем регистре (167 ms)
✓ принимает ровно 100 участников и отклоняет 101 (222 ms)
✓ отклоняет создание чата с неизвестным участником (134 ms)
✓ отклоняет создание чата с пустым/пробельным title (102 ms)
✓ возвращает 400 для синтаксически некорректного chat_id (не UUID) (103 ms)
✓ возвращает 404 для корректного по формату, но несуществующего chat_id (122 ms)
GET /api/v1/chats (пагинация)
✓ использует limit=50 по умолчанию, если limit не передан (128 ms)
✓ отклоняет нечисловой limit (219 ms)
✓ отклоняет limit=0 (115 ms)
✓ отклоняет повторённые limit и cursor (112 ms)
✓ отклоняет cursor, не являющийся корректным base64url JSON (156 ms)
✓ отклоняет корректно закодированный cursor с id чата, который никогда не существовал (149 ms)
✓ обходит весь список чатов по страницам без пропусков и дублей (255 ms)
сообщения
✓ не принимает sender_id, переданный клиентом (528 ms)
✓ считает attachment_ids: [] равным отсутствию поля, неизвестный ID — 404, неверный тип — 400 (295 ms)
✓ отклоняет пустое сообщение (270 ms)
✓ отклоняет сообщение из одних пробелов (233 ms)
✓ отклоняет отправку в чат, где вызывающий не участник (491 ms)
✓ отклоняет limit=0 при чтении истории (260 ms)
✓ отклоняет limit=101 при чтении истории (234 ms)
✓ отклоняет нечисловой limit (591 ms)
✓ отклоняет текст сообщения длиннее 4000 Unicode code points (265 ms)
✓ принимает текст сообщения ровно из 4000 Unicode code points (275 ms)
✓ отклоняет текст сообщения свыше 4000 code points, состоящий из эмодзи вне BMP (325 ms)
✓ отклоняет cursor, не являющийся корректным base64url JSON (345 ms)
✓ отклоняет корректно закодированный cursor с id сообщения, которое никогда не существовало в этом чате (372 ms)
✓ возвращает 400 для синтаксически некорректного chat_id при отправке сообщения (112 ms)
✓ возвращает 400 для синтаксически некорректного chat_id при чтении истории (120 ms)
✓ отклоняет cursor, взятый из другого чата (355 ms)
✓ обходит всю историю по страницам без пропусков и дублей (824 ms)
X-Request-Id
✓ присутствует и уникален для независимых запросов (10 ms)
✓ совпадает с request_id внутри тела ошибки (26 ms)
console.warn
An error was encountered in a non-retryable streaming request.
150 | private async guard<T>(action: string, run: () => Promise<T>): Promise<T> {
151 | try {
> 152 | return await run();
| ^
153 | } catch (error) {
154 | const reason = error instanceof Error ? error.name : 'unknown error';
155 | this.logger.error(`${action} failed: ${reason}`);
at ../node_modules/@smithy/middleware-retry/dist-cjs/index.js:329:125
at ../node_modules/@aws-sdk/middleware-flexible-checksums/dist-cjs/index.js:263:18
at ../node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:110:22
at ../node_modules/@aws-sdk/middleware-sdk-s3/dist-cjs/index.js:138:14
at ../node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22
at S3Service.guard (../src/storage/s3.service.ts:152:11)
at S3Service.putFile (../src/storage/s3.service.ts:64:3)
at AttachmentsService.store (../src/attachments/attachments.service.ts:117:3)
at AttachmentsService.upload (../src/attachments/attachments.service.ts:63:11)
at AttachmentsController.upload (../src/attachments/attachments.controller.ts:36:22)
at ../node_modules/@nestjs/core/router/router-execution-context.js:46:28
at Object.<anonymous> (../node_modules/@nestjs/core/router/router-proxy.js:9:17)
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [S3Service] put attachments/7ce5f967-a067-4b1e-820b-05e913049840 failed: Error
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [HttpExceptionFilter] POST /api/v1/chats/767cc2b1-fc46-43e1-8c56-40997227b614/attachments?filename=a.png -> 503: object storage unavailable
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [HttpExceptionFilter] POST /api/v1/chats/767cc2b1-fc46-43e1-8c56-40997227b614/attachments?filename=sample.png -> 500: Internal server error
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [AttachmentsService] metadata insert failed for attachments/9a51c460-2292-49ed-80dc-bb1001ac37b7
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [HttpExceptionFilter] POST /api/v1/chats/767cc2b1-fc46-43e1-8c56-40997227b614/attachments?filename=sample.png -> 503: database unavailable
[Nest] 174 - 11/05/2026, 1:58:03 PM  ERROR [HttpExceptionFilter] POST /api/v1/chats/767cc2b1-fc46-43e1-8c56-40997227b614/attachments?filename=sample.png -> 503: database unavailable
PASS test/attachments.e2e-spec.ts (55.555 s)
Загрузка вложений (e2e)
успешная загрузка
✓ возвращает 201 Attachment по контракту и сохраняет метаданные (1699 ms)
✓ принимает реальный JPEG (129 ms)
✓ игнорирует параметры и регистр Content-Type (96 ms)
✓ принимает файл ровно 10 MiB, filename ровно 255 символов и PNG с байтами после IEND (2012 ms)
✓ принимает ровно 40 млн пикселей (9399 ms)
порядок проверок и доступ
✓ без токена — 401 раньше любых проверок содержимого (33 ms)
✓ посторонний и несуществующий чат — одинаковый 404, чужой файл не сохраняется (43 ms)
✓ неверный UUID чата — 400 (7 ms)
filename
✓ отсутствует — 400 (14 ms)
✓ пустой — 400 (8 ms)
✓ только пробелы — 400 (9 ms)
✓ 256 символов — 400 (7 ms)
✓ путь через / — 400 (8 ms)
✓ путь через \ — 400 (6 ms)
✓ NUL — 400 (8 ms)
✓ перевод строки — 400 (5 ms)
✓ DEL — 400 (6 ms)
✓ C1 U+0085 — 400 (10 ms)
✓ разделитель строк U+2028 — 400 (6 ms)
✓ повторённый параметр — 400 (6 ms)
тип содержимого
✓ Content-Type text/plain — 415 (5 ms)
✓ Content-Type application/json — 415 (102 ms)
✓ Content-Type application/octet-stream — 415 (7 ms)
✓ Content-Type multipart/form-data; boundary=x — 415 (6 ms)
✓ Content-Type image/gif — 415 (8 ms)
✓ Content-Type image/webp — 415 (6 ms)
✓ без Content-Type — 415 (6 ms)
✓ подмена MIME в обе стороны и чужие форматы — 415 (57 ms)
✓ пустое тело — 400 (25 ms)
повреждённые изображения
✓ PNG: первые 33 байта sample.png — 415 (15 ms)
✓ PNG: половина файла — 415 (19 ms)
✓ PNG: без последних 20 байт — 415 (20 ms)
✓ PNG: без IEND — 415 (18 ms)
✓ PNG: неверный CRC — 415 (51 ms)
✓ PNG: фильтр строки 5 — 415 (13 ms)
✓ PNG: фильтр строки 255 — 415 (13 ms)
✓ PNG: неверный фильтр в последней строке — 415 (16 ms)
✓ PNG: мусор в IDAT с верным CRC — 415 (24 ms)
✓ PNG: данных меньше, чем строк — 415 (17 ms)
✓ PNG: палитра на 257 записей — 415 (11 ms)
✓ JPEG: все повреждения — 415 (63 ms)
лимиты
✓ 10 MiB + 1 байт — 413 и без чтения объявленного тела (1266 ms)
✓ превышение при chunked без Content-Length — 413 (801 ms)
✓ превышение лимита пикселей — 413 до декодирования (28 ms)
✓ оборванная загрузка не оставляет временных файлов и строк в БД (810 ms)
отказы
✓ S3 недоступен — 503 с заголовками, метаданные не создаются (193 ms)
✓ явный отказ INSERT после PUT удаляет объект (77 ms)
✓ необработанная ошибка PostgreSQL при INSERT — 503, объект не удаляется (45 ms)
✓ при неясном исходе COMMIT объект не удаляется (41 ms)
A worker process has failed to exit gracefully and has been force exited. This is likely caused by tests leaking due to improper teardown. Try running with --detectOpenHandles to find leaks. Active timers can also cause this, ensure that .unref() was called on them.
Test Suites: 9 passed, 9 total
Tests: 163 passed, 163 total
Snapshots: 0 total
Time: 56.981 s
Ran all test suites.
+536
View File
@@ -0,0 +1,536 @@
{
"date": "2026-11-05T14:06:08Z",
"api_replica_limits": {
"cpus": 0.5,
"memory_mib": 256
},
"rows_after_attachments_messages": "290|264",
"results": [
{
"profile": "sample 112 KiB x10",
"body_bytes": 111817,
"content_type": "image/png",
"concurrency": 10,
"rounds": 3,
"requests": 30,
"statuses": {
"201": 30
},
"wall_seconds": 2.02,
"successful_rps": 14.83,
"error_rate": 0.0,
"latency_seconds": {
"p50": 0.488,
"p95": 0.707,
"p99": 0.811
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 118,
"vm_hwm_mib": 118,
"cgroup_max_usage_with_page_cache_mib": 73,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
},
"0900a35b199d": {
"idle_rss_mib": 103,
"sampled_peak_rss_mib": 113,
"vm_hwm_mib": 113,
"cgroup_max_usage_with_page_cache_mib": 64,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 4.55,
"last_mem": "121.2MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 1.91,
"last_mem": "12.31MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 40.14,
"last_mem": "64.27MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 43.73,
"last_mem": "56.66MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "29.14MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 0.55,
"last_mem": "8.105MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 5.16,
"last_mem": "34.39MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 5.51,
"last_mem": "68.39MiB"
}
}
},
{
"profile": "png 10 MiB x1",
"body_bytes": 10485760,
"content_type": "image/png",
"concurrency": 1,
"rounds": 3,
"requests": 3,
"statuses": {
"201": 3
},
"wall_seconds": 1.8,
"successful_rps": 1.67,
"error_rate": 0.0,
"latency_seconds": {
"p50": 0.69,
"p95": 0.742,
"p99": 0.742
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 103,
"sampled_peak_rss_mib": 112,
"vm_hwm_mib": 121,
"cgroup_max_usage_with_page_cache_mib": 74,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 1
},
"0900a35b199d": {
"idle_rss_mib": 105,
"sampled_peak_rss_mib": 122,
"vm_hwm_mib": 122,
"cgroup_max_usage_with_page_cache_mib": 77,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 2
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 0.75,
"last_mem": "119.3MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 0.55,
"last_mem": "12.31MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 12.44,
"last_mem": "57.14MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 24.71,
"last_mem": "67.43MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 3.9,
"last_mem": "30.21MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 0.47,
"last_mem": "8.23MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 1.02,
"last_mem": "32MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 5.27,
"last_mem": "87.09MiB"
}
}
},
{
"profile": "png 10 MiB x10",
"body_bytes": 10485760,
"content_type": "image/png",
"concurrency": 10,
"rounds": 3,
"requests": 30,
"statuses": {
"201": 30
},
"wall_seconds": 9.58,
"successful_rps": 3.13,
"error_rate": 0.0,
"latency_seconds": {
"p50": 2.945,
"p95": 3.77,
"p99": 3.771
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 103,
"sampled_peak_rss_mib": 142,
"vm_hwm_mib": 142,
"cgroup_max_usage_with_page_cache_mib": 145,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
},
"0900a35b199d": {
"idle_rss_mib": 105,
"sampled_peak_rss_mib": 143,
"vm_hwm_mib": 144,
"cgroup_max_usage_with_page_cache_mib": 139,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 8.22,
"last_mem": "103.6MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 9.11,
"last_mem": "12.32MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 54.38,
"last_mem": "85.79MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 54.51,
"last_mem": "87.57MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "30.12MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 3.06,
"last_mem": "8.234MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 5.81,
"last_mem": "44.02MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 46.28,
"last_mem": "147.5MiB"
}
}
},
{
"profile": "png 40 MP x10",
"body_bytes": 126786,
"content_type": "image/png",
"concurrency": 10,
"rounds": 3,
"requests": 30,
"statuses": {
"201": 30
},
"wall_seconds": 89.21,
"successful_rps": 0.34,
"error_rate": 0.0,
"latency_seconds": {
"p50": 23.187,
"p95": 33.475,
"p99": 33.514
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 152,
"vm_hwm_mib": 153,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
},
"0900a35b199d": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 160,
"vm_hwm_mib": 163,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 2.34,
"last_mem": "111.8MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 1.26,
"last_mem": "12.33MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 55.41,
"last_mem": "66.35MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 54.7,
"last_mem": "67.4MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "30.14MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 8.95,
"last_mem": "8.105MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 5.1,
"last_mem": "45MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 7.63,
"last_mem": "160.1MiB"
}
}
},
{
"profile": "jpeg 40 MP x10",
"body_bytes": 235018,
"content_type": "image/jpeg",
"concurrency": 10,
"rounds": 3,
"requests": 30,
"statuses": {
"201": 30
},
"wall_seconds": 86.77,
"successful_rps": 0.35,
"error_rate": 0.0,
"latency_seconds": {
"p50": 21.567,
"p95": 29.473,
"p99": 29.817
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 103,
"sampled_peak_rss_mib": 150,
"vm_hwm_mib": 158,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
},
"0900a35b199d": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 160,
"vm_hwm_mib": 163,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 15
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 1.93,
"last_mem": "102MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 0.61,
"last_mem": "12.42MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 54.66,
"last_mem": "48.4MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 55.35,
"last_mem": "58.52MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "30.15MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 3.8,
"last_mem": "8.105MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 3.13,
"last_mem": "45.41MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 5.96,
"last_mem": "161.7MiB"
}
}
},
{
"profile": "png 10 MiB x20",
"body_bytes": 10485760,
"content_type": "image/png",
"concurrency": 20,
"rounds": 3,
"requests": 60,
"statuses": {
"201": 60
},
"wall_seconds": 16.62,
"successful_rps": 3.61,
"error_rate": 0.0,
"latency_seconds": {
"p50": 4.453,
"p95": 6.507,
"p99": 6.588
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 106,
"sampled_peak_rss_mib": 151,
"vm_hwm_mib": 151,
"cgroup_max_usage_with_page_cache_mib": 199,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 30
},
"0900a35b199d": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 148,
"vm_hwm_mib": 148,
"cgroup_max_usage_with_page_cache_mib": 194,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 30
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 1.92,
"last_mem": "104MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 12.15,
"last_mem": "12.68MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 54.25,
"last_mem": "96.46MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 54.62,
"last_mem": "91.93MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "30.15MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 3.07,
"last_mem": "8.23MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 4.49,
"last_mem": "47.98MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 49.68,
"last_mem": "174.5MiB"
}
}
},
{
"profile": "png 10 MiB x40 (выше лимита 16 на реплику)",
"body_bytes": 10485760,
"content_type": "image/png",
"concurrency": 40,
"rounds": 3,
"requests": 120,
"statuses": {
"503": 24,
"201": 96
},
"wall_seconds": 24.63,
"successful_rps": 3.9,
"error_rate": 0.2,
"latency_seconds": {
"p50": 7.862,
"p95": 8.374,
"p99": 8.399
},
"sha256_in_responses_ok": true,
"download_sha256_ok": true,
"replicas": {
"bb4424f819bb": {
"idle_rss_mib": 104,
"sampled_peak_rss_mib": 156,
"vm_hwm_mib": 156,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 60
},
"0900a35b199d": {
"idle_rss_mib": 102,
"sampled_peak_rss_mib": 150,
"vm_hwm_mib": 150,
"cgroup_max_usage_with_page_cache_mib": 256,
"oom_killed": "false",
"temp_dirs_left": 0,
"served": 60
}
},
"docker_stats": {
"messenger-lab4-tools-run-3ba5514e0d22": {
"max_cpu_percent": 15.56,
"last_mem": "122.4MiB"
},
"messenger-lab4-lb-1": {
"max_cpu_percent": 26.52,
"last_mem": "13.5MiB"
},
"messenger-lab4-api-1": {
"max_cpu_percent": 52.45,
"last_mem": "98.35MiB"
},
"messenger-lab4-api-2": {
"max_cpu_percent": 52.64,
"last_mem": "91.67MiB"
},
"messenger-lab4-reconciler-1": {
"max_cpu_percent": 0,
"last_mem": "30.15MiB"
},
"messenger-lab4-redis-1": {
"max_cpu_percent": 3.46,
"last_mem": "8.105MiB"
},
"messenger-lab4-postgres-1": {
"max_cpu_percent": 7.07,
"last_mem": "65.05MiB"
},
"messenger-lab4-s3-1": {
"max_cpu_percent": 49.36,
"last_mem": "248.1MiB"
}
}
}
]
}