forked from mtusi2026/mtusi2026lab4
Compare commits
6
Commits
b32ce9a75d
...
abba248020
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abba248020 | ||
|
|
66c44aa0f3 | ||
|
|
9caa0313be | ||
|
|
4b53e03fd6 | ||
|
|
a06471a6c6 | ||
|
|
4badd5a7b9 |
+9
-2
@@ -33,7 +33,7 @@ IDEMPOTENCY_TTL_SECONDS=86400
|
||||
# Стенд (compose.yaml и scripts/):
|
||||
API_REPLICAS=2
|
||||
API_CPUS_PER_REPLICA=1.5
|
||||
API_MEMORY_PER_REPLICA=768m
|
||||
API_MEMORY_PER_REPLICA=1024m
|
||||
PG_CPUS=1.5
|
||||
PG_MEMORY=512m
|
||||
REDIS_CPUS=0.25
|
||||
@@ -68,7 +68,14 @@ S3_CONNECT_TIMEOUT_MS=1000
|
||||
S3_REQUEST_TIMEOUT_MS=15000
|
||||
MAX_UPLOAD_BYTES=10485760
|
||||
MAX_IMAGE_PIXELS=40000000
|
||||
UPLOAD_MAX_IN_FLIGHT=32
|
||||
# Каждая загрузка держит копию файла (≤ MAX_UPLOAD_BYTES) до полного декода;
|
||||
# худший декод (40 Мп RGBA16 interlaced PNG) ≈ 340 MiB. Граница памяти реплики:
|
||||
# базовый RSS (~250 MiB) + UPLOAD_MAX_IN_FLIGHT × 10 MiB + IMAGE_DECODE_MAX_CONCURRENT × 340 MiB
|
||||
# = 250 + 160 + 340 ≈ 750 MiB при API_MEMORY_PER_REPLICA=1024m.
|
||||
UPLOAD_MAX_IN_FLIGHT=16
|
||||
# Не больше стольких одновременных загрузок одного пользователя на реплику.
|
||||
UPLOAD_MAX_IN_FLIGHT_PER_USER=4
|
||||
IMAGE_DECODE_MAX_CONCURRENT=1
|
||||
DIRECT_UPLOAD_MAX_PENDING_PER_USER=10
|
||||
# UPLOAD_TIMEOUT_MS, DIRECT_UPLOAD_URL_TTL_SECONDS, ATTACHMENT_SWEEP_GRACE_SECONDS,
|
||||
# ATTACHMENT_SWEEP_INTERVAL_MS задаются в compose.yaml (environment) с умолчаниями
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
Что реализовано и что перенесено:
|
||||
- Перенесено из lab3: NestJS 12 + Fastify 5, PostgreSQL, Redis-сессии и кэш, идемпотентность POST сообщений, HAProxy + 2 API-реплики, хуки `restart.sh` / `stop-one.sh` / `start-replica.sh`.
|
||||
- Стенд: MinIO (образ закреплён по digest), идемпотентный bootstrap `s3-init` (приватный bucket, политика `messenger-api` только на `attachments/*`, отдельный пользователь API), секреты через Docker secrets (`make init-env`), консоль MinIO отключена, порт 9001 не публикуется, корневая ФС API `read_only`.
|
||||
- Proxy upload PNG/JPEG: потоковая передача в S3 без буферизации тела; `ImageInspector` проверяет сигнатуру, структуру и CRC, лимиты 10 MiB / 40 млн пикселей применяются до чтения; при отказе — компенсация; 201 ready только после PUT в S3 и `markReady`.
|
||||
- Proxy upload PNG/JPEG: потоковая передача в S3; два слоя проверки — `ImageInspector` (сигнатура, структура, CRC, тип, лимит 40 млн пикселей до любого декода) и полный декод libvips/sharp (`failOn: 'warning'`, один декод на реплику, принимаются снимки до 40 Мп включая RGBA16), последний кусок уходит в S3 только после обоих; тип проверяется после аутентификации (401 раньше 415); лимит 10 MiB до чтения; 201 ready только после PUT в S3 и `markReady`.
|
||||
- Компенсация не теряет оригинал: сначала захват строки `pending → deleting`, объект удаляется только после успешного захвата; если COMMIT `ready` прошёл, а ответ потерян — объект сохраняется, клиент получает 201; при недоступной БД ничего не удаляется (уборщик).
|
||||
- Download через API с проверкой членства в чате; `attachment_ids` в сообщениях (атомарно в `CREATE_ONCE_SQL`, составные FK запрещают вложение другого чата); уборщик незавершённых загрузок с grace period; CLI sweep.
|
||||
- Недоступность S3 — деградация: вложения отвечают 503, текст, история и readiness работают.
|
||||
- Трек 1: `POST /chats/{id}/attachments/direct-uploads` → presigned PUT (подписаны content-type, content-length, x-amz-checksum-sha256) → `POST /attachments/{id}/complete` (HEAD + чтение заголовка изображения, статус `rejected` для отклонённых); расширение — `contracts/extensions.openapi.json`, обязательный proxy endpoint не изменён.
|
||||
- Трек 1: `POST /chats/{id}/attachments/direct-uploads` → presigned PUT (подписаны content-type, content-length, x-amz-checksum-sha256) → `POST /attachments/{id}/complete` (HEAD размера и checksum, полное чтение и декод объекта с дедлайном, статус `rejected` для отклонённых, параллельные complete идемпотентны); расширение — `contracts/extensions.openapi.json`, обязательный proxy endpoint не изменён.
|
||||
|
||||
Команды запуска из чистого clone:
|
||||
```sh
|
||||
@@ -25,17 +26,17 @@ make bench
|
||||
|
||||
Результаты проверок и ссылка на REPORT.md: [REPORT.md](../REPORT.md); вывод — `evidence/lab4/`.
|
||||
- `make check` — PASS; `make test` — PASS (`make-check.txt`, `make-test.txt`).
|
||||
- `make test-e2e`: 34 passed, 8 skipped (opt-in); unit-тесты: 36 passed.
|
||||
- `make test-dependencies`: 6 passed (Redis, PG, S3 down, PG down между PUT и ready).
|
||||
- `make test-e2e`: 44 passed, 9 skipped (opt-in); unit-тесты: 48 passed (регрессия потерянного COMMIT, декодер, лимиты слотов).
|
||||
- `make test-dependencies`: 7 passed (Redis, PG, S3 остановлен, S3 завис — 503 за ≤ 20 с, PG down между PUT и ready — объект сохранён до уборки); короткий TTL: 10 passed.
|
||||
- Persistence и failover — PASS; download после остановки каждой из реплик возвращает тот же sha256.
|
||||
- `make s3-security`: 9 PASS; `make consistency`: orphans 0, missing 0; спайк подписи: чужие байты → S3 400/403.
|
||||
- Эксперимент: proxy 10×9.5 MiB — пик Δrss 15.7 MiB, 20×9.5 MiB — 16.5 MiB; direct — трафик API ≈0.07 MiB на загрузку при любом размере, proxy ≈2×size.
|
||||
- Эксперимент: proxy 10×9.5 MiB — медиана пика Δrss 20 MiB, 20×9.5 MiB — 43 MiB; худший случай (32 клиента, 40 Мп RGBA16 Adam7, 10 MiB) — пик RSS 791 из 1024 MiB без OOM, все отказы — 429; худший декод в контейнере — 338 MiB; direct снимает с API исходящий трафик (≈0.01 MiB против size), входящий одинаков (≈size), т.к. complete проверяет объект целиком.
|
||||
|
||||
Ограничения / известные ошибки:
|
||||
- Прямой путь проверяет только заголовок изображения (структура хвоста файла >64 KiB не проверяется; байты зафиксированы подписанным SHA-256).
|
||||
- Полная проверка стоит памяти (копия тела ≤10 MiB + декод до 338 MiB, поэтому декод по одному и 1 GiB на реплику) и времени под потоком тяжёлых изображений; изменённый байт в сжатых данных baseline JPEG может пройти (у JPEG нет контрольной суммы); direct не экономит входящий трафик API — нужна асинхронная проверка рядом с хранилищем.
|
||||
- Потерянный ответ COMMIT проверен unit-тестом с моком (в стенде нет прокси, рвущего соединение после COMMIT).
|
||||
- Не атомарна проверка лимита незавершённых заявок прямой загрузки (гонка параллельных init).
|
||||
- Порядок компенсации proxy (сначала объект, потом строка): при ложном обрыве после commit возможна потеря объекта.
|
||||
- Тайм-аут загрузки обрывает сокет вместо ответа 400.
|
||||
- Тайм-аут загрузки обрывает сокет вместо ответа 400; лимит на пользователя не защищает от медленных клиентов с многих аккаунтов.
|
||||
- Нет автоматического reconciler'а orphan-объектов (только `make consistency`), нет TLS (до lab7), нет вариантов/WebP/delete-API.
|
||||
- Репозиторий MinIO, вероятно, архивирован (в этой работе не перепроверялось).
|
||||
|
||||
|
||||
@@ -36,7 +36,11 @@ make test-persistence ACTION_SCRIPT=scripts/restart.sh
|
||||
make test-failover ACTION_SCRIPT=scripts/stop-one.sh && scripts/start-replica.sh
|
||||
```
|
||||
|
||||
Действия оператора: только `make init-env` (секреты создаются локально в `secrets/`, каталог в
|
||||
Действия оператора: только `make init-env`. Он не перезаписывает существующий `.env`: при обновлении с
|
||||
предыдущей версии сверьте несекретные значения с `.env.example` (команда не печатает секреты):
|
||||
`diff <(grep -vE '^(POSTGRES_PASSWORD|DATABASE_URL|METRICS_TOKEN)=' .env.example) <(grep -vE '^(POSTGRES_PASSWORD|DATABASE_URL|METRICS_TOKEN)=' .env)`
|
||||
— иначе останутся старые лимиты (так один из прогонов этой работы шёл с `UPLOAD_MAX_IN_FLIGHT=32`).
|
||||
Секреты создаются локально в `secrets/` (каталог в
|
||||
`.gitignore`; `secrets/` и `.env` нельзя коммитить). Остановка с сохранением данных — `make stand-down`
|
||||
(тома `postgres-data`, `redis-data`, `s3-data` сохраняются). **Намеренное удаление учебных данных:**
|
||||
`docker compose --env-file .env down -v` (удаляет все три тома, включая загруженные файлы; следующий
|
||||
@@ -61,8 +65,9 @@ ATTACHMENT_SWEEP_INTERVAL_MS=1000 docker compose --env-file .env up -d --no-deps
|
||||
хранится для отображения и никогда не попадает в ключ или путь. На API нет локального файла
|
||||
оригинала: корневая ФС контейнера `read_only: true`, `/tmp` — tmpfs 16 MiB
|
||||
(`evidence/lab4/readonly-api.txt`).
|
||||
- **Жизненный цикл строки:** `pending` (байты не подтверждены) → `ready` (видна участникам чата) или
|
||||
`deleting` (захвачена уборщиком) → строка удалена. Публично существуют только `ready`.
|
||||
- **Жизненный цикл строки:** `pending` (байты не подтверждены) → `ready` (видна участникам чата),
|
||||
либо `deleting` (захвачена компенсацией или уборщиком) → строка удалена, либо (direct) `rejected`
|
||||
(проверка не пройдена, URL ещё может действовать) → уборщик. Публично существуют только `ready`.
|
||||
Инварианты в БД: составные FK `(chat_id, owner_id) → chat_members` и
|
||||
`(attachment_id, chat_id) → attachments(id, chat_id)` делают «вложение другого чата» невозможным;
|
||||
`CHECK` требует size/sha256/width/height у `ready` и `expires_at` у незавершённых; FK
|
||||
@@ -71,29 +76,76 @@ ATTACHMENT_SWEEP_INTERVAL_MS=1000 docker compose --env-file .env up -d --no-deps
|
||||
- **Когда честно 201 (proxy):** только после того, как S3 принял весь объект (`PutObject` завершён) и
|
||||
`UPDATE … SET status='ready' WHERE status='pending'` изменил строку. Этот `UPDATE` проигрывает
|
||||
захвату уборщиком атомарно (строка уже `deleting` → 503, а не фальшивый 201).
|
||||
- **S3 PUT прошёл, а COMMIT нет:** строка остаётся `pending`, объект есть. Запрос сначала пытается
|
||||
компенсировать (`DeleteObject`, затем `DELETE … WHERE status='pending'`); если не удалось
|
||||
(PG/S3 недоступны) — счётчик `attachments.compensation_deferred`, строка остаётся и через
|
||||
`expires_at + ATTACHMENT_SWEEP_GRACE_SECONDS` её убирает уборщик (удаляет объект, затем строку).
|
||||
Сверка: `make consistency`. Наблюдение — `dependency-failures` «compensates the S3 write when
|
||||
PostgreSQL fails before ready».
|
||||
- **Потоковая обработка (proxy):** тело читается как поток и сразу идёт в S3 с заранее известным
|
||||
`Content-Length` (≤ 10 MiB, иначе 413 до чтения). Параллельно `ImageInspector` (байтовый автомат
|
||||
PNG/JPEG, без декодирования и без буферизации тела) проверяет сигнатуру, структуру, CRC чанков PNG
|
||||
и число пикселей (≤ 40 млн, 413). До появления заголовка (≤ 1 MiB) нет ни строки, ни объекта.
|
||||
Последний кусок отдаётся в S3 только после `inspector.finish()` — S3 не получит полное тело
|
||||
невалидного файла и не зафиксирует объект. Ограничители: `UPLOAD_MAX_IN_FLIGHT` (429 +
|
||||
`Retry-After`), `UPLOAD_TIMEOUT_MS` (жёсткий дедлайн запроса), тайм-ауты S3-клиента.
|
||||
Fastify `bodyLimit` к `image/*` не применяется: контент-парсеры отдают сырой поток (для
|
||||
`text/plain` встроенный буферизующий парсер заменён — иначе бинарное тело давало 400).
|
||||
- **S3 PUT прошёл, а COMMIT нет — и как не потерять оригинал.** Ошибка `markReady` на стороне API
|
||||
не означает, что COMMIT не прошёл: соединение может оборваться *после* фиксации, и тогда строка
|
||||
уже `ready`. Поэтому компенсация сначала **захватывает строку**
|
||||
(`UPDATE … SET status='deleting' WHERE id=$1 AND status='pending'`) и удаляет объект **только после
|
||||
успешного захвата**, затем удаляет строку:
|
||||
- захват не сработал (строка уже не `pending`) — объект не трогается; если строка `ready`, API
|
||||
отвечает 201 с этим вложением (`attachments.upload.recovered`): COMMIT был, это правда;
|
||||
- PostgreSQL недоступен — ничего не удаляется (`attachments.compensation_deferred`): по строке
|
||||
`pending` объект найдёт уборщик через `expires_at + ATTACHMENT_SWEEP_GRACE_SECONDS`, и он тоже
|
||||
сначала захватывает строку;
|
||||
- S3 недоступен после захвата — строка остаётся `deleting` и перезахватывается уборщиком через минуту;
|
||||
- запрос оборван (таймаут) уже после того, как последний байт ушёл в S3, — S3 может зафиксировать PUT
|
||||
*после* нашего DELETE; поэтому строка остаётся `deleting`, и уборщик через минуту удаляет ключ ещё
|
||||
раз и только потом строку. Если же последний байт не ушёл (обрыв клиента, отказ проверки), S3 не
|
||||
может зафиксировать объект с неполным телом, и строка удаляется сразу.
|
||||
|
||||
Так «объект без строки» не возникает ни в одном из этих сценариев, а `ready` без объекта — только при внешнем
|
||||
удалении из bucket. Первая версия удаляла объект до строки и теряла оригинал при потерянном ответе
|
||||
COMMIT; регрессия — `attachments.service.spec.ts` (unit, мок «COMMIT прошёл, ответ потерян»), а
|
||||
fault-тест `dependency-failures` «keeps the object while PostgreSQL is down before ready» проверяет,
|
||||
что при остановленном PG объект сохраняется до уборки.
|
||||
- **Proxy: потоковая передача + полная проверка изображения.** Тело читается как поток и сразу идёт
|
||||
в S3 с заранее известным `Content-Length` (≤ 10 MiB, иначе 413 до чтения). Проверка в два слоя:
|
||||
1. `ImageInspector` — байтовый автомат PNG/JPEG без буферизации: сигнатура, структура, CRC чанков
|
||||
PNG, тип по содержимому и число пикселей (≤ 40 млн → 413) по IHDR/SOF. До появления заголовка
|
||||
нет ни строки, ни объекта (фаза заголовка ограничена `Content-Length` ≤ 10 MiB: у JPEG до SOF
|
||||
бывают мегабайты APPn-метаданных); pixel bomb отвергается до любого декодирования.
|
||||
2. `ImageDecoder` — полный декод libvips (sharp 0.35, `failOn: 'warning'`, `limitInputPixels`),
|
||||
стоком служит уменьшение до 64 px: оно читает все сжатые данные, но держит в памяти меньше
|
||||
полноразмерного конвейера (вердикты по 14 видам корректных и битых файлов совпадают с `stats()`,
|
||||
худший пик памяти — 339 против 329–232 MiB у других стоков… см. `decode-memory.txt`). Структуры и
|
||||
CRC недостаточно: PNG с мусорным zlib-потоком (верные CRC) и JPEG без данных скана проходят первый
|
||||
слой — их ловит только декод. Ошибка самого сервера (нет места, нет памяти) не выдаётся за 415:
|
||||
она логируется и даёт 500. `VIPS_DISC_THRESHOLD=1g` не даёт libvips уносить большие изображения во
|
||||
временный файл: `/tmp` у API — tmpfs 16 MiB, и до этой настройки снимки ≈40 Мп получали 415.
|
||||
|
||||
Последний кусок отдаётся в S3 только после обоих слоёв — S3 не получает полное тело невалидного
|
||||
файла и не фиксирует объект. Цена — память: копия тела (≤ 10 MiB, libvips не принимает поток) и
|
||||
декод. Худший допустимый вход — 40 Мп RGBA 16 bit с Adam7-чередованием (декодер обязан держать всё
|
||||
изображение): **338 MiB** на декод в контейнере (`decode-memory.txt`; baseline JPEG 4.5 MiB,
|
||||
progressive JPEG 118 MiB, CMYK 7.5 MiB, RGBA16 без чередования 67 MiB). Отсюда настройки:
|
||||
`IMAGE_DECODE_MAX_CONCURRENT=1` (остальные ждут в очереди; ожидающий запрос, у которого истёк
|
||||
`UPLOAD_TIMEOUT_MS`, покидает очередь вместе со своим буфером) и `API_MEMORY_PER_REPLICA=1024m`.
|
||||
Граница на реплику: базовый RSS ≈250 MiB + `UPLOAD_MAX_IN_FLIGHT` 16 × 10 MiB + 1 × 340 MiB
|
||||
≈ 750 MiB. Нагрузочный прогон худшего случая (32 клиента одновременно шлют именно такой файл
|
||||
10 MiB) дал пик RSS 791 MiB из 1024 без OOM и рестартов (`bench/*-worst-c32.json`,
|
||||
`bench-oom-check.txt`). Слоты: `UPLOAD_MAX_IN_FLIGHT` на реплику и `UPLOAD_MAX_IN_FLIGHT_PER_USER`
|
||||
(4) на пользователя — медленный клиент (держит слот до `UPLOAD_TIMEOUT_MS`) не занимает слоты
|
||||
остальных; при исчерпании — 429 + `Retry-After`. Слоты общие для proxy и direct complete.
|
||||
Маршрут загрузки получает тело сырым потоком при любом `Content-Type`: хук `onRequest` помечает
|
||||
запрос, и тип проверяет сервис уже после guard (401 раньше 415, как требует contracts/README);
|
||||
Fastify `bodyLimit` к нему не применяется (лимит считает сервис), остальные маршруты используют
|
||||
штатные парсеры Fastify (`text/plain` > 1 MiB → 413 в конверте ошибки).
|
||||
- **Таймауты S3.** `S3_REQUEST_TIMEOUT_MS` (15 с) действует как жёсткий предел: `throwOnRequestTimeout`
|
||||
(без него smithy только пишет предупреждение) и `socketTimeout` на простой при чтении тела. Для PUT
|
||||
предел — `UPLOAD_TIMEOUT_MS` (сигнал отмены), чтобы медленный клиент не обрывался на 15 с.
|
||||
Проверено fault-тестом с `docker pause s3` (порт открыт, ответа нет): download → 503 быстрее 20 с,
|
||||
метаданные и readiness — 200, после `unpause` файл отдаётся.
|
||||
- **Прямая загрузка (трек 1):** `POST /api/v1/chats/{id}/attachments/direct-uploads` создаёт строку
|
||||
`pending` (`expires_at = now + TTL`) и возвращает presigned PUT. Подписаны `content-type`,
|
||||
`content-length` и `x-amz-checksum-sha256`: S3 сам отвергает тело другого размера (403
|
||||
`SignatureDoesNotMatch`) или с другим SHA-256 (400 `XAmzContentChecksumMismatch`), объект при этом
|
||||
не создаётся (`evidence/lab4/presign-spike.txt`). `POST /api/v1/attachments/{id}/complete`
|
||||
(только владелец): `HEAD` (размер + подписанный checksum), чтение заголовка изображения (первый
|
||||
диапазон 64 KiB, при необходимости расширяется до 1 MiB; объект, целиком попавший в диапазон,
|
||||
проверяется до конца, включая CRC/EOI), сверка типа и пикселей, `markReady`. Несоответствие
|
||||
(только владелец): `HEAD` (размер + подписанный checksum), затем объект **читается целиком** и
|
||||
проходит те же два слоя, что и proxy (инспектор + полный декод), сверка типа и пикселей, `markReady`.
|
||||
Подписанный checksum доказывает лишь, что байты те, что заявил клиент, а не что это изображение:
|
||||
первая версия читала только начало и принимала усечённый PNG и файл, повреждённый после первых
|
||||
64 KiB (оба с верным checksum). Цена — входящий трафик API = size на `complete` (см. H2). Чтение и
|
||||
декод ограничены `UPLOAD_TIMEOUT_MS`, обрыв чтения из S3 → 503. Параллельные `complete` одной заявки
|
||||
все получают 200 (проигравший `markReady` перечитывает строку). Несоответствие
|
||||
(размер/checksum/тип/пиксели) → 409/413/415, объект удаляется, а строка получает статус
|
||||
`rejected` и сохраняет `expires_at`: подписанный URL ещё может быть использован, и повторный PUT
|
||||
оставил бы объект без строки; уборщик удаляет `rejected` после `expires_at` + grace, пока же строка
|
||||
@@ -137,7 +189,11 @@ ATTACHMENT_SWEEP_INTERVAL_MS=1000 docker compose --env-file .env up -d --no-deps
|
||||
| `S3_ACCESS_KEY_ID_FILE`, `S3_SECRET_ACCESS_KEY_FILE` | `resolveSecret` → `S3_ACCESS_KEY_ID`/`S3_SECRET_ACCESS_KEY` | API-credentials из Docker secrets |
|
||||
| `S3_CONNECT_TIMEOUT_MS`, `S3_REQUEST_TIMEOUT_MS` | `NodeHttpHandler` | тайм-ауты S3-клиента |
|
||||
| `MAX_UPLOAD_BYTES`, `MAX_IMAGE_PIXELS` | `AttachmentsService`, `DirectUploadsService` | 10 MiB, 40 млн пикселей |
|
||||
| `UPLOAD_TIMEOUT_MS`, `UPLOAD_MAX_IN_FLIGHT` | `AttachmentsService` | дедлайн запроса и число одновременных proxy-загрузок на реплику |
|
||||
| `UPLOAD_TIMEOUT_MS` | `AttachmentsService`, `DirectUploadsService` | дедлайн загрузки и `complete` (25 с), включая ожидание декода |
|
||||
| `UPLOAD_MAX_IN_FLIGHT`, `UPLOAD_MAX_IN_FLIGHT_PER_USER` | `UploadSlots` | одновременные proxy-загрузки и direct complete на реплику (16) и на пользователя (4) |
|
||||
| `IMAGE_DECODE_MAX_CONCURRENT` | `ImageDecoder` | одновременные полные декоды на реплику (1; худший декод ≈340 MiB) |
|
||||
| `VIPS_DISC_THRESHOLD` | `compose.yaml` → libvips | 1g: декод в памяти, не во временном файле в tmpfs `/tmp` |
|
||||
| `API_MEMORY_PER_REPLICA` | `compose.yaml` | лимит памяти реплики, 1024m (бюджет ≈750 MiB, см. выше) |
|
||||
| `ATTACHMENT_SWEEP_INTERVAL_MS`, `ATTACHMENT_SWEEP_GRACE_SECONDS` | `AttachmentSweeper`, CLI | период фонового прохода (0 = выкл.) и grace после `expires_at` |
|
||||
| `DIRECT_UPLOAD_URL_TTL_SECONDS`, `DIRECT_UPLOAD_MAX_PENDING_PER_USER` | `DirectUploadsService` | TTL подписи; лимит незавершённых заявок |
|
||||
| `S3_PUBLIC_BIND`, `S3_PUBLIC_PORT`, `S3_CPUS`, `S3_MEMORY` | `compose.yaml` (сервис `s3`) | публикация порта на loopback; лимиты контейнера |
|
||||
@@ -148,10 +204,11 @@ ATTACHMENT_SWEEP_INTERVAL_MS=1000 docker compose --env-file .env up -d --no-deps
|
||||
### Компенсация, сверка, очистка (grace period)
|
||||
|
||||
`expires_at` у proxy = старт + `UPLOAD_TIMEOUT_MS` (жёсткий дедлайн запроса), у direct = выдача URL + TTL.
|
||||
Уборщик берёт строку только через `ATTACHMENT_SWEEP_GRACE_SECONDS` (900 с по умолчанию) после этого:
|
||||
Уборщик берёт строки `pending`/`rejected` только через `ATTACHMENT_SWEEP_GRACE_SECONDS` (900 с по умолчанию) после этого:
|
||||
живую загрузку он не застанет, а `markReady … WHERE status='pending'` проигрывает захвату
|
||||
(`pending → deleting`, `FOR UPDATE SKIP LOCKED`, реплики не мешают друг другу). Застрявшая в
|
||||
`deleting` строка (упавший уборщик) перезахватывается через минуту. Ручной запуск:
|
||||
`deleting` строка (упавший уборщик или компенсация, которой не ответил S3) перезахватывается через
|
||||
минуту — живая компенсация за это время либо завершается, либо уже не идёт. Ручной запуск:
|
||||
`docker compose exec api node dist/attachments/attachments-sweep.cli.js`. Сверка в обе стороны (только
|
||||
чтение): `make consistency` — `orphans` (объект без строки) и `missing` (`ready` без объекта).
|
||||
Отсутствующий объект у `ready`-строки при download — это потеря данных: 500 и счётчик
|
||||
@@ -165,88 +222,112 @@ ATTACHMENT_SWEEP_INTERVAL_MS=1000 docker compose --env-file .env up -d --no-deps
|
||||
| --- | --- | --- | --- |
|
||||
| Публичный smoke | `make test` | `PASS: lab4 public API scenario` (upload 201 ready, сообщение с `''` и `attachment_ids`, download bob = байты, eve 404) | `make-test.txt` |
|
||||
| Контракт offline | `make check` | PASS, `contracts/extensions.openapi.json` — валидный JSON | `make-check.txt` |
|
||||
| 3: S3 в общем стенде, приватный bucket, метаданные в PG, байты в bucket | `make stand-up`; `docker compose ps`; `make consistency` | `s3` healthy, `s3-init` завершён с 0; bucket приватный (`mc anonymous set none`); число объектов в bucket = числу `ready`-строк (2577 после серий `make bench` и e2e; ещё 33 `pending` без объектов и 6 `rejected` ждут истечения + grace), orphans/missing = 0 | `bootstrap-rerun.txt`, `consistency.txt` |
|
||||
| 3: S3 в общем стенде, приватный bucket, метаданные в PG, байты в bucket | `make stand-up`; `docker compose ps`; `make consistency` | `s3` healthy, `s3-init` завершён с 0; bucket приватный (`mc anonymous set none`); после серий `make bench`, e2e и fault-тестов: 5066 объектов на 5065 `ready` + 15 незавершённых строк (`pending`/`rejected`, ждут истечения + grace; одна из них — с объектом), orphans/missing = 0 | `bootstrap-rerun.txt`, `consistency.txt` |
|
||||
| 3: 201 ready, побайтный download, `attachment_ids` | `make test-e2e` (`attachments.e2e-spec.ts`) | sha256 в ответе = sha256 файла; content = байты, `nosniff`, `Content-Length` | `make-test-e2e.txt` |
|
||||
| 3: PNG/JPEG ≤10 MiB и ≤40 млн px; MIME по содержимому; опасные filename; лимиты до чтения | e2e: 10485760 → 201, 10485761 → 413, pixel bomb 8000×5001 → 413 сразу после IHDR, PNG как `image/jpeg` → 415, `a/b.png`, `\u202E`, NUL, 256 символов → 400, 255×😀 → 201 | кейсы перечислены в `app/test/attachments.e2e-spec.ts` (в evidence — итог: 34 passed, 8 skipped opt-in); raw image/text тело на JSON-маршрутах → 415/400, не 500 | `make-test-e2e.txt`, `unit-tests.txt` (`image-inspector.spec.ts`) |
|
||||
| 3: PNG/JPEG ≤10 MiB и ≤40 млн px; MIME по содержимому; опасные filename; лимиты до чтения | e2e: снимок 7728×5152 (39.8 Мп) baseline и progressive JPEG → 201, PNG 8000×5000 RGBA16 → 201, JPEG с 1.3 MB метаданных до SOF → 201; 10485760 → 201, 10485761 → 413, pixel bomb 8000×5001 → 413 сразу после IHDR, PNG как `image/jpeg` → 415, `a/b.png`, `\u202E`, NUL, 256 символов → 400, 255×😀 → 201 | кейсы перечислены в `app/test/attachments.e2e-spec.ts` (в evidence — итог: 44 passed, 9 skipped opt-in); raw image/text тело на JSON-маршрутах → 415/400, `text/plain` > 1 MiB → 413, без токена с `application/zip` → 401 (не 415) | `make-test-e2e.txt`, `unit-tests.txt` (48 passed: `image-inspector.spec.ts`, `image-decoder.spec.ts`, `attachments.service.spec.ts`, `upload-slots.spec.ts`) |
|
||||
| 3: другая реплика отдаёт файл после остановки загрузившей; restart сохраняет данные | `scripts/stop-one.sh` (обе реплики по очереди), `make test-failover`; `make test-persistence ACTION_SCRIPT=scripts/restart.sh` | failover: 0 неуспешных попыток, восстановление ≈3.3 с; download с тем же sha256 после остановки api-1 и api-2; persistence: `StartedAt` у postgres, redis, s3, api×2, haproxy изменился, данные и сессия сохранены | `failover.txt`, `failover-attachment.txt`, `persistence.txt` |
|
||||
| 3: на API нет локального файла оригинала | `touch` в корне контейнера | `Read-only file system` | `readonly-api.txt` |
|
||||
| 4: тесты: большой файл, повреждённое изображение, подмена MIME, чужое `attachment_id`, вложение другого чата, нет 500 | `make test-e2e` | 413; усечённый PNG, флип байта (CRC), сигнатура+мусор, пустое тело → 415; подмена MIME → 415; чужое/неизвестное/незавершённое → 404; вложение чата eve в чате alice → 404 | `make-test-e2e.txt` |
|
||||
| 4: прерывание загрузки и отказ между S3/БД не оставляют вечных объектов | e2e «client drops the connection»; `make test-dependencies` | обрыв клиента → строк 0 за ≤10 с; S3 down → одна `pending`, после старта и sweep — 0; PG down между PUT и ready → 503, объекта в S3 нет, `pending` убрана sweep; затем `orphans: 0, missing: 0` | `make-test-e2e.txt`, `make-test-dependencies.txt`, `consistency.txt` |
|
||||
| 4: лимиты, таймауты, потоковая обработка; эксперимент ≥10 загрузок с пиком памяти | `make bench` (proxy, C=10 и C=20, 9.5 MiB) | max Δrss реплики 15.7 MiB при C=10 и 16.5 MiB при C=20 против 95/190 MiB тел в полёте — см. «Эксперименты» | `summary.md`, `bench/*.json` |
|
||||
| 4: тесты: большой файл, повреждённое изображение, подмена MIME, чужое `attachment_id`, вложение другого чата, нет 500 | `make test-e2e` | 413; усечённый PNG, флип байта (CRC), сигнатура+мусор, пустое тело, PNG с мусорным zlib-потоком при верных CRC, JPEG (baseline и прогрессивный) без данных скана → 415; подмена MIME → 415; чужое/неизвестное/незавершённое → 404; вложение чата eve в чате alice → 404 | `make-test-e2e.txt` |
|
||||
| 4: прерывание загрузки и отказ между S3/БД не оставляют вечных объектов | e2e «client drops the connection»; `make test-dependencies` | обрыв клиента → строк 0 за ≤10 с; S3 down → строка в `deleting`, после старта перезахвачена и убрана sweep; PG down между PUT и ready → 503, объект сохранён до уборки (строка `pending` его учитывает), после sweep нет ни объекта, ни строки; потерянный ответ COMMIT → объект не удаляется, 201 (unit `attachments.service.spec.ts`); затем `orphans: 0, missing: 0` | `make-test-e2e.txt`, `make-test-dependencies.txt`, `consistency.txt` |
|
||||
| 4: лимиты, таймауты, потоковая обработка; эксперимент ≥10 загрузок с пиком памяти | `make bench`: proxy 9.5 MiB при C=10 и C=20; худший случай — 32 клиента с 40 Мп RGBA16 Adam7 10 MiB; `docker pause s3` в `make test-dependencies` | типичные: Δrss 20 / 43 MiB; худший: пик RSS 791 из 1024 MiB, без OOM, избыток — 429; граница по конфигурации ≈750 MiB; худший декод в контейнере 338 MiB; зависший S3 → 503 за ≤ 20 с | `summary.md`, `bench/*.json`, `bench-oom-check.txt`, `decode-memory.txt`, `make-test-dependencies.txt` |
|
||||
| 4: идемпотентный bootstrap; отдельные ограниченные credentials; консоль закрыта; private bucket вне API | `docker compose run s3-init` дважды; `make s3-security` | повтор → `bootstrap ok`; анонимные GET/list/PUT → 403; API-credentials не создают bucket, не вызывают admin, не пишут вне `attachments/`, читают `attachments/*`; порт 9001 не опубликован и не отвечает | `bootstrap-rerun.txt`, `s3-security.txt` |
|
||||
| 5 / трек 1: presigned flow (короткая подпись, уникальный ключ, принадлежность, размер/checksum на complete, незавершённые) | `direct-upload.e2e-spec.ts`; спайк подписи | init → PUT мимо API → complete → metadata/content → сообщение; чужой/посторонний complete → 404; подмена байта → S3 400, затем complete 409; JPEG под видом PNG → 415, затем 404; pixel bomb → 413; 11-я заявка → 429 + `Retry-After` | `make-test-e2e.txt`, `presign-spike.txt` |
|
||||
| 5 / трек 1: presigned flow (короткая подпись, уникальный ключ, принадлежность, размер/checksum на complete, незавершённые) | `direct-upload.e2e-spec.ts`; спайк подписи | init → PUT мимо API → complete → metadata/content → сообщение; чужой/посторонний complete → 404; 4 параллельных complete → 200 × 4; усечённый PNG и PNG, повреждённый после первых 64 KiB (оба с верным checksum) → 415, затем 404; подмена байта → S3 400, затем complete 409; JPEG под видом PNG → 415, затем 404; pixel bomb → 413; 11-я заявка → 429 + `Retry-After` | `make-test-e2e.txt`, `presign-spike.txt` |
|
||||
| 5 / трек 1: истёкший URL и уборка | `E2E_DIRECT_TTL_SHORT=1` на стенде с TTL 5 с | PUT после `expires_at` → 403, строка убрана уборщиком, complete → 404 | `direct-ttl-short.txt` |
|
||||
| 5 / трек 1: сравнение трафика и RAM API на ≥2 размерах | `make bench` (0.125, 1, 9.5 MiB) | см. таблицу ниже | `summary.md`, `bench/*.json` |
|
||||
|
||||
Оговорка по hook'ам: `make test-persistence` и `make test-failover` подтверждают сохранность данных и
|
||||
сессии; какие процессы перезапущены, видно по `StartedAt` до/после (`persistence.txt`).
|
||||
`scripts/stop-one.sh` останавливает только реплику, обслужившую сессию теста (в трёх прогонах
|
||||
`scripts/stop-one.sh` останавливает только реплику, обслужившую сессию теста (в обоих прогонах
|
||||
`make test-failover` это была одна и та же реплика), поэтому остановка обеих реплик показана отдельно
|
||||
`failover-attachment.txt`.
|
||||
`failover-attachment.txt`. Persistence, failover, бенчмарк, безопасность и сверка перезапущены на
|
||||
коммите `9caa031` (код приложения тот же, что в `4b53e03`); unit, e2e, отказы и короткий TTL — на `4b53e03`.
|
||||
|
||||
## Эксперименты и отказы
|
||||
|
||||
**Методика.** Хост: 8 логических CPU, 16 GiB RAM, один Docker-хост. Лимиты: API 1.5 CPU / 768 MiB на
|
||||
реплику (2 реплики), MinIO 1 CPU / 512 MiB, PG 1.5 CPU / 512 MiB. Версии — см. «Запуск». Нагрузка:
|
||||
`scripts/lab4/attachments_bench.py`, closed-loop: C потоков × 5 загрузок несжимаемых PNG
|
||||
(`noise_png`, разные seed), R = 3 повтора; один прогрев на конфигурацию (2 × число реплик загрузок,
|
||||
не измеряется), перед каждым повтором — `POST /internal/metrics/reset` на каждой реплике. Трафик API — дельта `eth0` rx/tx из `/proc/net/dev`
|
||||
контейнера; RAM — пик `process.memoryUsage().rss` с шагом 50 мс минус RSS в момент reset (Δrss);
|
||||
в таблицу идёт медиана по повторам, для Δrss — максимум по репликам. Команда: `make bench`
|
||||
(`scripts/lab4/run_matrix.sh`); raw — `evidence/lab4/bench/*.json` (без токенов и URL).
|
||||
**Методика.** Хост: 8 логических CPU, 16 GiB RAM, один Docker-хост. Лимиты: API 1.5 CPU / 1024 MiB на
|
||||
реплику (2 реплики), MinIO 1 CPU / 512 MiB, PG 1.5 CPU / 512 MiB; `UPLOAD_MAX_IN_FLIGHT=16`,
|
||||
`UPLOAD_MAX_IN_FLIGHT_PER_USER=4`, `IMAGE_DECODE_MAX_CONCURRENT=1`. Версии — см. «Запуск». Нагрузка:
|
||||
`scripts/lab4/attachments_bench.py`, closed-loop: C потоков (у каждого свой пользователь и чат) × K
|
||||
загрузок, R = 3 повтора; один прогрев на конфигурацию (2 × число реплик загрузок, не измеряется), перед
|
||||
каждым повтором — `POST /internal/metrics/reset` на каждой реплике. Два вида входа:
|
||||
1. **типичный** — несжимаемые PNG ширины 1024 (`noise_png`, разные seed) 0.125 / 1 / 9.5 MiB, K = 5:
|
||||
нагружают сеть и S3, декод у них дешёвый (≈15 мс на 9.5 MiB);
|
||||
2. **худший для памяти** — 40 Мп RGBA 16 bit, Adam7, дополненный до 10 MiB (`pngkit.py`), C = 32, K = 2:
|
||||
каждый запрос требует максимального декода (≈810 мс, 338 MiB), а C = 32 упирается в
|
||||
`UPLOAD_MAX_IN_FLIGHT` обеих реплик.
|
||||
|
||||
**H1 (уровень 4).** Потоковый proxy держит рост пикового RSS реплики ограниченным и почти независимым
|
||||
от размера файла: Δrss при 10 × 9.5 MiB много меньше суммарного объёма тел в полёте.
|
||||
Трафик API — дельта `eth0` rx/tx из `/proc/net/dev` контейнера; RAM — пик `process.memoryUsage().rss`
|
||||
с шагом 50 мс (Δrss — минус RSS в момент reset; peak RSS — абсолютный максимум по репликам и повторам);
|
||||
отказы классифицируются по шагу и статусу. В таблицу идут медианы по повторам. Команда: `make bench`
|
||||
(`scripts/lab4/run_matrix.sh`); raw — `evidence/lab4/bench/*.json` (без токенов и URL), коммит `9caa031`.
|
||||
|
||||
**H2 (трек 1).** Прямая загрузка снижает трафик API на загрузку с ≈2 × size (вход от клиента + выход в
|
||||
S3) до малой величины, не зависящей от размера, и не растит RSS; латентность малых файлов у direct
|
||||
выше из-за трёх round trip.
|
||||
**H1 (уровень 4).** Память реплики ограничена сверху конфигурацией — базовый RSS ≈250 MiB +
|
||||
`UPLOAD_MAX_IN_FLIGHT × 10 MiB` + `IMAGE_DECODE_MAX_CONCURRENT × 340 MiB` ≈ 750 MiB < 1024 MiB — при любом
|
||||
числе клиентов и любом допустимом изображении; избыток нагрузки получает 429, а не OOM. (Исходная
|
||||
формулировка «Δrss почти не зависит от размера файла» для текущей версии неверна по построению: ради
|
||||
полного декода API держит копию тела.)
|
||||
|
||||
Результаты (`evidence/lab4/summary.md`; 150 загрузок на строку при C=10, 300 при C=20; ошибок 0):
|
||||
**H2 (трек 1).** Прямая загрузка снимает с API передачу байтов в S3 (tx) и не требует держать соединение
|
||||
клиента на время заливки; входящий трафик API она не снижает, потому что `complete` читает объект
|
||||
целиком для проверки; латентность direct выше из-за трёх round trip и повторного чтения.
|
||||
|
||||
| mode | size, MiB | C | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | p50, ms | p95, ms |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| direct | 0.12 | 10 | 0.07 | 0.01 | 0.40 | 45 | 65 |
|
||||
| proxy | 0.12 | 10 | 0.13 | 0.13 | 3.78 | 32 | 62 |
|
||||
| direct | 1.00 | 10 | 0.07 | 0.01 | 0.75 | 75 | 137 |
|
||||
| proxy | 1.00 | 10 | 1.01 | 1.01 | 4.38 | 59 | 110 |
|
||||
| direct | 9.50 | 10 | 0.07 | 0.01 | 0.88 | 346 | 571 |
|
||||
| proxy | 9.50 | 10 | 9.52 | 9.53 | 15.70 | 239 | 394 |
|
||||
| proxy | 9.50 | 20 | 9.53 | 9.53 | 16.46 | 409 | 812 |
|
||||
Результаты (`evidence/lab4/summary.md`; 150 загрузок на строку при C=10, 300 при C=20, 192 в худшем случае):
|
||||
|
||||
| mode | size, MiB | C | ok | отказы | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | peak RSS, MiB | p50, ms | p95, ms |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
||||
| direct | 0.12 | 10 | 150/150 | — | 0.13 | 0.01 | 0.38 | 394 | 40 | 71 |
|
||||
| proxy | 0.12 | 10 | 150/150 | — | 0.13 | 0.13 | 0.00 | 447 | 26 | 46 |
|
||||
| direct | 1.00 | 10 | 150/150 | — | 1.01 | 0.01 | 0.00 | 244 | 71 | 107 |
|
||||
| proxy | 1.00 | 10 | 150/150 | — | 1.01 | 1.01 | 0.12 | 395 | 50 | 82 |
|
||||
| direct | 9.50 | 10 | 150/150 | — | 9.52 | 0.01 | 67.06 | 344 | 448 | 672 |
|
||||
| proxy | 9.50 | 10 | 150/150 | — | 9.52 | 9.53 | 20.31 | 273 | 245 | 399 |
|
||||
| proxy | 9.50 | 20 | 300/300 | — | 9.53 | 9.53 | 42.53 | 274 | 433 | 781 |
|
||||
| direct, худший | 10.00 | 32 | 167/192 | complete 429 × 25 | 9.24 | 0.01 | 366.88 | 791 | 11067 | 13423 |
|
||||
| proxy, худший | 10.00 | 32 | 190/192 | upload 429 × 2 | 10.04 | 9.90 | 356.76 | 785 | 11982 | 13068 |
|
||||
|
||||
Выводы:
|
||||
|
||||
- **H1 подтверждена с оговоркой.** При C=10 и 9.5 MiB пик Δrss — 15.7 MiB (по повторам 14.5–18.1) при
|
||||
≈95 MiB тел в полёте; при C=20 — 16.5 MiB (12.1–21.0) при ≈190 MiB: удвоение concurrency в пределах
|
||||
шума не изменило пик. Память не пропорциональна размеру файла (размер ×76: 0.12 → 9.5 MiB дал Δrss
|
||||
3.78 → 15.7 MiB, ×4.2), но и не постоянна: растёт с размером (буферы сокетов, чанки в полёте,
|
||||
аллокатор), оставаясь на порядок меньше тел в полёте. Δrss — шумная величина (между повторами одной
|
||||
конфигурации 1.9–6.3 MiB для proxy 0.12/1 MiB), поэтому разница между C=10 и C=20 не интерпретируется.
|
||||
- **H2 подтверждена.** Для proxy tx ≈ rx ≈ size (≈2 × size суммарно: вход от клиента и выход в S3).
|
||||
Для direct при любом из трёх размеров API видит ≈0.07 MiB rx (первый диапазон 64 KiB + служебные
|
||||
запросы) и ≈0.01 MiB tx, Δrss ≤ 0.9 MiB. Для размера 0.12 MiB выигрыш по rx вдвое (0.13 → 0.07),
|
||||
по tx — на порядок. Латентность direct выше (p50 45 против 32 мс, 75 против 59 мс — три запроса
|
||||
вместо одного) и на 9.5 MiB (346 против 239 мс): клиент заливает через loopback в MinIO с лимитом
|
||||
1 CPU, а не через API; причина прироста в эксперименте не выяснялась и остаётся гипотезой (вероятно,
|
||||
проверка подписи и checksum в MinIO). Первая версия `complete` читала диапазон до 1 MiB и
|
||||
останавливалась по заголовку: сокет к этому моменту уже вычитывал 110–176 KB (read-ahead), а для файлов
|
||||
≤ 1 MiB объект читался целиком (rx = size). Это нашло ревью; диапазон 64 KiB убрал оба эффекта.
|
||||
- **H1 подтверждена.** В худшем случае пик RSS реплики — 785–791 MiB из 1024, OOM и рестартов нет
|
||||
(`bench-oom-check.txt`); все неуспехи — 429 с `Retry-After` (сработал лимит слотов), ни одного 5xx.
|
||||
Пик выше расчётных ≈750 MiB на ≈40 MiB: базовый RSS к этому прогону уже был выше 250 MiB (аллокатор
|
||||
не возвращает память ОС после предыдущих прогонов — поэтому и абсолютный peak RSS у малых файлов
|
||||
в таблице 394–447 MiB при Δrss ≈ 0). Для типичных файлов Δrss — 0–2 MiB на 0.12–1 MiB и 20–43 MiB на
|
||||
9.5 MiB (C = 10 / 20) при ≈95 / 190 MiB тел в полёте на весь стенд. Латентность худшего случая
|
||||
(p50 ≈ 11–12 с) — очередь к единственному декоду: 16 запросов × ≈0.8 с; это плата за ограничение
|
||||
памяти, ожидающие дольше `UPLOAD_TIMEOUT_MS` уходят из очереди с 503.
|
||||
- **H2 подтверждена в новой формулировке.** API tx у direct ≈0.01 MiB против size у proxy (≈1000× для
|
||||
9.5 MiB); API rx одинаков (≈size), потому что `complete` читает объект целиком. Ранняя версия, читавшая
|
||||
только начало объекта, давала rx ≈0.07 MiB, но принимала повреждённые изображения — этот выигрыш был
|
||||
ценой корректности и отозван. Δrss у direct 9.5 MiB выше, чем у proxy (67 против 20 MiB): объект
|
||||
читается из S3 быстрее, чем приходит от клиента, и больше копий одновременно ждут декода. Латентность
|
||||
direct выше на всех размерах (p50 40/71/448 против 26/50/245 мс): три запроса и повторное чтение
|
||||
объекта. Выигрыш direct в этой реализации — снятие с API исходящего трафика в S3 и времени заливки
|
||||
клиентом; для выигрыша по rx проверку нужно вынести с API (асинхронный воркер рядом с хранилищем,
|
||||
`status: processing`) — следующий шаг, не реализован.
|
||||
- История версий: до полного декода (`830e581`) p50 proxy 9.5 MiB C=10 — 239 мс; с декодом через
|
||||
`stats()` (`4badd5a`, тот прогон по ошибке шёл с `UPLOAD_MAX_IN_FLIGHT=32` из устаревшего локального
|
||||
`.env`) — 642 мс; с декодом через уменьшение (`9caa031`) — 245 мс.
|
||||
|
||||
**Ограничения измерений.** Один Docker-хост: клиент, LB, API и MinIO делят 8 CPU, без реальной сети;
|
||||
`/proc/net/dev` реплики включает трафик PG/Redis и служебные запросы метрик (≈7–8 KiB на загрузку,
|
||||
видно в tx у direct; метрики и конфигурация берутся прогонами `docker exec`, но их трафик в
|
||||
измеряемое окно не входит, кроме двух чтений метрик); closed-loop клиент не моделирует arrival rate; выборка RSS 50 мс может
|
||||
пропустить короткий пик; нет TLS (до lab7); Python-клиент сам ограничен по CPU, поэтому абсолютные
|
||||
латентности не переносимы.
|
||||
`/proc/net/dev` реплики включает трафик PG/Redis и служебные запросы метрик (≈7–13 KiB на загрузку,
|
||||
видно в tx у direct); closed-loop клиент не моделирует arrival rate; выборка RSS 50 мс может
|
||||
пропустить короткий пик; абсолютный RSS зависит от истории процесса; типичные файлы — синтетический
|
||||
шум, а не фото (худший случай по памяти проверен отдельно); нет TLS (до lab7); Python-клиент сам
|
||||
ограничен по CPU, поэтому абсолютные латентности не переносимы.
|
||||
|
||||
### Отказы
|
||||
|
||||
| Воздействие | Что ожидаем | Что наблюдали | Время восстановления / потеря данных |
|
||||
| --- | --- | --- | --- |
|
||||
| S3 остановлен (`compose stop s3`) | вложения → bounded 503; текст, история, метаданные, `/health/ready` работают | upload → 503 `unavailable` без утечки деталей; метаданные 200; content 503; текстовое сообщение 201; readiness 200; одна `pending`-строка неудачной загрузки | после `start s3` и healthy download старого файла 200 с теми же байтами, новый upload 201; `pending` убрана sweep; потерь нет |
|
||||
| PostgreSQL остановлен между S3 PUT и `ready` | 503; объект не должен остаться | ответ 503; объект в S3 компенсирован (`mc stat` — нет), `pending`-строка осталась (БД недоступна) | после старта PG и `waitForReadiness`; строка убрана sweep после `expires_at`; `orphans: 0` |
|
||||
| S3 остановлен (`compose stop s3`) | вложения → bounded 503; текст, история, метаданные, `/health/ready` работают | upload → 503 `unavailable` без утечки деталей; метаданные 200; content 503; текстовое сообщение 201; readiness 200; строка неудачной загрузки в `deleting` (захвачена, удаление объекта не прошло) | после `start s3` и healthy download старого файла 200 с теми же байтами, новый upload 201; строка перезахвачена и убрана sweep через минуту; потерь нет |
|
||||
| PostgreSQL остановлен между S3 PUT и `ready` | 503; API не знает, прошёл ли COMMIT, — ничего не удаляет; объект учтён строкой | ответ 503; после старта PG строка `pending`, объект на месте (`mc stat` — есть); после `expires_at` sweep удалил объект и строку | уборка через `expires_at` + grace; `orphans: 0`, `missing: 0` |
|
||||
| COMMIT `ready` прошёл, ответ PostgreSQL потерян | объект не удаляется, клиент получает 201 | unit `attachments.service.spec.ts`: захват строки не срабатывает, `delete` не вызывается, ответ 201 `ready` | потерь нет (в стенде не воспроизводится без прокси, разрывающего соединение после COMMIT) |
|
||||
| S3 «завис» (`docker pause s3`: порт открыт, ответа нет) | ответ в пределах `S3_REQUEST_TIMEOUT_MS`, а не бесконечное ожидание | download → 503 быстрее 20 с (15 с таймаут); метаданные и readiness — 200 | после `unpause` download 200 с теми же байтами; потерь нет |
|
||||
| Медленный клиент держит 12 соединений загрузки | его лишние запросы → 429, остальные пользователи не страдают | его 13-я загрузка → 429 `Retry-After: 1`; 4 загрузки другого пользователя подряд → 201 | соединения закрыты — строк не осталось |
|
||||
| 4 параллельных `complete` одной прямой загрузки | все получают готовое вложение | 200 × 4 с одним и тем же `id` | — |
|
||||
| 32 клиента одновременно шлют худший по памяти файл | без OOM; избыток → 429 | пик RSS 791 из 1024 MiB, OOM нет, 27 отказов — все 429 | — |
|
||||
| Обрыв клиента посреди загрузки (512 KiB из 2 MiB) | не остаётся ни строки, ни объекта | PUT прерывается (`S3 put failed: AbortError` в логе API, в evidence не сохранён) без ожидания тайм-аута, компенсация, строк в чате 0 | ≤10 с (предел ожидания теста; точное время не измерялось) |
|
||||
| Остановка обслужившей реплики | другая реплика отдаёт тот же файл | download 200, тот же sha256, другой `X-Instance-Id` для api-1 и api-2 | ≈3.3 с до первого успешного запроса, 0 неуспешных записей из 134–140 |
|
||||
| Остановка обслужившей реплики | другая реплика отдаёт тот же файл | download 200, тот же sha256, другой `X-Instance-Id` для api-1 и api-2 | ≈3.2 с до первого успешного запроса, 0 неуспешных записей из 133–141 |
|
||||
| Restart стенда (`scripts/restart.sh`) | метаданные и оригиналы сохраняются, сессия жива | persistence PASS; `StartedAt` всех сервисов изменился | потерь нет (время до готовности отдельно не измерялось) |
|
||||
| Истёкший presigned URL | PUT отвергается, заявка убирается | PUT → 403; строка убрана уборщиком; complete → 404 | TTL (5 с в прогоне) + grace 0 + период уборщика 1 с |
|
||||
| Подмена байтов / размера при прямой загрузке | S3 отвергает, объект не создаётся | 400 `XAmzContentChecksumMismatch` / 403 `SignatureDoesNotMatch`; complete → 409 | заявка остаётся до TTL, клиент может доотправить |
|
||||
@@ -256,28 +337,42 @@ S3) до малой величины, не зависящей от размер
|
||||
- **MinIO:** закреплён образ `RELEASE.2025-09-07T16-13-09Z`; по данным, использованным при планировании,
|
||||
репозиторий `minio/minio` архивирован — новых образов и исправлений не будет *(в этой сессии не
|
||||
перепроверялось)*. Для продакшена потребуется замена (SeaweedFS/RustFS) или форк.
|
||||
- **Прямой путь не проверяет структуру хвоста файла** при size > 64 KiB: только заголовок (первые 64 KiB, при необходимости до 1 MiB) и
|
||||
подписанный SHA-256/размер. Байты гарантированно те, что заявил клиент, но заявил он их сам;
|
||||
усечённый или «склеенный» файл с корректным заголовком пройдёт `complete`. В proxy-режиме проверяется
|
||||
весь поток (CRC чанков PNG, EOI JPEG). Для size ≤ 64 KiB direct проверяет всё, ценой входящего
|
||||
трафика API.
|
||||
- **Полная проверка изображения стоит памяти и времени:** копия тела (≤ 10 MiB) на загрузку и декод
|
||||
через libvips (нативная зависимость sharp; худший вход — 338 MiB, ≈0.8 с). Поэтому декод на реплике
|
||||
строго по одному, а реплике нужен 1 GiB; под потоком «тяжёлых» изображений латентность растёт до
|
||||
секунд (очередь), а лишние запросы получают 429. `failOn: 'warning'` строже браузеров: файл с
|
||||
предупреждением libjpeg/libpng будет отвергнут (на 300 изображениях с хоста ложных отказов не было,
|
||||
но выборка не репрезентативна для фото с камер). Проверяются декодируемость и целостность, а не
|
||||
«безопасность для всех декодеров» — перекодирование в чистый формат не делается.
|
||||
- **Изменённый байт внутри сжатых данных baseline JPEG может пройти проверку:** у JPEG нет контрольной
|
||||
суммы, и такой байт часто даёт другой, но корректный поток Хаффмана (замер: из 14 видов порчи не
|
||||
пойман только этот). Для PNG то же поймает CRC/Adler-32. В direct байты дополнительно зафиксированы
|
||||
подписанным SHA-256 — они ровно те, что заявил клиент.
|
||||
- **Direct не экономит входящий трафик API** (см. H2); это следствие проверки на API. Следующий шаг —
|
||||
асинхронная проверка воркером рядом с хранилищем (`status: processing`), что требует расширения
|
||||
контракта.
|
||||
- **Лимит на пользователя не защищает от многих аккаунтов:** регистрация открыта, поэтому распределённый
|
||||
«медленный клиент» из ≥ 4 аккаунтов на реплику всё ещё может занять все слоты на `UPLOAD_TIMEOUT_MS`
|
||||
(25 с). Защита — минимальная скорость приёма тела или ограничения на LB; не реализовано.
|
||||
- **Гонка лимита заявок:** `countPendingDirect` и `insertPending` не атомарны — параллельные `init`
|
||||
одного пользователя могут превысить лимит на число параллельных запросов; для лабораторной принято.
|
||||
- **Загрузка, не доставленная до `ready`, видна уборщику только через grace (по умолчанию 15 мин):**
|
||||
до этого объект занимает место; для быстрой очистки в тестах grace уменьшается переменной окружения.
|
||||
- **Недоступность S3 при `compensate`** оставляет объект, если сам `DeleteObject` не прошёл; его
|
||||
убирает уборщик по строке. Объект без строки (например, строку удалили вручную) обнаружит только
|
||||
`make consistency` — автоматического reconciler'а для orphan-объектов нет (это трек 2).
|
||||
- **Порядок компенсации proxy:** сначала удаляется объект, затем строка. Если `markReady` на самом деле
|
||||
зафиксирован, а клиент БД увидел обрыв соединения, объект будет удалён у строки `ready` (потеря данных;
|
||||
`object_missing` → 500 на download). Обратный порядок противоречил бы требованию «объекта не должно
|
||||
остаться при отказе PG»; окно — доли секунды между commit и обрывом, принято как ограничение.
|
||||
- **Таймаут загрузки** уничтожает тело (и сокет) — клиент может получить обрыв соединения вместо
|
||||
ожидаемого 400 «Upload was interrupted»; строка и объект при этом компенсируются.
|
||||
- **Незавершённые загрузки занимают место до уборки** (`expires_at` + grace 15 мин): в т. ч. прямые
|
||||
заявки, чей `complete` получил 429 (после серии бенчмарка в `consistency.txt` видно 84 `pending`).
|
||||
Если строка уже `deleting` из-за поздно зафиксированного PUT после таймаута, уборщик повторно удалит
|
||||
ключ через минуту.
|
||||
- **Компенсация при недоступной БД ничего не удаляет:** объект остаётся до уборки
|
||||
(`expires_at` + 900 с grace) — сознательный выбор: без БД нельзя отличить «COMMIT не прошёл» от «ответ
|
||||
потерян», а удаление во втором случае теряет оригинал. Объект без строки (например, строку удалили
|
||||
вручную) обнаружит только `make consistency` — автоматического reconciler'а нет (это трек 2).
|
||||
- **Потерянный COMMIT проверен только unit-тестом** с моком репозитория: стенд не умеет разорвать
|
||||
соединение PostgreSQL ровно после COMMIT (для этого нужен прокси вроде toxiproxy).
|
||||
- **Таймаут загрузки** уничтожает тело (и сокет) — клиент получает обрыв соединения (через HAProxy — 502
|
||||
без `X-Request-Id`) вместо 400 «Upload was interrupted»; строка и объект при этом компенсируются.
|
||||
- **TLS нет** до lab7: presigned URL и токены ходят по HTTP; консоль MinIO отключена полностью, поэтому
|
||||
администрирование — только через `mc` из контейнера.
|
||||
- **Не реализовано:** варианты вложений (`variants` всегда `[]`; `variant=thumbnail|crop|optimized` → 404),
|
||||
delete-API вложений, WebP.
|
||||
- **Подтверждено измерением:** потоковый proxy ограничивает память, direct уменьшает tx и rx API для
|
||||
любого из проверенных размеров. **Остаётся гипотезой:** причина роста латентности direct на 9.5 MiB; зависимость Δrss от
|
||||
concurrency за пределами C=20.
|
||||
delete-API вложений, WebP, `Range` на download (игнорируется, отдаётся весь файл с 200).
|
||||
- **Подтверждено измерением:** память реплики ограничена конфигурацией и в худшем случае не доходит до
|
||||
лимита; direct снимает с API исходящий трафик в S3. **Опровергнуто для текущей версии:** снижение
|
||||
входящего трафика API прямой загрузкой. **Остаётся гипотезой:** поведение на реальных фото (типичный
|
||||
бенчмарк — синтетический шум) и при C, многократно превышающем лимит слотов.
|
||||
|
||||
Generated
+560
-1
@@ -26,6 +26,7 @@
|
||||
"redis": "^6.3.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"sharp": "^0.35.5",
|
||||
"zod": "^4.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -553,6 +554,16 @@
|
||||
"node": ">=0.1.90"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.11.3",
|
||||
"resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.11.3.tgz",
|
||||
"integrity": "sha512-Xz4Tpyki7XyrpbUK1jR1AhdAdaXyhhY4lZ3neLodmhpuWfy2PAQN5B46sAiU4liOXGLkHypn/qU+jvfWSCYYLA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@epic-web/invariant": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@epic-web/invariant/-/invariant-1.0.0.tgz",
|
||||
@@ -1200,6 +1211,506 @@
|
||||
"node": ">= 10"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/colour": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@img/colour/-/colour-1.1.0.tgz",
|
||||
"integrity": "sha512-Td76q7j57o/tLVdgS746cYARfSyxk8iEfRxewL9h4OMzYhbW4TAcppl0mT4eyqXddh6L/jwoM75mo7ixa/pCeQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-darwin-arm64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.35.5.tgz",
|
||||
"integrity": "sha512-QRUlFQ0WxvdWyqqG/WtI3iupfD5rBzmCHXSdPsY91sAtVtTo7Q4cb6zOccZ3gqEqkr0f1As1ehLqmEpDsRf+lg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-darwin-arm64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-darwin-x64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.35.5.tgz",
|
||||
"integrity": "sha512-+BR255RhDlpygUpOc/Jdt1nT6DQ3XG/ERo5wbcdOf5Q320dKtPCKPLR1LJs9VGXRaMa8l1uUa0tkCNOXiAxZUw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-darwin-x64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-freebsd-wasm32": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-freebsd-wasm32/-/sharp-freebsd-wasm32-0.35.5.tgz",
|
||||
"integrity": "sha512-Y/z91nEZ4uIBX5X3nfTovjU9lHNKFYbL2lpHCLVNmXQK03VIZvXBBt0KxbPGp2SdGSF+2mQU4e+hQaWOt86iAw==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"dependencies": {
|
||||
"@img/sharp-wasm32": "0.35.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-darwin-arm64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.3.4.tgz",
|
||||
"integrity": "sha512-5R89nBYiRdUlSWJxPhO+GVtaXzXSxKnRu/xqMn3KTA3L9EB9Oy/P+Nn2f2vlhPuUdy/Zusb2DarbyTpGCfEDuw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-darwin-x64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.3.4.tgz",
|
||||
"integrity": "sha512-iR2OKH80yi0U+dUplyh3/xdpFvps6YkCwsXenIJxqxR1v9o+xtKTGbS9H7cps+2Vxjc8B1j96p75NmTGjIhtpQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-arm": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.3.4.tgz",
|
||||
"integrity": "sha512-LmRtTsOHuvM2+wlO2Db37dx5MiZhB0FvSunciw48YjdOkZz9KAiRbm8ujeMOA1INqmei5NapFxYEK1D1ZSidmw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-arm64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.3.4.tgz",
|
||||
"integrity": "sha512-Y3dgX/6lE2QhQb+Gxy0WZxfg9MEm/JBjamZpS2IklP7xIQoKN4hzAm7KcMVGtaVDt3neE9OKBC7vAfonA/Lr1A==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-ppc64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.3.4.tgz",
|
||||
"integrity": "sha512-Le6boB8Tai0Nis+gIxIpKx68UDVVIqdR8Tin5Yf1z2LJJQLDJvCDRqRu+jC2qCoD+eIomonmOwB4smBRxfVpYQ==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-riscv64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-riscv64/-/sharp-libvips-linux-riscv64-1.3.4.tgz",
|
||||
"integrity": "sha512-aHkkIEHPRdQEegJN20MLmGtxYD9R2wQr3Cwpddnu5+YKMt6Uzax7S9h5gpZTo8wyrGuZSlfQ63OevL5mTyOC7Q==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-s390x": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.3.4.tgz",
|
||||
"integrity": "sha512-ra/mB6MikESDUO7Yg+Mi95bFBb9GsObURuhnOv3OqknjGe9sZrG8tCe9q0xSIGrtLgvgw0gKnFWcK4blSgQOuQ==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-x64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.3.4.tgz",
|
||||
"integrity": "sha512-GJ//SSXbnwSDes02umB3nDJLFcQzw8a18V8fyhqr6tV515tOEMdImjjxj1AoafMRz56F3PHgftnj1QEKSU1zkw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linuxmusl-arm64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.3.4.tgz",
|
||||
"integrity": "sha512-hvulFwtjUcagsis6BBxHwGFwWoNZjgYmULGVrZcyfNbjA8hKILbRxGg15/7w5HDyXHXUos/j6baAWqnCyQ2DWA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linuxmusl-x64": {
|
||||
"version": "1.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.3.4.tgz",
|
||||
"integrity": "sha512-6zXKeE/p39I1AmA3cJG35eyBGNqNddLnUXjhwBnsGjFPWqf5VKkDBEqaEkPDoTEtkxwi2vv8Tcr2mDyP4So7Fg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-arm": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.35.5.tgz",
|
||||
"integrity": "sha512-LEaXK2WdXVK5ykcw0buWyPMsmLLL2vpHLD6yrNSW+JGEL3BZPA4tpKN6iaMc4AxTTAoaX/sU1rOL51lcIz48ZQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-arm": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-arm64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.35.5.tgz",
|
||||
"integrity": "sha512-LYVx5JTsOM2CBzmxreh+nl64/3H6Xb09iSLknqH47z2T2DFFxDeFLP5y4dJwe6H7uGQlHPyEEtIqyo3DYsRwdQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-arm64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-ppc64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.35.5.tgz",
|
||||
"integrity": "sha512-QVxAAq8evVRI9ia2vqgwrmWucn5Dfv+JdWzj75pD8omHLPSP7f8p20O8jxzjCcuCEQEOtYOZUmX1hkiZ0kdevA==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-ppc64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-riscv64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-riscv64/-/sharp-linux-riscv64-0.35.5.tgz",
|
||||
"integrity": "sha512-LtdreXguaavKODPIfzJ4kffx7UNt1omwtK0rch4EBbbSTXPnxWmYSayXdLJw0fJzQ97kHt1gL/yh4tvU+nCyRQ==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-riscv64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-s390x": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.35.5.tgz",
|
||||
"integrity": "sha512-UZasTOFiYzotTsGOCu42BfUzP6Tu6Do/947iRm1RsLKvlllxwGcn4RN27LibGWceix4Y+Pmw3jsnTcCQIgWjqA==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-s390x": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-x64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.35.5.tgz",
|
||||
"integrity": "sha512-SxFtLTeJInhAA9Q836kux2vZNeOBQEx658qvbboZScr0wIARym3IcGmW7KpVD5sbVg0Ojy+udFQdayYIZyoNog==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-x64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linuxmusl-arm64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.35.5.tgz",
|
||||
"integrity": "sha512-9HbMclmI1zlNkFRs3z9/eBtDjfD0sGlrX1z6b1qwmiFY5ElDLh4BC0LPBdVp7z1DXFiKlIcznf+ZlsuZzLxQqg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linuxmusl-arm64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linuxmusl-x64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.35.5.tgz",
|
||||
"integrity": "sha512-4KOphqB035HrVdqLZfCgMzzERrQkkzOwRhl4OAkRO1YCldbaFjySXMaK534Mo0V+LndnlJk+sbUyLeU0ULyD1A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linuxmusl-x64": "1.3.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-wasm32": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.35.5.tgz",
|
||||
"integrity": "sha512-Ptsga1su4tQx+LLF1ECS9U6nz5kmrXKo6XVbtR48Ke3ZRxxgaWBu7IDtEe1quo8hiupwm6WFqxVlXaSf7IINGQ==",
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/runtime": "^1.11.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-webcontainers-wasm32": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-webcontainers-wasm32/-/sharp-webcontainers-wasm32-0.35.5.tgz",
|
||||
"integrity": "sha512-hfhF/FmoQyTUkA0bIKFOtw536BQSeBMe6BF6QyWlrPxT754+TFLaZ7sKKTfvvM0yJgKgaYTwnFCIZ/GuDw5SUA==",
|
||||
"cpu": [
|
||||
"wasm32"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@img/sharp-wasm32": "0.35.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-win32-arm64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.35.5.tgz",
|
||||
"integrity": "sha512-X4t7g+7ZA5DKblCBEXGjUqqemj4vczING/5viFwAL8h4N3qYeyjwdCvRLHi4EdOUI+2Z7UFlp1VM+p/AuEtm6Q==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-win32-ia32": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.35.5.tgz",
|
||||
"integrity": "sha512-5Zm82LoBc43nhwNybZlG7Y1KO//Zhsn306fQl29ZOuStHLGTo3BWL83q3cznX0poxSAMuYL1On/BHBxkBeKr6A==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-win32-x64": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.35.5.tgz",
|
||||
"integrity": "sha512-x76eH0vEiHlcMQu8Y8IenntaACtddpT6W0wmXtWrnKcnKI7ME5DdgqhAD6SEWOEl1v2zDvkZDhFA9KnURwpfqg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@inquirer/ansi": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@inquirer/ansi/-/ansi-2.0.8.tgz",
|
||||
@@ -4014,7 +4525,6 @@
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@@ -6842,6 +7352,55 @@
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/sharp": {
|
||||
"version": "0.35.5",
|
||||
"resolved": "https://registry.npmjs.org/sharp/-/sharp-0.35.5.tgz",
|
||||
"integrity": "sha512-Ywn4OnzGukp7CDMrp08RQ50YKmuwG47brZgIVPTvBaaAfQlRlygrRqSrxdCiL9M+LlzLBiJ68IR1QqvzHyjC7g==",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@img/colour": "^1.1.0",
|
||||
"detect-libc": "^2.1.2",
|
||||
"semver": "^7.8.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-darwin-arm64": "0.35.5",
|
||||
"@img/sharp-darwin-x64": "0.35.5",
|
||||
"@img/sharp-freebsd-wasm32": "0.35.5",
|
||||
"@img/sharp-libvips-darwin-arm64": "1.3.4",
|
||||
"@img/sharp-libvips-darwin-x64": "1.3.4",
|
||||
"@img/sharp-libvips-linux-arm": "1.3.4",
|
||||
"@img/sharp-libvips-linux-arm64": "1.3.4",
|
||||
"@img/sharp-libvips-linux-ppc64": "1.3.4",
|
||||
"@img/sharp-libvips-linux-riscv64": "1.3.4",
|
||||
"@img/sharp-libvips-linux-s390x": "1.3.4",
|
||||
"@img/sharp-libvips-linux-x64": "1.3.4",
|
||||
"@img/sharp-libvips-linuxmusl-arm64": "1.3.4",
|
||||
"@img/sharp-libvips-linuxmusl-x64": "1.3.4",
|
||||
"@img/sharp-linux-arm": "0.35.5",
|
||||
"@img/sharp-linux-arm64": "0.35.5",
|
||||
"@img/sharp-linux-ppc64": "0.35.5",
|
||||
"@img/sharp-linux-riscv64": "0.35.5",
|
||||
"@img/sharp-linux-s390x": "0.35.5",
|
||||
"@img/sharp-linux-x64": "0.35.5",
|
||||
"@img/sharp-linuxmusl-arm64": "0.35.5",
|
||||
"@img/sharp-linuxmusl-x64": "0.35.5",
|
||||
"@img/sharp-webcontainers-wasm32": "0.35.5",
|
||||
"@img/sharp-win32-arm64": "0.35.5",
|
||||
"@img/sharp-win32-ia32": "0.35.5",
|
||||
"@img/sharp-win32-x64": "0.35.5"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
"redis": "^6.3.0",
|
||||
"reflect-metadata": "^0.2.2",
|
||||
"rxjs": "^7.8.1",
|
||||
"sharp": "^0.35.5",
|
||||
"zod": "^4.6.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -23,6 +23,7 @@ import type { User } from '../users/user.js';
|
||||
import { AttachmentsService } from './attachments.service.js';
|
||||
import { CreateDirectUploadDto } from './dto/create-direct-upload.dto.js';
|
||||
import { DirectUploadsService } from './direct-uploads.service.js';
|
||||
import type { UploadRequest } from './upload-request.js';
|
||||
import { contentDisposition } from './filename.js';
|
||||
|
||||
@Controller('api/v1')
|
||||
@@ -44,9 +45,8 @@ export class AttachmentsController {
|
||||
@Param('chatId', new ParseUUIDPipe()) chatId: string,
|
||||
@CurrentUser() user: User,
|
||||
@Query('filename') filename: unknown,
|
||||
@Headers('content-type') contentType: string | undefined,
|
||||
@Headers('content-length') contentLength: string | undefined,
|
||||
@Req() request: FastifyRequest,
|
||||
@Req() request: FastifyRequest & UploadRequest,
|
||||
@Res({ passthrough: true }) reply: FastifyReply,
|
||||
) {
|
||||
// A gigantic body is not worth draining: close the connection after the answer.
|
||||
@@ -56,7 +56,7 @@ export class AttachmentsController {
|
||||
chatId,
|
||||
user,
|
||||
filename,
|
||||
contentType,
|
||||
request.uploadContentType,
|
||||
contentLength,
|
||||
request.body as Readable | undefined,
|
||||
);
|
||||
|
||||
@@ -8,6 +8,8 @@ import { StorageModule } from '../storage/storage.module.js';
|
||||
import { AttachmentSweeper } from './attachment-sweeper.service.js';
|
||||
import { AttachmentsController } from './attachments.controller.js';
|
||||
import { AttachmentsRepository } from './attachments.repository.js';
|
||||
import { ImageDecoder } from './image/image-decoder.js';
|
||||
import { UploadSlots } from './upload-slots.js';
|
||||
import { DirectUploadsService } from './direct-uploads.service.js';
|
||||
import { AttachmentsService } from './attachments.service.js';
|
||||
|
||||
@@ -25,6 +27,8 @@ import { AttachmentsService } from './attachments.service.js';
|
||||
AttachmentsRepository,
|
||||
AttachmentsService,
|
||||
DirectUploadsService,
|
||||
ImageDecoder,
|
||||
UploadSlots,
|
||||
AttachmentSweeper,
|
||||
],
|
||||
exports: [AttachmentsRepository],
|
||||
|
||||
@@ -75,13 +75,38 @@ export class AttachmentsRepository {
|
||||
);
|
||||
}
|
||||
|
||||
async rejectPending(id: string): Promise<void> {
|
||||
await this.database.query(
|
||||
async rejectPending(id: string): Promise<boolean> {
|
||||
const result = await this.database.query(
|
||||
'attachments.reject_pending',
|
||||
`UPDATE attachments SET status = 'rejected', updated_at = now()
|
||||
WHERE id = $1 AND status = 'pending'`,
|
||||
[id],
|
||||
);
|
||||
return result.rowCount === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes a pending row out of play before its object is deleted. The object
|
||||
* is deleted only when this returns true: a row that is already `ready`
|
||||
* (its commit succeeded even if the reply was lost) keeps its object.
|
||||
*/
|
||||
async claimForCompensation(id: string): Promise<boolean> {
|
||||
const result = await this.database.query(
|
||||
'attachments.claim_for_compensation',
|
||||
`UPDATE attachments SET status = 'deleting', updated_at = now()
|
||||
WHERE id = $1 AND status = 'pending'`,
|
||||
[id],
|
||||
);
|
||||
return result.rowCount === 1;
|
||||
}
|
||||
|
||||
async findById(id: string): Promise<AttachmentRow | undefined> {
|
||||
const result = await this.database.query<AttachmentRow>(
|
||||
'attachments.find_by_id',
|
||||
'SELECT * FROM attachments WHERE id = $1',
|
||||
[id],
|
||||
);
|
||||
return result.rows[0];
|
||||
}
|
||||
|
||||
async findVisible(
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { Readable } from 'node:stream';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import type { AttachmentRow } from './attachment.js';
|
||||
import { AttachmentsService } from './attachments.service.js';
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const png = readFileSync(join(here, '../../../tests/fixtures/sample.png'));
|
||||
const lostReply = () =>
|
||||
Object.assign(new Error('Connection terminated unexpectedly'), {});
|
||||
|
||||
const settings: Record<string, number> = {
|
||||
MAX_UPLOAD_BYTES: 10_485_760,
|
||||
MAX_IMAGE_PIXELS: 40_000_000,
|
||||
UPLOAD_TIMEOUT_MS: 10_000,
|
||||
};
|
||||
|
||||
function setup(repository: Record<string, unknown>) {
|
||||
const storage = {
|
||||
objectKey: (id: string) => `attachments/${id}/original`,
|
||||
putStream: vi.fn(async (_key: string, body: Readable) => {
|
||||
for await (const _chunk of body) {
|
||||
// drain like S3 does
|
||||
}
|
||||
}),
|
||||
delete: vi.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
const service = new AttachmentsService(
|
||||
{ getOrThrow: (key: string) => settings[key] } as never,
|
||||
{
|
||||
insertPending: vi.fn(),
|
||||
deleteClaimed: vi.fn(),
|
||||
...repository,
|
||||
} as never,
|
||||
storage as never,
|
||||
{ getForUser: vi.fn() } as never,
|
||||
{ increment: vi.fn(), add: vi.fn() } as never,
|
||||
{ verify: vi.fn() } as never,
|
||||
{
|
||||
run: (_user: string, work: () => Promise<unknown>) => work(),
|
||||
} as never,
|
||||
);
|
||||
const upload = () =>
|
||||
service.uploadProxy(
|
||||
'chat',
|
||||
{ id: 'user' } as never,
|
||||
'a.png',
|
||||
'image/png',
|
||||
String(png.length),
|
||||
Readable.from([png]),
|
||||
);
|
||||
return { storage, upload };
|
||||
}
|
||||
|
||||
const readyRow = (id: string): AttachmentRow => ({
|
||||
id,
|
||||
chat_id: 'chat',
|
||||
owner_id: 'user',
|
||||
filename: 'a.png',
|
||||
content_type: 'image/png',
|
||||
upload_mode: 'proxy',
|
||||
status: 'ready',
|
||||
object_key: `attachments/${id}/original`,
|
||||
size_bytes: png.length,
|
||||
sha256: 'a'.repeat(64),
|
||||
width: 320,
|
||||
height: 200,
|
||||
expires_at: null,
|
||||
created_at: new Date(),
|
||||
updated_at: new Date(),
|
||||
});
|
||||
|
||||
describe('AttachmentsService compensation', () => {
|
||||
it('keeps the object and answers 201 when ready was committed but its reply was lost', async () => {
|
||||
const { storage, upload } = setup({
|
||||
markReady: vi.fn().mockRejectedValue(lostReply()),
|
||||
claimForCompensation: vi.fn().mockResolvedValue(false),
|
||||
findById: vi.fn((id: string) => Promise.resolve(readyRow(id))),
|
||||
});
|
||||
const attachment = await upload();
|
||||
expect(attachment.status).toBe('ready');
|
||||
expect(storage.delete).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('deletes nothing while PostgreSQL is unreachable', async () => {
|
||||
const { storage, upload } = setup({
|
||||
markReady: vi.fn().mockRejectedValue(lostReply()),
|
||||
claimForCompensation: vi.fn().mockRejectedValue(lostReply()),
|
||||
findById: vi.fn().mockRejectedValue(lostReply()),
|
||||
});
|
||||
await expect(upload()).rejects.toThrow();
|
||||
expect(storage.delete).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('deletes the object only after claiming the pending row', async () => {
|
||||
const order: string[] = [];
|
||||
const { storage, upload } = setup({
|
||||
markReady: vi.fn().mockRejectedValue(lostReply()),
|
||||
claimForCompensation: vi.fn(async () => {
|
||||
order.push('claim');
|
||||
return true;
|
||||
}),
|
||||
deleteClaimed: vi.fn(async () => {
|
||||
order.push('delete-row');
|
||||
}),
|
||||
});
|
||||
storage.delete.mockImplementation(async () => {
|
||||
order.push('delete-object');
|
||||
});
|
||||
await expect(upload()).rejects.toThrow();
|
||||
expect(order).toEqual(['claim', 'delete-object', 'delete-row']);
|
||||
});
|
||||
});
|
||||
@@ -24,12 +24,13 @@ import {
|
||||
} from './attachment.js';
|
||||
import { validateFilename } from './filename.js';
|
||||
import {
|
||||
IMAGE_HEADER_MAX_BYTES,
|
||||
ImageHeader,
|
||||
ImageInspector,
|
||||
ImageRejectedError,
|
||||
} from './image/image-inspector.js';
|
||||
import { AttachmentsRepository } from './attachments.repository.js';
|
||||
import { ImageDecoder } from './image/image-decoder.js';
|
||||
import { UploadSlots } from './upload-slots.js';
|
||||
|
||||
const MEDIA_TYPES = new Set(['image/png', 'image/jpeg']);
|
||||
|
||||
@@ -49,11 +50,9 @@ class UploadInterruptedError extends Error {}
|
||||
@Injectable()
|
||||
export class AttachmentsService {
|
||||
private readonly logger = new Logger(AttachmentsService.name);
|
||||
private inFlight = 0;
|
||||
private readonly maxUploadBytes: number;
|
||||
private readonly maxPixels: number;
|
||||
private readonly uploadTimeoutMs: number;
|
||||
private readonly maxInFlight: number;
|
||||
|
||||
constructor(
|
||||
config: ConfigService<AppConfig>,
|
||||
@@ -61,11 +60,12 @@ export class AttachmentsService {
|
||||
private readonly storage: ObjectStorage,
|
||||
private readonly chats: ChatsService,
|
||||
private readonly metrics: MetricsService,
|
||||
private readonly decoder: ImageDecoder,
|
||||
private readonly slots: UploadSlots,
|
||||
) {
|
||||
this.maxUploadBytes = config.getOrThrow('MAX_UPLOAD_BYTES');
|
||||
this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS');
|
||||
this.uploadTimeoutMs = config.getOrThrow('UPLOAD_TIMEOUT_MS');
|
||||
this.maxInFlight = config.getOrThrow('UPLOAD_MAX_IN_FLIGHT');
|
||||
}
|
||||
|
||||
async uploadProxy(
|
||||
@@ -93,15 +93,9 @@ export class AttachmentsService {
|
||||
if (contentLength > this.maxUploadBytes)
|
||||
throw new PayloadTooLargeException('Image is too large');
|
||||
|
||||
if (this.inFlight >= this.maxInFlight)
|
||||
throw new HttpException(
|
||||
{ message: 'Too many concurrent uploads', retryAfter: 1 },
|
||||
429,
|
||||
);
|
||||
this.inFlight += 1;
|
||||
try {
|
||||
return this.slots.run(user.id, async () => {
|
||||
await this.chats.getForUser(chatId, user);
|
||||
return await this.receive(
|
||||
return this.receive(
|
||||
chatId,
|
||||
user,
|
||||
filename,
|
||||
@@ -109,9 +103,7 @@ export class AttachmentsService {
|
||||
contentLength,
|
||||
body,
|
||||
);
|
||||
} finally {
|
||||
this.inFlight -= 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private async receive(
|
||||
@@ -144,8 +136,9 @@ export class AttachmentsService {
|
||||
let key = '';
|
||||
let rejection: unknown;
|
||||
try {
|
||||
// Header phase: nothing exists in the database or S3 yet.
|
||||
let headBytes = 0;
|
||||
// Header phase: nothing exists in the database or S3 yet. It is
|
||||
// bounded by Content-Length (<= MAX_UPLOAD_BYTES): a JPEG may carry
|
||||
// megabytes of APPn metadata before its frame header.
|
||||
try {
|
||||
while (inspector.header === undefined) {
|
||||
const step = await next();
|
||||
@@ -157,16 +150,7 @@ export class AttachmentsService {
|
||||
);
|
||||
}
|
||||
head.push(step.value);
|
||||
headBytes += step.value.length;
|
||||
inspector.push(step.value);
|
||||
if (
|
||||
inspector.header === undefined &&
|
||||
headBytes > IMAGE_HEADER_MAX_BYTES
|
||||
)
|
||||
throw new ImageRejectedError(
|
||||
'unsupported_media_type',
|
||||
'Image header is missing',
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw this.mapUploadError(error, timedOut);
|
||||
@@ -193,8 +177,13 @@ export class AttachmentsService {
|
||||
});
|
||||
|
||||
const sha256 = createHash('sha256');
|
||||
const decoder = this.decoder;
|
||||
// Copy for the full decode check; bounded by MAX_UPLOAD_BYTES and
|
||||
// UPLOAD_MAX_IN_FLIGHT, released as soon as the decode starts.
|
||||
const copy: Buffer[] = [];
|
||||
let total = 0;
|
||||
const account = (chunk: Buffer, inspect: boolean): void => {
|
||||
let allSent = false;
|
||||
const account = (chunk: Buffer, inspect: boolean): boolean => {
|
||||
total += chunk.length;
|
||||
if (total > contentLength)
|
||||
throw new UploadInterruptedError(
|
||||
@@ -203,19 +192,29 @@ export class AttachmentsService {
|
||||
if (inspect) inspector.push(chunk);
|
||||
sha256.update(chunk);
|
||||
this.metrics.add('attachments.proxy.bytes_in', chunk.length);
|
||||
// Validate before the last bytes reach S3: it cannot commit an
|
||||
// object whose body is incomplete.
|
||||
if (total === contentLength) inspector.finish();
|
||||
copy.push(chunk);
|
||||
return total === contentLength;
|
||||
};
|
||||
// Validate before the last bytes reach S3: it cannot commit an object
|
||||
// whose body is incomplete, so an invalid image never becomes an object.
|
||||
const finalize = async (): Promise<void> => {
|
||||
inspector.finish();
|
||||
const data = Buffer.concat(copy, total);
|
||||
copy.length = 0;
|
||||
await decoder.verify(data, controller.signal);
|
||||
// From here S3 may receive the whole body and commit the object
|
||||
// even if this request fails or times out afterwards.
|
||||
allSent = true;
|
||||
};
|
||||
async function* generate(): AsyncGenerator<Buffer> {
|
||||
for (const chunk of head) {
|
||||
account(chunk, false);
|
||||
if (account(chunk, false)) await finalize();
|
||||
yield chunk;
|
||||
}
|
||||
for (;;) {
|
||||
const step = await next();
|
||||
if (step.done) break;
|
||||
account(step.value, true);
|
||||
if (account(step.value, true)) await finalize();
|
||||
yield step.value;
|
||||
}
|
||||
if (total < contentLength)
|
||||
@@ -238,6 +237,7 @@ export class AttachmentsService {
|
||||
// `rejection`; the listener also keeps a late error from crashing us.
|
||||
readable.on('error', () => controller.abort());
|
||||
let claimed = false;
|
||||
let stored = false;
|
||||
try {
|
||||
await this.storage.putStream(
|
||||
key,
|
||||
@@ -250,6 +250,7 @@ export class AttachmentsService {
|
||||
'attachments.proxy.bytes_to_s3',
|
||||
contentLength,
|
||||
);
|
||||
stored = true;
|
||||
const row = await this.repository.markReady(id, {
|
||||
sizeBytes: total,
|
||||
sha256: sha256.digest('hex'),
|
||||
@@ -264,7 +265,28 @@ export class AttachmentsService {
|
||||
return toAttachment(row);
|
||||
} catch (error) {
|
||||
readable.destroy();
|
||||
if (!claimed) await this.compensate(id, key);
|
||||
if (!claimed) {
|
||||
// After the last byte was handed to S3, a PUT aborted on our
|
||||
// side may still be committed by S3 after our DELETE: keep the
|
||||
// row so the sweeper deletes the key again later.
|
||||
const outcome = await this.compensate(id, key, {
|
||||
keepRow: allSent && !stored,
|
||||
});
|
||||
// markReady failed on our side, but the row is no longer
|
||||
// pending: the commit may have succeeded with its reply lost.
|
||||
// If so, the upload is complete and 201 is the truth.
|
||||
if (outcome === 'not_pending' && stored) {
|
||||
const row = await this.repository
|
||||
.findById(id)
|
||||
.catch(() => undefined);
|
||||
if (row?.status === 'ready') {
|
||||
this.metrics.increment(
|
||||
'attachments.upload.recovered',
|
||||
);
|
||||
return toAttachment(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
throw this.mapUploadError(rejection ?? error, timedOut);
|
||||
}
|
||||
} finally {
|
||||
@@ -279,16 +301,36 @@ export class AttachmentsService {
|
||||
return error;
|
||||
}
|
||||
|
||||
async compensate(id: string, key: string): Promise<void> {
|
||||
/**
|
||||
* Undoes an upload that did not reach `ready`. The row is claimed first
|
||||
* (pending -> deleting) and the object is deleted only after a successful
|
||||
* claim: if PostgreSQL committed `ready` but the reply was lost, the claim
|
||||
* matches nothing and the object stays. If PostgreSQL is unreachable,
|
||||
* nothing is deleted; the sweeper finishes the job after expiry + grace
|
||||
* (a row stuck in `deleting` is re-claimed after a minute).
|
||||
*/
|
||||
async compensate(
|
||||
id: string,
|
||||
key: string,
|
||||
options: { keepRow?: boolean } = {},
|
||||
): Promise<'compensated' | 'not_pending' | 'deferred'> {
|
||||
try {
|
||||
if (!(await this.repository.claimForCompensation(id))) {
|
||||
this.metrics.increment('attachments.compensation_skipped');
|
||||
return 'not_pending';
|
||||
}
|
||||
await this.storage.delete(key);
|
||||
await this.repository.deletePending(id);
|
||||
// A kept `deleting` row is re-claimed by the sweeper after a minute,
|
||||
// which deletes the key once more and only then the row.
|
||||
if (!options.keepRow) await this.repository.deleteClaimed(id);
|
||||
this.metrics.increment('attachments.compensated');
|
||||
return 'compensated';
|
||||
} catch (error) {
|
||||
this.metrics.increment('attachments.compensation_deferred');
|
||||
this.logger.warn(
|
||||
`Compensation of attachment ${id} deferred: ${error instanceof Error ? error.message : 'unknown error'}`,
|
||||
);
|
||||
return 'deferred';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ import { randomUUID } from 'node:crypto';
|
||||
import type { AppConfig } from '../config/app-config.schema.js';
|
||||
import { ChatsService } from '../chats/chats.service.js';
|
||||
import { MetricsService } from '../metrics/metrics.service.js';
|
||||
import { ObjectStorage } from '../storage/object-storage.js';
|
||||
import {
|
||||
ObjectStorage,
|
||||
ObjectStorageUnavailableError,
|
||||
} from '../storage/object-storage.js';
|
||||
import type { User } from '../users/user.js';
|
||||
import {
|
||||
toAttachment,
|
||||
@@ -22,8 +25,9 @@ import { AttachmentsRepository } from './attachments.repository.js';
|
||||
import { imageRejection } from './attachments.service.js';
|
||||
import type { CreateDirectUploadDto } from './dto/create-direct-upload.dto.js';
|
||||
import { validateFilename } from './filename.js';
|
||||
import { ImageDecoder } from './image/image-decoder.js';
|
||||
import { UploadSlots } from './upload-slots.js';
|
||||
import {
|
||||
IMAGE_HEADER_MAX_BYTES,
|
||||
ImageInspector,
|
||||
ImageRejectedError,
|
||||
type ImageHeader,
|
||||
@@ -37,13 +41,13 @@ export type DirectUpload = {
|
||||
expires_at: string;
|
||||
};
|
||||
|
||||
const FIRST_RANGE_BYTES = 65_536;
|
||||
const MEDIA_TYPES = new Set(['image/png', 'image/jpeg']);
|
||||
|
||||
@Injectable()
|
||||
export class DirectUploadsService {
|
||||
private readonly maxUploadBytes: number;
|
||||
private readonly maxPixels: number;
|
||||
private readonly uploadTimeoutMs: number;
|
||||
private readonly ttlSeconds: number;
|
||||
private readonly maxPending: number;
|
||||
|
||||
@@ -53,9 +57,12 @@ export class DirectUploadsService {
|
||||
private readonly storage: ObjectStorage,
|
||||
private readonly chats: ChatsService,
|
||||
private readonly metrics: MetricsService,
|
||||
private readonly decoder: ImageDecoder,
|
||||
private readonly slots: UploadSlots,
|
||||
) {
|
||||
this.maxUploadBytes = config.getOrThrow('MAX_UPLOAD_BYTES');
|
||||
this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS');
|
||||
this.uploadTimeoutMs = config.getOrThrow('UPLOAD_TIMEOUT_MS');
|
||||
this.ttlSeconds = config.getOrThrow('DIRECT_UPLOAD_URL_TTL_SECONDS');
|
||||
this.maxPending = config.getOrThrow(
|
||||
'DIRECT_UPLOAD_MAX_PENDING_PER_USER',
|
||||
@@ -136,7 +143,10 @@ export class DirectUploadsService {
|
||||
);
|
||||
if (!row) throw new NotFoundException();
|
||||
if (row.status === 'ready') return toAttachment(row);
|
||||
return this.slots.run(user.id, () => this.verifyAndMarkReady(row));
|
||||
}
|
||||
|
||||
private async verifyAndMarkReady(row: AttachmentRow): Promise<Attachment> {
|
||||
const size = Number(row.size_bytes);
|
||||
const expectedChecksum = Buffer.from(
|
||||
row.sha256 as string,
|
||||
@@ -152,10 +162,9 @@ export class DirectUploadsService {
|
||||
);
|
||||
}
|
||||
|
||||
// Only the header is read: the signed checksum already pins every byte.
|
||||
let header: ImageHeader;
|
||||
try {
|
||||
header = await this.readHeader(row.object_key, size);
|
||||
header = await this.verifyObject(row.object_key, size);
|
||||
} catch (error) {
|
||||
if (error instanceof ImageRejectedError) {
|
||||
await this.reject(row);
|
||||
@@ -175,46 +184,62 @@ export class DirectUploadsService {
|
||||
width: header.width,
|
||||
height: header.height,
|
||||
});
|
||||
if (!ready) throw new ConflictException('Upload is no longer pending');
|
||||
if (!ready) {
|
||||
// A parallel complete of the same upload won: answer like a repeat.
|
||||
const current = await this.repository.findForComplete(
|
||||
row.id,
|
||||
row.owner_id,
|
||||
);
|
||||
if (current?.status === 'ready') return toAttachment(current);
|
||||
throw new ConflictException('Upload is no longer pending');
|
||||
}
|
||||
this.metrics.increment('attachments.direct.completed');
|
||||
return toAttachment(ready);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a small first range and widens it only when the header is not in it,
|
||||
* so the usual `complete` costs one short ranged GET. A range that covers the
|
||||
* whole object is also checked for structural completeness.
|
||||
* Reads the whole object: a correct signed checksum only proves that the
|
||||
* bytes are the ones the client declared, not that they form an image. The
|
||||
* stream goes through ImageInspector (structure, CRCs, completeness), then
|
||||
* the copy is fully decoded. Memory is bounded like a proxy upload.
|
||||
*/
|
||||
private async readHeader(key: string, size: number): Promise<ImageHeader> {
|
||||
const ceiling = Math.min(size, IMAGE_HEADER_MAX_BYTES);
|
||||
let range = Math.min(size, FIRST_RANGE_BYTES);
|
||||
for (;;) {
|
||||
const inspector = new ImageInspector(this.maxPixels);
|
||||
const stream = await this.storage.getStream(
|
||||
key,
|
||||
`bytes=0-${range - 1}`,
|
||||
);
|
||||
if (stream === null)
|
||||
throw new ConflictException('Upload has not been received');
|
||||
let verified = 0;
|
||||
try {
|
||||
for await (const chunk of stream as AsyncIterable<Buffer>) {
|
||||
verified += chunk.length;
|
||||
inspector.push(chunk);
|
||||
}
|
||||
} finally {
|
||||
stream.destroy();
|
||||
this.metrics.add('attachments.direct.verify_bytes', verified);
|
||||
private async verifyObject(
|
||||
key: string,
|
||||
size: number,
|
||||
): Promise<ImageHeader> {
|
||||
// Same deadline as a proxy upload: a slow or hung read releases its slot.
|
||||
const signal = AbortSignal.timeout(this.uploadTimeoutMs);
|
||||
const stream = await this.storage.getStream(key, signal);
|
||||
if (stream === null)
|
||||
throw new ConflictException('Upload has not been received');
|
||||
const inspector = new ImageInspector(this.maxPixels);
|
||||
const chunks: Buffer[] = [];
|
||||
let read = 0;
|
||||
try {
|
||||
for await (const chunk of stream as AsyncIterable<Buffer>) {
|
||||
read += chunk.length;
|
||||
if (read > size)
|
||||
throw new ImageRejectedError(
|
||||
'unsupported_media_type',
|
||||
'Object is larger than declared',
|
||||
);
|
||||
inspector.push(chunk);
|
||||
chunks.push(chunk);
|
||||
}
|
||||
if (range === size) return inspector.finish();
|
||||
if (inspector.header !== undefined) return inspector.header;
|
||||
if (range >= ceiling)
|
||||
throw new ImageRejectedError(
|
||||
'unsupported_media_type',
|
||||
'Image header is missing',
|
||||
);
|
||||
range = ceiling;
|
||||
} catch (error) {
|
||||
if (error instanceof ImageRejectedError) throw error;
|
||||
// The object stream broke mid-read (S3 outage, timeout): the image
|
||||
// was not judged, so this is an outage, not a client error.
|
||||
throw new ObjectStorageUnavailableError();
|
||||
} finally {
|
||||
stream.destroy();
|
||||
this.metrics.add('attachments.direct.verify_bytes', read);
|
||||
}
|
||||
const header = inspector.finish();
|
||||
const data = Buffer.concat(chunks, read);
|
||||
chunks.length = 0;
|
||||
await this.decoder.verify(data, signal);
|
||||
return header;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +248,9 @@ export class DirectUploadsService {
|
||||
* object that no row refers to. The sweeper removes both after expiry + grace.
|
||||
*/
|
||||
private async reject(row: AttachmentRow): Promise<void> {
|
||||
await this.repository.rejectPending(row.id);
|
||||
// Row first: a row that is not pending any more (ready after a parallel
|
||||
// complete, or claimed by the sweeper) keeps its object.
|
||||
if (!(await this.repository.rejectPending(row.id))) return;
|
||||
try {
|
||||
await this.storage.delete(row.object_key);
|
||||
} catch {
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { jpegWithoutScanData } from '../../../test/support/jpeg.js';
|
||||
import {
|
||||
maxPixelsRgba16Png,
|
||||
noisePng,
|
||||
pngWithGarbageIdat,
|
||||
} from '../../../test/support/png.js';
|
||||
import { ImageDecoder } from './image-decoder.js';
|
||||
import { ImageInspector, ImageRejectedError } from './image-inspector.js';
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url));
|
||||
const png = readFileSync(join(here, '../../../../tests/fixtures/sample.png'));
|
||||
const jpeg = readFileSync(join(here, '../../../test/fixtures/sample.jpg'));
|
||||
const progressive = readFileSync(
|
||||
join(here, '../../../test/fixtures/sample-progressive.jpg'),
|
||||
);
|
||||
|
||||
const settings: Record<string, number> = {
|
||||
MAX_IMAGE_PIXELS: 40_000_000,
|
||||
IMAGE_DECODE_MAX_CONCURRENT: 1,
|
||||
};
|
||||
const decoder = new ImageDecoder(
|
||||
{ getOrThrow: (key: string) => settings[key] } as never,
|
||||
{ increment: () => undefined, add: () => undefined } as never,
|
||||
);
|
||||
|
||||
describe('ImageDecoder', () => {
|
||||
it('accepts valid PNG and JPEG files, also concurrently', async () => {
|
||||
await Promise.all(
|
||||
[png, jpeg, progressive, noisePng(1_048_576)].map((data) =>
|
||||
decoder.verify(data),
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
// These files pass the structural inspector; only a decode catches them.
|
||||
it.each([
|
||||
['PNG with a garbage zlib stream', pngWithGarbageIdat()],
|
||||
['JPEG without scan data', jpegWithoutScanData(jpeg)],
|
||||
[
|
||||
'progressive JPEG without scan data',
|
||||
jpegWithoutScanData(progressive),
|
||||
],
|
||||
])('rejects a %s', async (_name, data) => {
|
||||
const inspector = new ImageInspector(40_000_000);
|
||||
inspector.push(data);
|
||||
expect(inspector.finish().width).toBe(320);
|
||||
await expect(decoder.verify(data)).rejects.toBeInstanceOf(
|
||||
ImageRejectedError,
|
||||
);
|
||||
});
|
||||
|
||||
it('accepts the heaviest valid input: 40 MP RGBA 16-bit', async () => {
|
||||
await decoder.verify(await maxPixelsRgba16Png());
|
||||
});
|
||||
|
||||
it('drops an aborted waiter from the queue without running its decode', async () => {
|
||||
const busy = decoder.verify(noisePng(4_000_000));
|
||||
const controller = new AbortController();
|
||||
const waiting = decoder.verify(png, controller.signal);
|
||||
controller.abort();
|
||||
await expect(waiting).rejects.toMatchObject({ status: 503 });
|
||||
await busy;
|
||||
// The slot was not leaked: the next decode runs.
|
||||
await decoder.verify(png);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
import {
|
||||
Injectable,
|
||||
InternalServerErrorException,
|
||||
Logger,
|
||||
ServiceUnavailableException,
|
||||
} from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import sharp from 'sharp';
|
||||
import type { AppConfig } from '../../config/app-config.schema.js';
|
||||
import { MetricsService } from '../../metrics/metrics.service.js';
|
||||
import { ImageRejectedError } from './image-inspector.js';
|
||||
|
||||
// One libvips worker per decode and no operation cache: decodes are one-off,
|
||||
// and memory must stay predictable under the per-replica limit.
|
||||
sharp.cache(false);
|
||||
sharp.concurrency(1);
|
||||
|
||||
// Failures of the replica itself, not of the image: they must not turn into a
|
||||
// client 415. libvips spills large images to a temp file unless
|
||||
// VIPS_DISC_THRESHOLD (compose.yaml) keeps them in memory; a full /tmp or an
|
||||
// allocation failure ends up here.
|
||||
const SERVER_FAULT =
|
||||
/no space left|out of memory|unable to allocate|cannot allocate|write failed|unable to open|tmp/iu;
|
||||
|
||||
/**
|
||||
* Full decode check. ImageInspector only proves the container structure
|
||||
* (signature, chunk CRCs, markers, dimensions); a PNG with a garbage zlib stream
|
||||
* or a JPEG without scan data passes it. Decoding every scanline with
|
||||
* failOn=warning rejects those, including truncated or corrupted compressed
|
||||
* data. A downscale to a thumbnail is the sink: it decodes all input but keeps
|
||||
* far less in memory than a full-size pipeline (measured in
|
||||
* evidence/lab4/decode-memory.txt). Decodes are bounded by
|
||||
* IMAGE_DECODE_MAX_CONCURRENT; a waiter whose request was aborted leaves the
|
||||
* queue and releases its buffer.
|
||||
*/
|
||||
@Injectable()
|
||||
export class ImageDecoder {
|
||||
private readonly logger = new Logger(ImageDecoder.name);
|
||||
private readonly maxPixels: number;
|
||||
private readonly maxConcurrent: number;
|
||||
private active = 0;
|
||||
private readonly waiting = new Set<() => void>();
|
||||
|
||||
constructor(
|
||||
config: ConfigService<AppConfig>,
|
||||
private readonly metrics: MetricsService,
|
||||
) {
|
||||
this.maxPixels = config.getOrThrow('MAX_IMAGE_PIXELS');
|
||||
this.maxConcurrent = config.getOrThrow('IMAGE_DECODE_MAX_CONCURRENT');
|
||||
}
|
||||
|
||||
async verify(data: Buffer, signal?: AbortSignal): Promise<void> {
|
||||
await this.acquire(signal);
|
||||
const started = performance.now();
|
||||
try {
|
||||
await sharp(data, {
|
||||
failOn: 'warning',
|
||||
sequentialRead: true,
|
||||
limitInputPixels: this.maxPixels,
|
||||
})
|
||||
.resize(64, 64, { fit: 'inside' })
|
||||
.toBuffer();
|
||||
} catch (error) {
|
||||
const message =
|
||||
error instanceof Error ? error.message : String(error);
|
||||
if (SERVER_FAULT.test(message)) {
|
||||
this.metrics.increment('attachments.decode.server_error');
|
||||
this.logger.error(
|
||||
`Image decode failed on the server: ${message}`,
|
||||
);
|
||||
throw new InternalServerErrorException();
|
||||
}
|
||||
this.metrics.increment('attachments.decode.rejected');
|
||||
throw new ImageRejectedError(
|
||||
'unsupported_media_type',
|
||||
'Image data cannot be decoded',
|
||||
);
|
||||
} finally {
|
||||
this.metrics.add(
|
||||
'attachments.decode.ms',
|
||||
performance.now() - started,
|
||||
);
|
||||
this.release();
|
||||
}
|
||||
}
|
||||
|
||||
private acquire(signal?: AbortSignal): Promise<void> {
|
||||
const abandoned = new ServiceUnavailableException(
|
||||
'Image check was abandoned',
|
||||
);
|
||||
if (signal?.aborted) return Promise.reject(abandoned);
|
||||
if (this.active < this.maxConcurrent) {
|
||||
this.active += 1;
|
||||
return Promise.resolve();
|
||||
}
|
||||
const { promise, resolve, reject } = Promise.withResolvers<void>();
|
||||
const cancel = () => {
|
||||
this.waiting.delete(grant);
|
||||
reject(abandoned);
|
||||
};
|
||||
const grant = () => {
|
||||
signal?.removeEventListener('abort', cancel);
|
||||
resolve();
|
||||
};
|
||||
this.waiting.add(grant);
|
||||
signal?.addEventListener('abort', cancel, { once: true });
|
||||
return promise;
|
||||
}
|
||||
|
||||
private release(): void {
|
||||
const next = this.waiting.values().next();
|
||||
if (next.done) {
|
||||
this.active -= 1;
|
||||
return;
|
||||
}
|
||||
this.waiting.delete(next.value);
|
||||
next.value();
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
import { crc32 } from 'node:zlib';
|
||||
|
||||
export const IMAGE_HEADER_MAX_BYTES = 1_048_576;
|
||||
|
||||
export type ImageHeader = {
|
||||
contentType: 'image/png' | 'image/jpeg';
|
||||
width: number;
|
||||
@@ -59,7 +57,9 @@ function unsupported(message: string): ImageRejectedError {
|
||||
/**
|
||||
* Streaming structural validator for PNG and JPEG. It never buffers the body:
|
||||
* only fixed-size fields (chunk headers, IHDR, SOF) are accumulated, and
|
||||
* nothing is decompressed.
|
||||
* nothing is decompressed. It is the early gate (type, dimensions, pixel limit
|
||||
* before anything is stored), not proof of a valid image: compressed pixel
|
||||
* data is checked by ImageDecoder.
|
||||
*/
|
||||
export class ImageInspector {
|
||||
private state: State = 'start';
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/** Request of the upload route; see the onRequest hook in main.ts. */
|
||||
export type UploadRequest = {
|
||||
method: string;
|
||||
routeOptions?: { url?: string };
|
||||
headers: Record<string, string | string[] | undefined>;
|
||||
/** Content-Type as sent by the client (the header itself is rewritten). */
|
||||
uploadContentType?: string | string[];
|
||||
body?: unknown;
|
||||
};
|
||||
@@ -0,0 +1,54 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { UploadSlots } from './upload-slots.js';
|
||||
|
||||
const slots = (max: number, perUser: number) =>
|
||||
new UploadSlots({
|
||||
getOrThrow: (key: string) =>
|
||||
key === 'UPLOAD_MAX_IN_FLIGHT' ? max : perUser,
|
||||
} as never);
|
||||
|
||||
function hold() {
|
||||
const { promise, resolve } = Promise.withResolvers<void>();
|
||||
return { work: () => promise, release: resolve };
|
||||
}
|
||||
|
||||
describe('UploadSlots', () => {
|
||||
it('caps one user without starving others, and frees slots after work', async () => {
|
||||
const limiter = slots(10, 2);
|
||||
const held = [hold(), hold()];
|
||||
const running = held.map((h) => limiter.run('a', h.work));
|
||||
await expect(limiter.run('a', async () => 'x')).rejects.toMatchObject({
|
||||
status: 429,
|
||||
});
|
||||
await expect(limiter.run('b', async () => 'ok')).resolves.toBe('ok');
|
||||
held.forEach((h) => h.release());
|
||||
await Promise.all(running);
|
||||
await expect(limiter.run('a', async () => 'again')).resolves.toBe(
|
||||
'again',
|
||||
);
|
||||
});
|
||||
|
||||
it('applies the replica-wide cap across users', async () => {
|
||||
const limiter = slots(2, 2);
|
||||
const held = [hold(), hold()];
|
||||
const running = [
|
||||
limiter.run('a', held[0].work),
|
||||
limiter.run('b', held[1].work),
|
||||
];
|
||||
await expect(limiter.run('c', async () => 'x')).rejects.toMatchObject({
|
||||
status: 429,
|
||||
});
|
||||
held.forEach((h) => h.release());
|
||||
await Promise.all(running);
|
||||
});
|
||||
|
||||
it('releases a slot when the work fails', async () => {
|
||||
const limiter = slots(1, 1);
|
||||
await expect(
|
||||
limiter.run('a', async () => {
|
||||
throw new Error('boom');
|
||||
}),
|
||||
).rejects.toThrow('boom');
|
||||
await expect(limiter.run('a', async () => 'ok')).resolves.toBe('ok');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,41 @@
|
||||
import { HttpException, Injectable } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import type { AppConfig } from '../config/app-config.schema.js';
|
||||
|
||||
/**
|
||||
* Per-replica caps on requests that hold an image in memory (proxy upload,
|
||||
* direct complete): each may keep up to MAX_UPLOAD_BYTES for the decode check.
|
||||
* The per-user cap keeps one client (e.g. slow senders holding slots until
|
||||
* UPLOAD_TIMEOUT_MS) from starving everyone else.
|
||||
*/
|
||||
@Injectable()
|
||||
export class UploadSlots {
|
||||
private inFlight = 0;
|
||||
private readonly perUser = new Map<string, number>();
|
||||
private readonly max: number;
|
||||
private readonly maxPerUser: number;
|
||||
|
||||
constructor(config: ConfigService<AppConfig>) {
|
||||
this.max = config.getOrThrow('UPLOAD_MAX_IN_FLIGHT');
|
||||
this.maxPerUser = config.getOrThrow('UPLOAD_MAX_IN_FLIGHT_PER_USER');
|
||||
}
|
||||
|
||||
async run<T>(userId: string, work: () => Promise<T>): Promise<T> {
|
||||
const mine = this.perUser.get(userId) ?? 0;
|
||||
if (this.inFlight >= this.max || mine >= this.maxPerUser)
|
||||
throw new HttpException(
|
||||
{ message: 'Too many concurrent uploads', retryAfter: 1 },
|
||||
429,
|
||||
);
|
||||
this.inFlight += 1;
|
||||
this.perUser.set(userId, mine + 1);
|
||||
try {
|
||||
return await work();
|
||||
} finally {
|
||||
this.inFlight -= 1;
|
||||
const left = (this.perUser.get(userId) ?? 1) - 1;
|
||||
if (left === 0) this.perUser.delete(userId);
|
||||
else this.perUser.set(userId, left);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,7 +85,19 @@ export const appConfigSchema = z
|
||||
MAX_UPLOAD_BYTES: numeric('MAX_UPLOAD_BYTES', 1, 10485760, 10485760),
|
||||
MAX_IMAGE_PIXELS: numeric('MAX_IMAGE_PIXELS', 1, 40000000, 40000000),
|
||||
UPLOAD_TIMEOUT_MS: numeric('UPLOAD_TIMEOUT_MS', 1000, undefined, 25000),
|
||||
UPLOAD_MAX_IN_FLIGHT: numeric('UPLOAD_MAX_IN_FLIGHT', 1, 1024, 32),
|
||||
UPLOAD_MAX_IN_FLIGHT: numeric('UPLOAD_MAX_IN_FLIGHT', 1, 1024, 16),
|
||||
UPLOAD_MAX_IN_FLIGHT_PER_USER: numeric(
|
||||
'UPLOAD_MAX_IN_FLIGHT_PER_USER',
|
||||
1,
|
||||
1024,
|
||||
4,
|
||||
),
|
||||
IMAGE_DECODE_MAX_CONCURRENT: numeric(
|
||||
'IMAGE_DECODE_MAX_CONCURRENT',
|
||||
1,
|
||||
64,
|
||||
1,
|
||||
),
|
||||
// 0 отключает фоновый проход уборщика (остаётся ручной CLI).
|
||||
ATTACHMENT_SWEEP_INTERVAL_MS: numeric(
|
||||
'ATTACHMENT_SWEEP_INTERVAL_MS',
|
||||
|
||||
+27
-43
@@ -1,12 +1,8 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { HttpAdapterHost } from '@nestjs/core';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import {
|
||||
PayloadTooLargeException,
|
||||
UnsupportedMediaTypeException,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common';
|
||||
import type { Readable } from 'node:stream';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import type { UploadRequest } from './attachments/upload-request.js';
|
||||
import {
|
||||
FastifyAdapter,
|
||||
NestFastifyApplication,
|
||||
@@ -16,53 +12,41 @@ import { HealthService } from './health/health.service.js';
|
||||
import { MetricsService } from './metrics/metrics.service.js';
|
||||
import { RequestIdInterceptor } from './common/http/request-id.interceptor.js';
|
||||
|
||||
const TEXT_BODY_LIMIT = 1_048_576;
|
||||
const UPLOAD_ROUTE = '/api/v1/chats/:chatId/attachments';
|
||||
const UPLOAD_STREAM_TYPE = 'application/x-messenger-upload-stream';
|
||||
|
||||
async function bootstrap(): Promise<void> {
|
||||
const app = await NestFactory.create<NestFastifyApplication>(
|
||||
AppModule,
|
||||
new FastifyAdapter({ logger: true }),
|
||||
);
|
||||
// Raw image bodies reach the controller as an unread stream: the upload is
|
||||
// bounded by our own checks, not by Fastify's bodyLimit. A stream may reach
|
||||
// only the upload route: on JSON routes it would hit the ValidationPipe and
|
||||
// overflow the stack there, so other routes keep the pre-upload behavior.
|
||||
// The upload route receives its body as an unread stream whatever the
|
||||
// declared Content-Type: the service checks the type itself, after the
|
||||
// auth guard (401 before 415, contracts/README.md), and bounds the body by
|
||||
// its own limits, not Fastify's bodyLimit. The declared type is kept on the
|
||||
// request; all other routes keep Fastify's parsers untouched.
|
||||
const fastify = app.getHttpAdapter().getInstance();
|
||||
type ParserRequest = { method: string; routeOptions?: { url?: string } };
|
||||
type Done = (error: Error | null, body?: unknown) => void;
|
||||
const isUpload = (request: ParserRequest) =>
|
||||
request.method === 'POST' && request.routeOptions?.url === UPLOAD_ROUTE;
|
||||
fastify.addContentTypeParser(
|
||||
['image/png', 'image/jpeg'],
|
||||
(request: ParserRequest, payload: unknown, done: Done) =>
|
||||
isUpload(request)
|
||||
? done(null, payload)
|
||||
: done(new UnsupportedMediaTypeException()),
|
||||
);
|
||||
// Fastify's built-in text/plain parser buffers the body and fails binary
|
||||
// input with 400; on the upload route the service answers 415 instead.
|
||||
// Elsewhere text/plain keeps being buffered as a string (1 MiB cap).
|
||||
fastify.removeContentTypeParser('text/plain');
|
||||
fastify.addContentTypeParser(
|
||||
'text/plain',
|
||||
(request: ParserRequest, payload: Readable, done: Done) => {
|
||||
if (isUpload(request)) return done(null, payload);
|
||||
const chunks: Buffer[] = [];
|
||||
let size = 0;
|
||||
payload.on('data', (chunk: Buffer) => {
|
||||
size += chunk.length;
|
||||
if (size > TEXT_BODY_LIMIT) {
|
||||
payload.destroy();
|
||||
done(new PayloadTooLargeException());
|
||||
} else chunks.push(chunk);
|
||||
});
|
||||
payload.on('end', () =>
|
||||
done(null, Buffer.concat(chunks).toString('utf8')),
|
||||
);
|
||||
payload.on('error', (error: Error) => done(error));
|
||||
fastify.addHook(
|
||||
'onRequest',
|
||||
(request: UploadRequest, _reply: unknown, done: () => void) => {
|
||||
if (
|
||||
request.method === 'POST' &&
|
||||
request.routeOptions?.url === UPLOAD_ROUTE
|
||||
) {
|
||||
request.uploadContentType = request.headers['content-type'];
|
||||
request.headers['content-type'] = UPLOAD_STREAM_TYPE;
|
||||
}
|
||||
done();
|
||||
},
|
||||
);
|
||||
fastify.addContentTypeParser(
|
||||
UPLOAD_STREAM_TYPE,
|
||||
(
|
||||
_request: unknown,
|
||||
payload: unknown,
|
||||
done: (error: Error | null, body?: unknown) => void,
|
||||
) => done(null, payload),
|
||||
);
|
||||
app.useGlobalInterceptors(
|
||||
new RequestIdInterceptor(
|
||||
app.get(HttpAdapterHost),
|
||||
|
||||
@@ -62,9 +62,15 @@ export class ObjectStorage {
|
||||
maxAttempts: 1,
|
||||
requestChecksumCalculation: 'WHEN_REQUIRED' as const,
|
||||
responseChecksumValidation: 'WHEN_REQUIRED' as const,
|
||||
// requestTimeout bounds a request until its response arrives and,
|
||||
// with throwOnRequestTimeout, actually fails it (otherwise smithy
|
||||
// only logs a warning); socketTimeout bounds a stalled body read.
|
||||
// A hung S3 therefore costs at most S3_REQUEST_TIMEOUT_MS per call.
|
||||
requestHandler: new NodeHttpHandler({
|
||||
connectionTimeout: config.getOrThrow('S3_CONNECT_TIMEOUT_MS'),
|
||||
requestTimeout: config.getOrThrow('S3_REQUEST_TIMEOUT_MS'),
|
||||
throwOnRequestTimeout: true,
|
||||
socketTimeout: config.getOrThrow('S3_REQUEST_TIMEOUT_MS'),
|
||||
httpAgent: new http.Agent({ keepAlive: true, maxSockets: 64 }),
|
||||
}),
|
||||
};
|
||||
@@ -99,21 +105,23 @@ export class ObjectStorage {
|
||||
ContentLength: contentLength,
|
||||
ContentType: contentType,
|
||||
}),
|
||||
{ abortSignal: signal },
|
||||
// The upload deadline (UPLOAD_TIMEOUT_MS, via `signal`) bounds the
|
||||
// PUT: it lasts as long as the client sends, not S3_REQUEST_TIMEOUT_MS.
|
||||
{ abortSignal: signal, requestTimeout: 0 },
|
||||
);
|
||||
} catch (error) {
|
||||
throw this.fail('put', error);
|
||||
}
|
||||
}
|
||||
|
||||
async getStream(key: string, range?: string): Promise<Readable | null> {
|
||||
async getStream(
|
||||
key: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<Readable | null> {
|
||||
try {
|
||||
const result = await this.internal.send(
|
||||
new GetObjectCommand({
|
||||
Bucket: this.bucket,
|
||||
Key: key,
|
||||
Range: range,
|
||||
}),
|
||||
new GetObjectCommand({ Bucket: this.bucket, Key: key }),
|
||||
{ abortSignal: signal },
|
||||
);
|
||||
return result.Body as Readable;
|
||||
} catch (error) {
|
||||
|
||||
@@ -21,7 +21,15 @@ import {
|
||||
upload,
|
||||
uploadRaw,
|
||||
} from './support/e2e.js';
|
||||
import { noisePng, padPngTo, pixelBombPng } from './support/png.js';
|
||||
import sharp from 'sharp';
|
||||
import { jpegWithMetadata, jpegWithoutScanData } from './support/jpeg.js';
|
||||
import {
|
||||
maxPixelsRgba16Png,
|
||||
noisePng,
|
||||
padPngTo,
|
||||
pixelBombPng,
|
||||
pngWithGarbageIdat,
|
||||
} from './support/png.js';
|
||||
|
||||
const png = readFileSync(
|
||||
new URL('../../tests/fixtures/sample.png', import.meta.url),
|
||||
@@ -140,6 +148,106 @@ describe('attachments (proxy upload)', () => {
|
||||
expect(content.bytes.equals(data)).toBe(true);
|
||||
});
|
||||
|
||||
it('accepts camera-size images up to the pixel limit', async () => {
|
||||
// 7728x5152 = 39.8 MP, like a 40 MP camera; decoded size far above the
|
||||
// replica's 16 MiB /tmp, so libvips must not spill to a temp file.
|
||||
const camera = sharp({
|
||||
create: {
|
||||
width: 7728,
|
||||
height: 5152,
|
||||
channels: 3,
|
||||
background: { r: 120, g: 80, b: 40 },
|
||||
},
|
||||
});
|
||||
const baseline = await camera.clone().jpeg({ quality: 85 }).toBuffer();
|
||||
const progressiveCamera = await camera
|
||||
.clone()
|
||||
.jpeg({ quality: 85, progressive: true })
|
||||
.toBuffer();
|
||||
for (const data of [baseline, progressiveCamera])
|
||||
expect((await ready(data, 'image/jpeg')).size_bytes).toBe(
|
||||
data.length,
|
||||
);
|
||||
const rgba16 = await maxPixelsRgba16Png();
|
||||
expect((await ready(rgba16)).size_bytes).toBe(rgba16.length);
|
||||
}, 120_000);
|
||||
|
||||
it('accepts a JPEG with megabytes of metadata before the frame header', async () => {
|
||||
const data = jpegWithMetadata(jpeg, 20);
|
||||
expect(data.length).toBeGreaterThan(1_048_576);
|
||||
expect((await ready(data, 'image/jpeg')).sha256).toBe(sha256(data));
|
||||
});
|
||||
|
||||
it('authenticates before judging the content type', async () => {
|
||||
const zip = await http<ApiErrorBody>(
|
||||
`/api/v1/chats/${chatId}/attachments?filename=a.zip`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/zip' },
|
||||
body: png as unknown as BodyInit,
|
||||
},
|
||||
);
|
||||
expectError(zip, 401, 'unauthorized');
|
||||
expectError(
|
||||
await upload(alice.token, leftoverChatId, png, {
|
||||
contentType: 'application/json',
|
||||
}),
|
||||
415,
|
||||
'unsupported_media_type',
|
||||
);
|
||||
});
|
||||
|
||||
it('answers 413 with the error envelope to an oversized text body on JSON routes', async () => {
|
||||
const result = await http<ApiErrorBody>(
|
||||
`/api/v1/chats/${chatId}/messages`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...bearer(alice.token),
|
||||
'content-type': 'text/plain',
|
||||
'idempotency-key': randomUUID().replaceAll('-', ''),
|
||||
},
|
||||
body: 'x'.repeat(2_100_000),
|
||||
},
|
||||
);
|
||||
expectError(result, 413, 'payload_too_large');
|
||||
});
|
||||
|
||||
it('keeps one slow client from taking every upload slot', async () => {
|
||||
const slow = await actor();
|
||||
const slowChat = (await createChat(slow, [])).id;
|
||||
const url = new URL(baseUrl);
|
||||
const sockets: net.Socket[] = [];
|
||||
try {
|
||||
for (let index = 0; index < 12; index += 1) {
|
||||
const socket = net.connect(
|
||||
Number(url.port || 80),
|
||||
url.hostname,
|
||||
);
|
||||
socket.on('error', () => {});
|
||||
socket.write(
|
||||
`POST /api/v1/chats/${slowChat}/attachments?filename=slow.png HTTP/1.1\r\n` +
|
||||
`Host: ${url.host}\r\nAuthorization: Bearer ${slow.token}\r\n` +
|
||||
`Content-Type: image/png\r\nContent-Length: ${png.length}\r\n\r\n`,
|
||||
);
|
||||
socket.write(png.subarray(0, 4));
|
||||
sockets.push(socket);
|
||||
}
|
||||
await sleep(1000);
|
||||
const extra = await upload(slow.token, slowChat, png);
|
||||
expectError(extra, 429, 'rate_limited');
|
||||
expect(extra.response.headers.get('retry-after')).toBe('1');
|
||||
// Another user is not affected by the slow client.
|
||||
for (let index = 0; index < 4; index += 1)
|
||||
expect(
|
||||
(await upload(bob.token, chatId, png)).response.status,
|
||||
).toBe(201);
|
||||
} finally {
|
||||
for (const socket of sockets) socket.destroy();
|
||||
}
|
||||
await settled(slowChat);
|
||||
});
|
||||
|
||||
it('enforces the 10 MiB limit exactly', async () => {
|
||||
const exact = padPngTo(png, MAX);
|
||||
const created = await ready(exact);
|
||||
@@ -167,6 +275,8 @@ describe('attachments (proxy upload)', () => {
|
||||
flipped,
|
||||
Buffer.concat([png.subarray(0, 8), randomBytes(2048)]),
|
||||
Buffer.alloc(0),
|
||||
// Structure and CRCs are fine; the pixel data does not decode.
|
||||
pngWithGarbageIdat(),
|
||||
];
|
||||
for (const data of cases)
|
||||
expectError(
|
||||
@@ -176,6 +286,24 @@ describe('attachments (proxy upload)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['baseline', jpeg],
|
||||
['progressive', progressive],
|
||||
])('rejects a %s JPEG without scan data', async (_name, data) => {
|
||||
expectError(
|
||||
await upload(
|
||||
alice.token,
|
||||
leftoverChatId,
|
||||
jpegWithoutScanData(data),
|
||||
{
|
||||
contentType: 'image/jpeg',
|
||||
},
|
||||
),
|
||||
415,
|
||||
'unsupported_media_type',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a content type that does not match the bytes', async () => {
|
||||
const gif = Buffer.from('GIF89a' + 'x'.repeat(64));
|
||||
const cases: [Buffer, string][] = [
|
||||
|
||||
@@ -602,6 +602,10 @@ describe.skipIf(!enabled)('dependency outages', () => {
|
||||
await compose('start', redisService);
|
||||
await compose('start', postgresService);
|
||||
await compose('start', s3Service);
|
||||
const s3Container = (await compose('ps', '-q', s3Service)).split(
|
||||
'\n',
|
||||
)[0];
|
||||
await docker('unpause', s3Container).catch(() => undefined);
|
||||
await waitForReadiness(200);
|
||||
await restoreDatabaseAccess();
|
||||
const expected = (await apiContainers()).length;
|
||||
@@ -944,12 +948,13 @@ describe.skipIf(!enabled)('dependency outages', () => {
|
||||
expect((await request('/health/ready')).response.status).toBe(
|
||||
200,
|
||||
);
|
||||
// Compensation could not reach S3, so the row stays for the sweeper.
|
||||
// Compensation claimed the row but could not delete the object:
|
||||
// the row stays in `deleting`, tracked for the sweeper.
|
||||
expect(
|
||||
await psql(
|
||||
`select count(*) from attachments where chat_id = '${chat.id}' and status = 'pending' and filename = 's3down-${runId}.png'`,
|
||||
`select status from attachments where chat_id = '${chat.id}' and filename = 's3down-${runId}.png'`,
|
||||
),
|
||||
).toBe('1');
|
||||
).toBe('deleting');
|
||||
} finally {
|
||||
await compose('start', s3Service);
|
||||
}
|
||||
@@ -966,18 +971,83 @@ describe.skipIf(!enabled)('dependency outages', () => {
|
||||
const after = await upload(samplePng, `s3after-${runId}.png`);
|
||||
expect(after.response.status).toBe(201);
|
||||
|
||||
const filter = `chat_id = '${chat.id}' and status = 'pending' and filename = 's3down-${runId}.png'`;
|
||||
await waitUntilExpired(filter);
|
||||
await sweepNow();
|
||||
expect(
|
||||
await psql(`select count(*) from attachments where ${filter}`),
|
||||
).toBe('0');
|
||||
// A `deleting` row is re-claimed one minute after its last change
|
||||
// (an in-flight compensation is never raced), then swept.
|
||||
const filter = `chat_id = '${chat.id}' and filename = 's3down-${runId}.png'`;
|
||||
await waitFor(
|
||||
async () => {
|
||||
await sweepNow();
|
||||
return (
|
||||
(await psql(
|
||||
`select count(*) from attachments where ${filter}`,
|
||||
)) === '0'
|
||||
);
|
||||
},
|
||||
async () => 'deleting row was not swept',
|
||||
90_000,
|
||||
);
|
||||
},
|
||||
outagedRequestBudgetMs,
|
||||
);
|
||||
|
||||
it(
|
||||
'compensates the S3 write when PostgreSQL fails before ready',
|
||||
'bounds requests by S3_REQUEST_TIMEOUT_MS when S3 hangs instead of refusing',
|
||||
async () => {
|
||||
const created = await request<{ id: string }>(
|
||||
uploadPath(chat.id, `hang-${runId}.png`),
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...bearer(token), 'content-type': 'image/png' },
|
||||
body: samplePng as unknown as BodyInit,
|
||||
},
|
||||
);
|
||||
expect(created.response.status).toBe(201);
|
||||
// A paused container keeps its TCP port open but never answers: the
|
||||
// failure mode a stopped container (connection refused) does not show.
|
||||
const container = (await compose('ps', '-q', s3Service)).split(
|
||||
'\n',
|
||||
)[0];
|
||||
await docker('pause', container);
|
||||
try {
|
||||
const started = Date.now();
|
||||
const content = await request<ApiErrorBody>(
|
||||
`/api/v1/attachments/${created.body.id}/content`,
|
||||
{ headers: bearer(token) },
|
||||
);
|
||||
const elapsed = Date.now() - started;
|
||||
expectBoundedOutage(content);
|
||||
// S3_REQUEST_TIMEOUT_MS is 15 s in the stand; HAProxy gives up at 30 s.
|
||||
expect(elapsed).toBeLessThan(20_000);
|
||||
expect(
|
||||
(
|
||||
await request(
|
||||
`/api/v1/attachments/${created.body.id}`,
|
||||
{
|
||||
headers: bearer(token),
|
||||
},
|
||||
)
|
||||
).response.status,
|
||||
).toBe(200);
|
||||
expect((await request('/health/ready')).response.status).toBe(
|
||||
200,
|
||||
);
|
||||
} finally {
|
||||
await docker('unpause', container);
|
||||
}
|
||||
const bytes = await fetch(
|
||||
`${baseUrl}/api/v1/attachments/${created.body.id}/content`,
|
||||
{ headers: bearer(token) },
|
||||
);
|
||||
expect(bytes.status).toBe(200);
|
||||
expect(
|
||||
Buffer.from(await bytes.arrayBuffer()).equals(samplePng),
|
||||
).toBe(true);
|
||||
},
|
||||
outagedRequestBudgetMs,
|
||||
);
|
||||
|
||||
it(
|
||||
'keeps the object while PostgreSQL is down before ready and sweeps it afterwards',
|
||||
async () => {
|
||||
const data = noisePng(1024 * 1024);
|
||||
const filename = `pgfault-${runId}.png`;
|
||||
@@ -1017,13 +1087,16 @@ describe.skipIf(!enabled)('dependency outages', () => {
|
||||
`select object_key from attachments where ${filter}`,
|
||||
);
|
||||
expect(key).toMatch(/^attachments\/[0-9a-f-]{36}\/original$/u);
|
||||
expect(await objectExists(key)).toBe(false);
|
||||
// Without PostgreSQL the API cannot tell a lost commit from a failed
|
||||
// one, so it deletes nothing; the pending row keeps the object tracked.
|
||||
expect(await objectExists(key)).toBe(true);
|
||||
|
||||
await waitUntilExpired(filter);
|
||||
await sweepNow();
|
||||
expect(
|
||||
await psql(`select count(*) from attachments where ${filter}`),
|
||||
).toBe('0');
|
||||
expect(await objectExists(key)).toBe(false);
|
||||
},
|
||||
outagedRequestBudgetMs,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
json,
|
||||
postMessage,
|
||||
} from './support/e2e.js';
|
||||
import { pixelBombPng } from './support/png.js';
|
||||
import { noisePng, pixelBombPng } from './support/png.js';
|
||||
|
||||
const png = readFileSync(
|
||||
new URL('../../tests/fixtures/sample.png', import.meta.url),
|
||||
@@ -160,6 +160,21 @@ describe('direct upload (presigned PUT)', () => {
|
||||
expect(sent.body.attachment_ids).toEqual([ticket.attachment_id]);
|
||||
});
|
||||
|
||||
it('answers 200 to every parallel complete of one upload', async () => {
|
||||
const ticket = await initOk(png);
|
||||
expect((await put(ticket, png)).status).toBe(200);
|
||||
const results = await Promise.all(
|
||||
Array.from({ length: 4 }, () =>
|
||||
complete(alice.token, ticket.attachment_id),
|
||||
),
|
||||
);
|
||||
expect(results.map((result) => result.response.status)).toEqual([
|
||||
200, 200, 200, 200,
|
||||
]);
|
||||
for (const result of results)
|
||||
expect(result.body.id).toBe(ticket.attachment_id);
|
||||
});
|
||||
|
||||
it('rejects invalid declarations', async () => {
|
||||
const base = declaration(png);
|
||||
expectError(await init(eve.token, chatId, base), 404, 'not_found');
|
||||
@@ -243,6 +258,34 @@ describe('direct upload (presigned PUT)', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it.each([
|
||||
['truncated PNG', () => png.subarray(0, png.length - 100)],
|
||||
[
|
||||
'PNG damaged after the first 64 KiB',
|
||||
() => {
|
||||
const data = noisePng(1_048_576);
|
||||
data[700_000] ^= 0xff;
|
||||
return data;
|
||||
},
|
||||
],
|
||||
])('rejects a %s even with a matching checksum', async (_name, make) => {
|
||||
// The declaration and the signed checksum match the bytes exactly:
|
||||
// only a check of the whole image can tell they are not an image.
|
||||
const data = make();
|
||||
const ticket = await initOk(data);
|
||||
expect((await put(ticket, data)).status).toBe(200);
|
||||
expectError(
|
||||
await complete(alice.token, ticket.attachment_id),
|
||||
415,
|
||||
'unsupported_media_type',
|
||||
);
|
||||
expectError(
|
||||
await complete(alice.token, ticket.attachment_id),
|
||||
404,
|
||||
'not_found',
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a pixel bomb on complete', async () => {
|
||||
const bomb = pixelBombPng();
|
||||
const ticket = await initOk(bomb);
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/** Keeps every segment through the SOS header and drops the scan data. */
|
||||
export function jpegWithoutScanData(jpeg: Buffer): Buffer {
|
||||
let offset = 2;
|
||||
for (;;) {
|
||||
const marker = jpeg[offset + 1];
|
||||
offset += 2 + jpeg.readUInt16BE(offset + 2);
|
||||
if (marker === 0xda) break;
|
||||
}
|
||||
return Buffer.concat([jpeg.subarray(0, offset), Buffer.from([0xff, 0xd9])]);
|
||||
}
|
||||
|
||||
/** Inserts `count` APP13 segments of ~64 KiB right after SOI (Photoshop-style metadata). */
|
||||
export function jpegWithMetadata(jpeg: Buffer, count: number): Buffer {
|
||||
const payload = Buffer.alloc(65_533, 0x20);
|
||||
const segment = Buffer.concat([
|
||||
Buffer.from([0xff, 0xed, 0xff, 0xff]),
|
||||
payload,
|
||||
]);
|
||||
return Buffer.concat([
|
||||
jpeg.subarray(0, 2),
|
||||
...Array.from({ length: count }, () => segment),
|
||||
jpeg.subarray(2),
|
||||
]);
|
||||
}
|
||||
+46
-1
@@ -1,5 +1,6 @@
|
||||
import { randomBytes } from 'node:crypto';
|
||||
import { crc32, deflateSync } from 'node:zlib';
|
||||
import { once } from 'node:events';
|
||||
import { crc32, createDeflate, deflateSync } from 'node:zlib';
|
||||
|
||||
const SIGNATURE = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
|
||||
|
||||
@@ -93,3 +94,47 @@ export function noisePng(size: number): Buffer {
|
||||
return padPngTo(png, size);
|
||||
}
|
||||
}
|
||||
|
||||
/** Valid signature, IHDR, CRCs and IEND around a zlib stream of random bytes. */
|
||||
export function pngWithGarbageIdat(): Buffer {
|
||||
return buildPng({
|
||||
width: 320,
|
||||
height: 200,
|
||||
colorType: 2,
|
||||
bitDepth: 8,
|
||||
idat: randomBytes(5000),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 8000x5000 RGBA 16-bit (8 bytes/pixel, 40 000 000 px — the pixel limit):
|
||||
* the heaviest decode a valid upload can ask for. Rows are streamed into the
|
||||
* compressor, so the 320 MB raw image is never allocated here.
|
||||
*/
|
||||
export async function maxPixelsRgba16Png(): Promise<Buffer> {
|
||||
const width = 8000;
|
||||
const height = 5000;
|
||||
// First row: a gradient; every next row uses filter "Up" with zero
|
||||
// deltas, i.e. repeats it — a valid image that compresses well.
|
||||
const first = Buffer.alloc(1 + width * 8);
|
||||
for (let x = 0; x < width; x += 1)
|
||||
first.writeUInt16BE((x * 8) & 0xffff, 1 + x * 8);
|
||||
const repeat = Buffer.alloc(1 + width * 8);
|
||||
repeat[0] = 2;
|
||||
const deflate = createDeflate({ level: 1 });
|
||||
const chunks: Buffer[] = [];
|
||||
deflate.on('data', (chunk: Buffer) => chunks.push(chunk));
|
||||
const ended = once(deflate, 'end');
|
||||
for (let y = 0; y < height; y += 1)
|
||||
if (!deflate.write(y === 0 ? first : repeat))
|
||||
await once(deflate, 'drain');
|
||||
deflate.end();
|
||||
await ended;
|
||||
return buildPng({
|
||||
width,
|
||||
height,
|
||||
colorType: 6,
|
||||
bitDepth: 16,
|
||||
idat: Buffer.concat(chunks),
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2023",
|
||||
"target": "ES2024",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"incremental": true,
|
||||
|
||||
+4
-1
@@ -169,6 +169,9 @@ services:
|
||||
DIRECT_UPLOAD_URL_TTL_SECONDS: ${DIRECT_UPLOAD_URL_TTL_SECONDS:-300}
|
||||
ATTACHMENT_SWEEP_GRACE_SECONDS: ${ATTACHMENT_SWEEP_GRACE_SECONDS:-900}
|
||||
ATTACHMENT_SWEEP_INTERVAL_MS: ${ATTACHMENT_SWEEP_INTERVAL_MS:-60000}
|
||||
# libvips держит декодируемое изображение в памяти, а не во временном
|
||||
# файле: /tmp — tmpfs 16 MiB, и изображение ~40 Мп туда не помещается.
|
||||
VIPS_DISC_THRESHOLD: ${VIPS_DISC_THRESHOLD:-1g}
|
||||
secrets: [s3_api_access_key_id, s3_api_secret_access_key]
|
||||
# Корневая ФС только для чтения: локального файла оригинала на API нет.
|
||||
read_only: true
|
||||
@@ -178,7 +181,7 @@ services:
|
||||
resources:
|
||||
limits:
|
||||
cpus: '${API_CPUS_PER_REPLICA:-1.5}'
|
||||
memory: ${API_MEMORY_PER_REPLICA:-768m}
|
||||
memory: ${API_MEMORY_PER_REPLICA:-1024m}
|
||||
stop_grace_period: 20s
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"openapi": "3.1.0",
|
||||
"info": {
|
||||
"title": "MTUSI Messenger — расширение lab4: прямая загрузка",
|
||||
"version": "1.4.0-ext.1",
|
||||
"description": "Трек 1. Не меняет обязательный контракт openapi.json: POST /api/v1/chats/{chat_id}/attachments остаётся основным путём. Клиент получает presigned PUT URL и отправляет байты прямо в приватный bucket MinIO, минуя API. Подписаны заголовки content-type, content-length и x-amz-checksum-sha256: хранилище само отвергает тело с другим размером (403 SignatureDoesNotMatch) или другим SHA-256 (400 XAmzContentChecksumMismatch), объект при этом не создаётся. TTL URL — DIRECT_UPLOAD_URL_TTL_SECONDS (300 с по умолчанию). Ключ объекта attachments/<attachment_id>/original раскрывает только UUID вложения; bucket приватный, анонимный доступ запрещён. Незавершённые заявки и объекты убирает уборщик через ATTACHMENT_SWEEP_GRACE_SECONDS после истечения. Вложение видно участникам чата только после успешного complete (status=ready)."
|
||||
"version": "1.4.0-ext.2",
|
||||
"description": "Трек 1. Не меняет обязательный контракт openapi.json: POST /api/v1/chats/{chat_id}/attachments остаётся основным путём. Клиент получает presigned PUT URL и отправляет байты прямо в приватный bucket MinIO, минуя API. Подписаны заголовки content-type, content-length и x-amz-checksum-sha256: хранилище само отвергает тело с другим размером (403 SignatureDoesNotMatch) или другим SHA-256 (400 XAmzContentChecksumMismatch), объект при этом не создаётся. TTL URL — DIRECT_UPLOAD_URL_TTL_SECONDS (300 с по умолчанию). Ключ объекта attachments/<attachment_id>/original раскрывает только UUID вложения; bucket приватный, анонимный доступ запрещён. Незавершённые и отклонённые заявки и их объекты убирает уборщик через ATTACHMENT_SWEEP_GRACE_SECONDS после истечения. Вложение видно участникам чата только после успешного complete (status=ready)."
|
||||
},
|
||||
"servers": [
|
||||
{
|
||||
@@ -264,8 +264,8 @@
|
||||
"/api/v1/attachments/{attachment_id}/complete": {
|
||||
"post": {
|
||||
"operationId": "completeDirectUpload",
|
||||
"summary": "Подтвердить прямую загрузку: HEAD объекта и проверка заголовка изображения",
|
||||
"description": "Только владелец заявки. Проверяет размер и подписанный SHA-256 объекта (HEAD), читает заголовок изображения (до 1 MiB) и сверяет тип и число пикселей. При несоответствии заявка и объект удаляются, повторный complete даёт 404. Повторный complete готового вложения идемпотентен и возвращает 200.",
|
||||
"summary": "Подтвердить прямую загрузку: HEAD объекта, полное чтение и декод изображения",
|
||||
"description": "Только владелец заявки. Сверяет размер и подписанный SHA-256 объекта (HEAD), затем читает объект целиком: структурная проверка PNG/JPEG и полный декод (повреждённые и усечённые изображения отвергаются, даже если checksum совпадает). При несоответствии объект удаляется, а заявка получает внутренний статус rejected до истечения URL и grace-периода уборщика (повторный PUT по ещё действующему URL не оставит неучтённый объект); повторный complete отклонённой заявки — 404. Если объект ещё не загружен — 409, заявка не меняется. Повторный и параллельный complete готового вложения идемпотентен (200).",
|
||||
"parameters": [
|
||||
{
|
||||
"name": "attachment_id",
|
||||
@@ -461,7 +461,7 @@
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"description": "Хранилище недоступно",
|
||||
"description": "Хранилище недоступно или не ответило за S3_REQUEST_TIMEOUT_MS / UPLOAD_TIMEOUT_MS",
|
||||
"headers": {
|
||||
"X-Request-Id": {
|
||||
"description": "Идентификатор запроса.",
|
||||
@@ -485,6 +485,39 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"429": {
|
||||
"description": "Реплика проверяет слишком много изображений одновременно (UPLOAD_MAX_IN_FLIGHT) или у пользователя слишком много одновременных проверок (UPLOAD_MAX_IN_FLIGHT_PER_USER); Retry-After — секунды до повтора.",
|
||||
"headers": {
|
||||
"X-Request-Id": {
|
||||
"description": "Идентификатор запроса.",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"X-Instance-Id": {
|
||||
"description": "Идентификатор реплики.",
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
}
|
||||
},
|
||||
"Retry-After": {
|
||||
"description": "Секунды до повтора.",
|
||||
"schema": {
|
||||
"type": "integer",
|
||||
"minimum": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"content": {
|
||||
"application/json": {
|
||||
"schema": {
|
||||
"$ref": "openapi.json#/components/schemas/Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/mtusi-lab4-api-1 OOMKilled=false restarts=0
|
||||
/mtusi-lab4-api-2 OOMKilled=false restarts=0
|
||||
@@ -1,189 +1,48 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:21+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:19:18+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "direct",
|
||||
"size_bytes": 1048576,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.542,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.474,
|
||||
"latency_ms": {
|
||||
"p50": 69.2,
|
||||
"p95": 101.4,
|
||||
"p99": 125.5
|
||||
"p50": 71.2,
|
||||
"p95": 97.4,
|
||||
"p99": 114.6
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1732876,
|
||||
"delta_tx_bytes": 185102,
|
||||
"baseline_rss_bytes": 192851968,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 26410731,
|
||||
"delta_tx_bytes": 192869,
|
||||
"baseline_rss_bytes": 255631360,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 192983040,
|
||||
"heap_used": 51764168,
|
||||
"external": 7874039,
|
||||
"array_buffers": 4083695
|
||||
},
|
||||
"delta_rss_bytes": 131072,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 26,
|
||||
"attachments.insert_pending": 26,
|
||||
"attachments.direct.initiated": 26,
|
||||
"attachments.find_for_complete": 24,
|
||||
"attachments.direct.verify_bytes": 1572864,
|
||||
"attachments.mark_ready": 24,
|
||||
"attachments.direct.completed": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1868893,
|
||||
"delta_tx_bytes": 186494,
|
||||
"baseline_rss_bytes": 181489664,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 182013952,
|
||||
"heap_used": 53099792,
|
||||
"external": 7642630,
|
||||
"array_buffers": 3852254
|
||||
},
|
||||
"delta_rss_bytes": 524288,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 1703936,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3601769,
|
||||
"total_delta_tx_bytes": 371596,
|
||||
"rx_bytes_per_upload": 72035,
|
||||
"tx_bytes_per_upload": 7432,
|
||||
"max_delta_rss_bytes": 524288
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.685,
|
||||
"latency_ms": {
|
||||
"p50": 111.1,
|
||||
"p95": 137.0,
|
||||
"p99": 142.2
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1800815,
|
||||
"delta_tx_bytes": 186876,
|
||||
"baseline_rss_bytes": 192983040,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 193507328,
|
||||
"heap_used": 51579728,
|
||||
"external": 6754919,
|
||||
"array_buffers": 2800370
|
||||
},
|
||||
"delta_rss_bytes": 524288,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1800709,
|
||||
"delta_tx_bytes": 185964,
|
||||
"baseline_rss_bytes": 182013952,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 182800384,
|
||||
"heap_used": 53017320,
|
||||
"external": 7914245,
|
||||
"array_buffers": 4123869
|
||||
},
|
||||
"delta_rss_bytes": 786432,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3601524,
|
||||
"total_delta_tx_bytes": 372840,
|
||||
"rx_bytes_per_upload": 72030,
|
||||
"tx_bytes_per_upload": 7457,
|
||||
"max_delta_rss_bytes": 786432
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.552,
|
||||
"latency_ms": {
|
||||
"p50": 75.4,
|
||||
"p95": 147.0,
|
||||
"p99": 157.9
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1801291,
|
||||
"delta_tx_bytes": 185886,
|
||||
"baseline_rss_bytes": 193396736,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 194314240,
|
||||
"heap_used": 52852056,
|
||||
"external": 6737214,
|
||||
"array_buffers": 2946870
|
||||
},
|
||||
"delta_rss_bytes": 917504,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1800711,
|
||||
"delta_tx_bytes": 185106,
|
||||
"baseline_rss_bytes": 182374400,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 182374400,
|
||||
"heap_used": 53283160,
|
||||
"external": 7898022,
|
||||
"array_buffers": 3970019
|
||||
"rss": 255631360,
|
||||
"heap_used": 55130048,
|
||||
"external": 30839902,
|
||||
"array_buffers": 27031366
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
@@ -191,17 +50,175 @@
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.direct.verify_bytes": 26214400,
|
||||
"attachments.decode.ms": 149.66068200027803,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 26409853,
|
||||
"delta_tx_bytes": 199121,
|
||||
"baseline_rss_bytes": 220901376,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 220901376,
|
||||
"heap_used": 49764944,
|
||||
"external": 19106520,
|
||||
"array_buffers": 15302577
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 26214400,
|
||||
"attachments.decode.ms": 134.77708099997835,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3602002,
|
||||
"total_delta_tx_bytes": 370992,
|
||||
"rx_bytes_per_upload": 72040,
|
||||
"tx_bytes_per_upload": 7420,
|
||||
"max_delta_rss_bytes": 917504
|
||||
"total_delta_rx_bytes": 52820584,
|
||||
"total_delta_tx_bytes": 391990,
|
||||
"rx_bytes_per_upload": 1056412,
|
||||
"tx_bytes_per_upload": 7840,
|
||||
"max_delta_rss_bytes": 0
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.486,
|
||||
"latency_ms": {
|
||||
"p50": 67.0,
|
||||
"p95": 107.3,
|
||||
"p99": 117.3
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 26407608,
|
||||
"delta_tx_bytes": 187247,
|
||||
"baseline_rss_bytes": 255631360,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 255631360,
|
||||
"heap_used": 54714120,
|
||||
"external": 29734772,
|
||||
"array_buffers": 25926248
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 26214400,
|
||||
"attachments.decode.ms": 129.6924299999373,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 26411452,
|
||||
"delta_tx_bytes": 197525,
|
||||
"baseline_rss_bytes": 220901376,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 220901376,
|
||||
"heap_used": 50436872,
|
||||
"external": 20154009,
|
||||
"array_buffers": 16352314
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 26214400,
|
||||
"attachments.decode.ms": 146.63997799990466,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 52819060,
|
||||
"total_delta_tx_bytes": 384772,
|
||||
"rx_bytes_per_upload": 1056381,
|
||||
"tx_bytes_per_upload": 7695,
|
||||
"max_delta_rss_bytes": 0
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.588,
|
||||
"latency_ms": {
|
||||
"p50": 79.7,
|
||||
"p95": 122.1,
|
||||
"p99": 146.3
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 24306748,
|
||||
"delta_tx_bytes": 183976,
|
||||
"baseline_rss_bytes": 255631360,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 256024576,
|
||||
"heap_used": 55222760,
|
||||
"external": 27656537,
|
||||
"array_buffers": 23848029
|
||||
},
|
||||
"delta_rss_bytes": 393216,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 27,
|
||||
"attachments.insert_pending": 27,
|
||||
"attachments.direct.initiated": 27,
|
||||
"attachments.find_for_complete": 23,
|
||||
"attachments.direct.verify_bytes": 24117248,
|
||||
"attachments.decode.ms": 164.5750180000323,
|
||||
"attachments.mark_ready": 23,
|
||||
"attachments.direct.completed": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 28515559,
|
||||
"delta_tx_bytes": 188283,
|
||||
"baseline_rss_bytes": 220901376,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 220901376,
|
||||
"heap_used": 51242112,
|
||||
"external": 23325182,
|
||||
"array_buffers": 19516705
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 23,
|
||||
"attachments.insert_pending": 23,
|
||||
"attachments.direct.initiated": 23,
|
||||
"attachments.find_for_complete": 27,
|
||||
"attachments.direct.verify_bytes": 28311552,
|
||||
"attachments.decode.ms": 181.22829800000181,
|
||||
"attachments.mark_ready": 27,
|
||||
"attachments.direct.completed": 27
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 52822307,
|
||||
"total_delta_tx_bytes": 372259,
|
||||
"rx_bytes_per_upload": 1056446,
|
||||
"tx_bytes_per_upload": 7445,
|
||||
"max_delta_rss_bytes": 393216
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,207 +1,224 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:09+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:19:05+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "direct",
|
||||
"size_bytes": 131072,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.242,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.225,
|
||||
"latency_ms": {
|
||||
"p50": 43.2,
|
||||
"p95": 56.1,
|
||||
"p99": 59.7
|
||||
"p50": 39.1,
|
||||
"p95": 67.1,
|
||||
"p99": 70.2
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1869074,
|
||||
"delta_tx_bytes": 185920,
|
||||
"baseline_rss_bytes": 182263808,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3306246,
|
||||
"delta_tx_bytes": 183847,
|
||||
"baseline_rss_bytes": 255115264,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 182898688,
|
||||
"heap_used": 53275328,
|
||||
"external": 9220810,
|
||||
"array_buffers": 5428348
|
||||
"rss": 255115264,
|
||||
"heap_used": 52168040,
|
||||
"external": 11980507,
|
||||
"array_buffers": 8188021
|
||||
},
|
||||
"delta_rss_bytes": 634880,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 1703936,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1732185,
|
||||
"delta_tx_bytes": 183862,
|
||||
"baseline_rss_bytes": 173453312,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 173862912,
|
||||
"heap_used": 51776512,
|
||||
"external": 7372259,
|
||||
"array_buffers": 3579797
|
||||
},
|
||||
"delta_rss_bytes": 409600,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 26,
|
||||
"attachments.insert_pending": 26,
|
||||
"attachments.direct.initiated": 26,
|
||||
"attachments.find_for_complete": 24,
|
||||
"attachments.direct.verify_bytes": 1572864,
|
||||
"attachments.direct.verify_bytes": 3145728,
|
||||
"attachments.decode.ms": 76.04879400000209,
|
||||
"attachments.mark_ready": 24,
|
||||
"attachments.direct.completed": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3572465,
|
||||
"delta_tx_bytes": 185987,
|
||||
"baseline_rss_bytes": 410796032,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 413024256,
|
||||
"heap_used": 61028552,
|
||||
"external": 11110575,
|
||||
"array_buffers": 7314315
|
||||
},
|
||||
"delta_rss_bytes": 2228224,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 3407872,
|
||||
"attachments.decode.ms": 95.17834699997911,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3601259,
|
||||
"total_delta_tx_bytes": 369782,
|
||||
"rx_bytes_per_upload": 72025,
|
||||
"tx_bytes_per_upload": 7396,
|
||||
"max_delta_rss_bytes": 634880
|
||||
"total_delta_rx_bytes": 6878711,
|
||||
"total_delta_tx_bytes": 369834,
|
||||
"rx_bytes_per_upload": 137574,
|
||||
"tx_bytes_per_upload": 7397,
|
||||
"max_delta_rss_bytes": 2228224
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.254,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.237,
|
||||
"latency_ms": {
|
||||
"p50": 44.9,
|
||||
"p95": 64.9,
|
||||
"p99": 74.0
|
||||
"p50": 39.7,
|
||||
"p95": 70.8,
|
||||
"p99": 71.9
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1663798,
|
||||
"delta_tx_bytes": 181411,
|
||||
"baseline_rss_bytes": 182898688,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3305361,
|
||||
"delta_tx_bytes": 182735,
|
||||
"baseline_rss_bytes": 255115264,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 183029760,
|
||||
"heap_used": 52623040,
|
||||
"external": 9199397,
|
||||
"array_buffers": 5406935
|
||||
"rss": 255115264,
|
||||
"heap_used": 52870848,
|
||||
"external": 12917408,
|
||||
"array_buffers": 8731525
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 26,
|
||||
"attachments.insert_pending": 26,
|
||||
"attachments.direct.initiated": 26,
|
||||
"attachments.find_for_complete": 24,
|
||||
"attachments.direct.verify_bytes": 3145728,
|
||||
"attachments.decode.ms": 74.47586199996294,
|
||||
"attachments.mark_ready": 24,
|
||||
"attachments.direct.completed": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3572269,
|
||||
"delta_tx_bytes": 183875,
|
||||
"baseline_rss_bytes": 413024256,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 413417472,
|
||||
"heap_used": 59807944,
|
||||
"external": 10703911,
|
||||
"array_buffers": 6908083
|
||||
},
|
||||
"delta_rss_bytes": 393216,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 3407872,
|
||||
"attachments.decode.ms": 80.40512400015723,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 6877630,
|
||||
"total_delta_tx_bytes": 366610,
|
||||
"rx_bytes_per_upload": 137553,
|
||||
"tx_bytes_per_upload": 7332,
|
||||
"max_delta_rss_bytes": 393216
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.266,
|
||||
"latency_ms": {
|
||||
"p50": 45.7,
|
||||
"p95": 73.8,
|
||||
"p99": 80.1
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3306421,
|
||||
"delta_tx_bytes": 183391,
|
||||
"baseline_rss_bytes": 255115264,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 255377408,
|
||||
"heap_used": 55403296,
|
||||
"external": 12765653,
|
||||
"array_buffers": 8973582
|
||||
},
|
||||
"delta_rss_bytes": 262144,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 26,
|
||||
"attachments.insert_pending": 26,
|
||||
"attachments.direct.initiated": 26,
|
||||
"attachments.find_for_complete": 24,
|
||||
"attachments.direct.verify_bytes": 3145728,
|
||||
"attachments.decode.ms": 113.08572699979413,
|
||||
"attachments.mark_ready": 24,
|
||||
"attachments.direct.completed": 24
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3572203,
|
||||
"delta_tx_bytes": 184215,
|
||||
"baseline_rss_bytes": 413417472,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 413548544,
|
||||
"heap_used": 60296808,
|
||||
"external": 10700258,
|
||||
"array_buffers": 6904444
|
||||
},
|
||||
"delta_rss_bytes": 131072,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 27,
|
||||
"attachments.insert_pending": 27,
|
||||
"attachments.direct.initiated": 27,
|
||||
"attachments.find_for_complete": 23,
|
||||
"attachments.direct.verify_bytes": 1507328,
|
||||
"attachments.mark_ready": 23,
|
||||
"attachments.direct.completed": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1936597,
|
||||
"delta_tx_bytes": 185873,
|
||||
"baseline_rss_bytes": 173862912,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 174125056,
|
||||
"heap_used": 53719328,
|
||||
"external": 7649562,
|
||||
"array_buffers": 3857100
|
||||
},
|
||||
"delta_rss_bytes": 262144,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 23,
|
||||
"attachments.insert_pending": 23,
|
||||
"attachments.direct.initiated": 23,
|
||||
"attachments.find_for_complete": 27,
|
||||
"attachments.direct.verify_bytes": 1769472,
|
||||
"attachments.mark_ready": 27,
|
||||
"attachments.direct.completed": 27
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 3407872,
|
||||
"attachments.decode.ms": 102.82485899998574,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3600395,
|
||||
"total_delta_tx_bytes": 367284,
|
||||
"rx_bytes_per_upload": 72008,
|
||||
"tx_bytes_per_upload": 7346,
|
||||
"total_delta_rx_bytes": 6878624,
|
||||
"total_delta_tx_bytes": 367606,
|
||||
"rx_bytes_per_upload": 137572,
|
||||
"tx_bytes_per_upload": 7352,
|
||||
"max_delta_rss_bytes": 262144
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.441,
|
||||
"latency_ms": {
|
||||
"p50": 80.3,
|
||||
"p95": 124.0,
|
||||
"p99": 127.6
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 2007125,
|
||||
"delta_tx_bytes": 186925,
|
||||
"baseline_rss_bytes": 183029760,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 183447552,
|
||||
"heap_used": 56507192,
|
||||
"external": 9369635,
|
||||
"array_buffers": 5577173
|
||||
},
|
||||
"delta_rss_bytes": 417792,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 22,
|
||||
"attachments.insert_pending": 22,
|
||||
"attachments.direct.initiated": 22,
|
||||
"attachments.find_for_complete": 28,
|
||||
"attachments.direct.verify_bytes": 1835008,
|
||||
"attachments.mark_ready": 28,
|
||||
"attachments.direct.completed": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1596449,
|
||||
"delta_tx_bytes": 182757,
|
||||
"baseline_rss_bytes": 174125056,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 174387200,
|
||||
"heap_used": 54337704,
|
||||
"external": 7649635,
|
||||
"array_buffers": 3857173
|
||||
},
|
||||
"delta_rss_bytes": 262144,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 28,
|
||||
"attachments.insert_pending": 28,
|
||||
"attachments.direct.initiated": 28,
|
||||
"attachments.find_for_complete": 22,
|
||||
"attachments.direct.verify_bytes": 1441792,
|
||||
"attachments.mark_ready": 22,
|
||||
"attachments.direct.completed": 22
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3603574,
|
||||
"total_delta_tx_bytes": 369682,
|
||||
"rx_bytes_per_upload": 72071,
|
||||
"tx_bytes_per_upload": 7394,
|
||||
"max_delta_rss_bytes": 417792
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,43 +1,115 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:47+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:19:48+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "direct",
|
||||
"size_bytes": 9961472,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 3.048,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 3.75,
|
||||
"latency_ms": {
|
||||
"p50": 346.0,
|
||||
"p95": 575.3,
|
||||
"p99": 581.2
|
||||
"p50": 448.3,
|
||||
"p95": 674.2,
|
||||
"p99": 702.9
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1669140,
|
||||
"delta_tx_bytes": 194261,
|
||||
"baseline_rss_bytes": 189468672,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 259479426,
|
||||
"delta_tx_bytes": 287642,
|
||||
"baseline_rss_bytes": 280027136,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 189468672,
|
||||
"heap_used": 59441184,
|
||||
"external": 6250789,
|
||||
"array_buffers": 2449996
|
||||
"rss": 322101248,
|
||||
"heap_used": 54779008,
|
||||
"external": 104107482,
|
||||
"array_buffers": 100313819
|
||||
},
|
||||
"delta_rss_bytes": 42074112,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 24,
|
||||
"attachments.insert_pending": 24,
|
||||
"attachments.direct.initiated": 24,
|
||||
"attachments.find_for_complete": 26,
|
||||
"attachments.direct.verify_bytes": 258998272,
|
||||
"attachments.decode.ms": 498.32417600008193,
|
||||
"attachments.mark_ready": 26,
|
||||
"attachments.direct.completed": 26
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 239524438,
|
||||
"delta_tx_bytes": 268169,
|
||||
"baseline_rss_bytes": 243490816,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 326799360,
|
||||
"heap_used": 54201104,
|
||||
"external": 106161894,
|
||||
"array_buffers": 102364928
|
||||
},
|
||||
"delta_rss_bytes": 83308544,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 26,
|
||||
"attachments.insert_pending": 26,
|
||||
"attachments.direct.initiated": 26,
|
||||
"attachments.find_for_complete": 24,
|
||||
"attachments.direct.verify_bytes": 239075328,
|
||||
"attachments.decode.ms": 373.651800000167,
|
||||
"attachments.mark_ready": 24,
|
||||
"attachments.direct.completed": 24
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 499003864,
|
||||
"total_delta_tx_bytes": 555811,
|
||||
"rx_bytes_per_upload": 9980077,
|
||||
"tx_bytes_per_upload": 11116,
|
||||
"max_delta_rss_bytes": 83308544
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 3.749,
|
||||
"latency_ms": {
|
||||
"p50": 471.3,
|
||||
"p95": 672.0,
|
||||
"p99": 739.0
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 229545332,
|
||||
"delta_tx_bytes": 272949,
|
||||
"baseline_rss_bytes": 322101248,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 322101248,
|
||||
"heap_used": 53139240,
|
||||
"external": 120388652,
|
||||
"array_buffers": 115495375
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
@@ -45,163 +117,108 @@
|
||||
"attachments.insert_pending": 27,
|
||||
"attachments.direct.initiated": 27,
|
||||
"attachments.find_for_complete": 23,
|
||||
"attachments.direct.verify_bytes": 1507328,
|
||||
"attachments.direct.verify_bytes": 229113856,
|
||||
"attachments.decode.ms": 295.2854530001059,
|
||||
"attachments.mark_ready": 23,
|
||||
"attachments.direct.completed": 23
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1940713,
|
||||
"delta_tx_bytes": 195885,
|
||||
"baseline_rss_bytes": 179376128,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 269451762,
|
||||
"delta_tx_bytes": 274913,
|
||||
"baseline_rss_bytes": 294375424,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 180293632,
|
||||
"heap_used": 59568768,
|
||||
"external": 6672150,
|
||||
"array_buffers": 2881806
|
||||
"rss": 360865792,
|
||||
"heap_used": 53636296,
|
||||
"external": 157544946,
|
||||
"array_buffers": 153746128
|
||||
},
|
||||
"delta_rss_bytes": 917504,
|
||||
"delta_rss_bytes": 66490368,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 23,
|
||||
"attachments.insert_pending": 23,
|
||||
"attachments.direct.initiated": 23,
|
||||
"attachments.find_for_complete": 27,
|
||||
"attachments.direct.verify_bytes": 1769472,
|
||||
"attachments.direct.verify_bytes": 268959744,
|
||||
"attachments.decode.ms": 467.34784599993145,
|
||||
"attachments.mark_ready": 27,
|
||||
"attachments.direct.completed": 27
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3609853,
|
||||
"total_delta_tx_bytes": 390146,
|
||||
"rx_bytes_per_upload": 72197,
|
||||
"tx_bytes_per_upload": 7803,
|
||||
"max_delta_rss_bytes": 917504
|
||||
"total_delta_rx_bytes": 498997094,
|
||||
"total_delta_tx_bytes": 547862,
|
||||
"rx_bytes_per_upload": 9979942,
|
||||
"tx_bytes_per_upload": 10957,
|
||||
"max_delta_rss_bytes": 66490368
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 2.948,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 3.501,
|
||||
"latency_ms": {
|
||||
"p50": 350.2,
|
||||
"p95": 570.8,
|
||||
"p99": 608.6
|
||||
"p50": 404.2,
|
||||
"p95": 599.0,
|
||||
"p99": 605.8
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1803498,
|
||||
"delta_tx_bytes": 194370,
|
||||
"baseline_rss_bytes": 189468672,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 219577054,
|
||||
"delta_tx_bytes": 272143,
|
||||
"baseline_rss_bytes": 270405632,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 189861888,
|
||||
"heap_used": 59295328,
|
||||
"external": 6363945,
|
||||
"array_buffers": 2573569
|
||||
"rss": 290258944,
|
||||
"heap_used": 52555024,
|
||||
"external": 103954247,
|
||||
"array_buffers": 100162235
|
||||
},
|
||||
"delta_rss_bytes": 393216,
|
||||
"delta_rss_bytes": 19853312,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
"attachments.count_pending_direct": 28,
|
||||
"attachments.insert_pending": 28,
|
||||
"attachments.direct.initiated": 28,
|
||||
"attachments.find_for_complete": 22,
|
||||
"attachments.direct.verify_bytes": 219152384,
|
||||
"attachments.decode.ms": 273.8368729999056,
|
||||
"attachments.mark_ready": 22,
|
||||
"attachments.direct.completed": 22
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 1804525,
|
||||
"delta_tx_bytes": 194742,
|
||||
"baseline_rss_bytes": 179740672,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 279433430,
|
||||
"delta_tx_bytes": 286105,
|
||||
"baseline_rss_bytes": 223891456,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 179740672,
|
||||
"heap_used": 59420128,
|
||||
"external": 6260844,
|
||||
"array_buffers": 2470500
|
||||
"rss": 294211584,
|
||||
"heap_used": 50865176,
|
||||
"external": 84552392,
|
||||
"array_buffers": 80757048
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"delta_rss_bytes": 70320128,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 25,
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.direct.initiated": 25,
|
||||
"attachments.find_for_complete": 25,
|
||||
"attachments.direct.verify_bytes": 1638400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.direct.completed": 25
|
||||
"attachments.count_pending_direct": 22,
|
||||
"attachments.insert_pending": 22,
|
||||
"attachments.direct.initiated": 22,
|
||||
"attachments.find_for_complete": 28,
|
||||
"attachments.direct.verify_bytes": 278921216,
|
||||
"attachments.decode.ms": 406.8028439999907,
|
||||
"attachments.mark_ready": 28,
|
||||
"attachments.direct.completed": 28
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3608023,
|
||||
"total_delta_tx_bytes": 389112,
|
||||
"rx_bytes_per_upload": 72160,
|
||||
"tx_bytes_per_upload": 7782,
|
||||
"max_delta_rss_bytes": 393216
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 2.556,
|
||||
"latency_ms": {
|
||||
"p50": 314.1,
|
||||
"p95": 425.2,
|
||||
"p99": 453.1
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 1531515,
|
||||
"delta_tx_bytes": 190497,
|
||||
"baseline_rss_bytes": 189861888,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 190910464,
|
||||
"heap_used": 60034376,
|
||||
"external": 6373249,
|
||||
"array_buffers": 2582873
|
||||
},
|
||||
"delta_rss_bytes": 1048576,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 29,
|
||||
"attachments.insert_pending": 29,
|
||||
"attachments.direct.initiated": 29,
|
||||
"attachments.find_for_complete": 21,
|
||||
"attachments.direct.verify_bytes": 1376256,
|
||||
"attachments.mark_ready": 21,
|
||||
"attachments.direct.completed": 21
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 2076238,
|
||||
"delta_tx_bytes": 196531,
|
||||
"baseline_rss_bytes": 179740672,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 179740672,
|
||||
"heap_used": 59642168,
|
||||
"external": 6672708,
|
||||
"array_buffers": 2755498
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 21,
|
||||
"attachments.insert_pending": 21,
|
||||
"attachments.direct.initiated": 21,
|
||||
"attachments.find_for_complete": 29,
|
||||
"attachments.direct.verify_bytes": 1900544,
|
||||
"attachments.mark_ready": 29,
|
||||
"attachments.direct.completed": 29
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 3607753,
|
||||
"total_delta_tx_bytes": 387028,
|
||||
"rx_bytes_per_upload": 72155,
|
||||
"tx_bytes_per_upload": 7741,
|
||||
"max_delta_rss_bytes": 1048576
|
||||
"total_delta_rx_bytes": 499010484,
|
||||
"total_delta_tx_bytes": 558248,
|
||||
"rx_bytes_per_upload": 9980210,
|
||||
"tx_bytes_per_upload": 11165,
|
||||
"max_delta_rss_bytes": 70320128
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,229 @@
|
||||
{
|
||||
"date": "2026-10-23T14:23:13+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "direct",
|
||||
"size_bytes": 10485760,
|
||||
"concurrency": 32,
|
||||
"uploads_per_worker": 2,
|
||||
"repeat": 3,
|
||||
"users": 32,
|
||||
"image": "worst-40mp-rgba16-adam7.png"
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 48,
|
||||
"failed": 16,
|
||||
"outcomes": {
|
||||
"ok": 48,
|
||||
"complete:429": 16
|
||||
},
|
||||
"duration_s": 25.881,
|
||||
"latency_ms": {
|
||||
"p50": 11067.1,
|
||||
"p95": 13423.0,
|
||||
"p99": 14220.4
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 168217561,
|
||||
"delta_tx_bytes": 384114,
|
||||
"baseline_rss_bytes": 428978176,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 823418880,
|
||||
"heap_used": 52305208,
|
||||
"external": 243338213,
|
||||
"array_buffers": 239547869
|
||||
},
|
||||
"delta_rss_bytes": 394440704,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 48,
|
||||
"attachments.insert_pending": 48,
|
||||
"attachments.direct.initiated": 48,
|
||||
"attachments.find_for_complete": 16,
|
||||
"attachments.direct.verify_bytes": 167772160,
|
||||
"attachments.decode.ms": 13205.84250300005,
|
||||
"attachments.mark_ready": 16,
|
||||
"attachments.direct.completed": 16
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 336236648,
|
||||
"delta_tx_bytes": 458338,
|
||||
"baseline_rss_bytes": 288284672,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 803422208,
|
||||
"heap_used": 51748952,
|
||||
"external": 236179385,
|
||||
"array_buffers": 232389041
|
||||
},
|
||||
"delta_rss_bytes": 515137536,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 16,
|
||||
"attachments.insert_pending": 16,
|
||||
"attachments.direct.initiated": 16,
|
||||
"attachments.find_for_complete": 48,
|
||||
"attachments.direct.verify_bytes": 335544320,
|
||||
"attachments.decode.ms": 24842.089320000494,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.direct.completed": 32
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 504454209,
|
||||
"total_delta_tx_bytes": 842452,
|
||||
"rx_bytes_per_upload": 7882097,
|
||||
"tx_bytes_per_upload": 13163,
|
||||
"max_delta_rss_bytes": 515137536
|
||||
},
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 60,
|
||||
"failed": 4,
|
||||
"outcomes": {
|
||||
"ok": 60,
|
||||
"complete:429": 4
|
||||
},
|
||||
"duration_s": 26.523,
|
||||
"latency_ms": {
|
||||
"p50": 11841.6,
|
||||
"p95": 13541.3,
|
||||
"p99": 14293.7
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 294214487,
|
||||
"delta_tx_bytes": 425744,
|
||||
"baseline_rss_bytes": 470261760,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 828153856,
|
||||
"heap_used": 51846456,
|
||||
"external": 242086934,
|
||||
"array_buffers": 238296517
|
||||
},
|
||||
"delta_rss_bytes": 357892096,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 36,
|
||||
"attachments.insert_pending": 36,
|
||||
"attachments.direct.initiated": 36,
|
||||
"attachments.find_for_complete": 28,
|
||||
"attachments.direct.verify_bytes": 293601280,
|
||||
"attachments.decode.ms": 22602.63425100036,
|
||||
"attachments.mark_ready": 28,
|
||||
"attachments.claim_expired": 1,
|
||||
"attachments.direct.completed": 28
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 336212832,
|
||||
"delta_tx_bytes": 461394,
|
||||
"baseline_rss_bytes": 429502464,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 814202880,
|
||||
"heap_used": 51503296,
|
||||
"external": 256575006,
|
||||
"array_buffers": 212949888
|
||||
},
|
||||
"delta_rss_bytes": 384700416,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 28,
|
||||
"attachments.insert_pending": 28,
|
||||
"attachments.direct.initiated": 28,
|
||||
"attachments.find_for_complete": 36,
|
||||
"attachments.direct.verify_bytes": 335544320,
|
||||
"attachments.decode.ms": 25502.105729999603,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.direct.completed": 32,
|
||||
"attachments.claim_expired": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 630427319,
|
||||
"total_delta_tx_bytes": 887138,
|
||||
"rx_bytes_per_upload": 9850427,
|
||||
"tx_bytes_per_upload": 13862,
|
||||
"max_delta_rss_bytes": 384700416
|
||||
},
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 59,
|
||||
"failed": 5,
|
||||
"outcomes": {
|
||||
"complete:429": 5,
|
||||
"ok": 59
|
||||
},
|
||||
"duration_s": 26.673,
|
||||
"latency_ms": {
|
||||
"p50": 10563.3,
|
||||
"p95": 13343.1,
|
||||
"p99": 14265.7
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 283773903,
|
||||
"delta_tx_bytes": 418163,
|
||||
"baseline_rss_bytes": 474800128,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 829358080,
|
||||
"heap_used": 51810024,
|
||||
"external": 242621863,
|
||||
"array_buffers": 228344296
|
||||
},
|
||||
"delta_rss_bytes": 354557952,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 37,
|
||||
"attachments.insert_pending": 37,
|
||||
"attachments.direct.initiated": 37,
|
||||
"attachments.find_for_complete": 27,
|
||||
"attachments.direct.verify_bytes": 283115520,
|
||||
"attachments.decode.ms": 22160.10410899995,
|
||||
"attachments.mark_ready": 27,
|
||||
"attachments.direct.completed": 27
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 336214318,
|
||||
"delta_tx_bytes": 426666,
|
||||
"baseline_rss_bytes": 461180928,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 814313472,
|
||||
"heap_used": 54614560,
|
||||
"external": 256831606,
|
||||
"array_buffers": 229984560
|
||||
},
|
||||
"delta_rss_bytes": 353132544,
|
||||
"counters": {
|
||||
"attachments.count_pending_direct": 27,
|
||||
"attachments.insert_pending": 27,
|
||||
"attachments.direct.initiated": 27,
|
||||
"attachments.find_for_complete": 37,
|
||||
"attachments.direct.verify_bytes": 335544320,
|
||||
"attachments.decode.ms": 25823.93422999978,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.direct.completed": 32
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 619988221,
|
||||
"total_delta_tx_bytes": 844829,
|
||||
"rx_bytes_per_upload": 9687316,
|
||||
"tx_bytes_per_upload": 13200,
|
||||
"max_delta_rss_bytes": 354557952
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,195 +1,212 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:15+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:19:11+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "proxy",
|
||||
"size_bytes": 1048576,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.369,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.402,
|
||||
"latency_ms": {
|
||||
"p50": 46.4,
|
||||
"p95": 68.3,
|
||||
"p99": 72.8
|
||||
"p50": 48.4,
|
||||
"p95": 84.1,
|
||||
"p99": 92.3
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 26390991,
|
||||
"delta_tx_bytes": 26399463,
|
||||
"baseline_rss_bytes": 183496704,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 26376487,
|
||||
"delta_tx_bytes": 26404723,
|
||||
"baseline_rss_bytes": 255217664,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 188407808,
|
||||
"heap_used": 58350032,
|
||||
"external": 15612927,
|
||||
"array_buffers": 11820465
|
||||
"rss": 255610880,
|
||||
"heap_used": 52221216,
|
||||
"external": 23026820,
|
||||
"array_buffers": 19216043
|
||||
},
|
||||
"delta_rss_bytes": 4911104,
|
||||
"delta_rss_bytes": 393216,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 156.9926100000739,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 26389902,
|
||||
"delta_tx_bytes": 26401063,
|
||||
"baseline_rss_bytes": 172593152,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 26386314,
|
||||
"delta_tx_bytes": 26402341,
|
||||
"baseline_rss_bytes": 413614080,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 179159040,
|
||||
"heap_used": 51726640,
|
||||
"external": 10983870,
|
||||
"array_buffers": 7191408
|
||||
"rss": 413876224,
|
||||
"heap_used": 55746224,
|
||||
"external": 28951897,
|
||||
"array_buffers": 25131678
|
||||
},
|
||||
"delta_rss_bytes": 6565888,
|
||||
"delta_rss_bytes": 262144,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 162.94164999981876,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 52780893,
|
||||
"total_delta_tx_bytes": 52800526,
|
||||
"rx_bytes_per_upload": 1055618,
|
||||
"tx_bytes_per_upload": 1056011,
|
||||
"max_delta_rss_bytes": 6565888
|
||||
"total_delta_rx_bytes": 52762801,
|
||||
"total_delta_tx_bytes": 52807064,
|
||||
"rx_bytes_per_upload": 1055256,
|
||||
"tx_bytes_per_upload": 1056141,
|
||||
"max_delta_rss_bytes": 393216
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.55,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.38,
|
||||
"latency_ms": {
|
||||
"p50": 59.3,
|
||||
"p95": 210.6,
|
||||
"p99": 226.6
|
||||
"p50": 50.7,
|
||||
"p95": 82.2,
|
||||
"p99": 88.5
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 26377432,
|
||||
"delta_tx_bytes": 26403430,
|
||||
"baseline_rss_bytes": 188645376,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 26388819,
|
||||
"delta_tx_bytes": 26402419,
|
||||
"baseline_rss_bytes": 255610880,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 193232896,
|
||||
"heap_used": 52490432,
|
||||
"external": 19098493,
|
||||
"array_buffers": 15306617
|
||||
"rss": 255741952,
|
||||
"heap_used": 53542032,
|
||||
"external": 30837329,
|
||||
"array_buffers": 27022020
|
||||
},
|
||||
"delta_rss_bytes": 4587520,
|
||||
"delta_rss_bytes": 131072,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 149.34638900024584,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 26383216,
|
||||
"delta_tx_bytes": 26401660,
|
||||
"baseline_rss_bytes": 179159040,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 26377403,
|
||||
"delta_tx_bytes": 26400247,
|
||||
"baseline_rss_bytes": 220905472,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 179486720,
|
||||
"heap_used": 49462912,
|
||||
"external": 15506324,
|
||||
"array_buffers": 11714604
|
||||
"rss": 221036544,
|
||||
"heap_used": 51357984,
|
||||
"external": 22079805,
|
||||
"array_buffers": 18271239
|
||||
},
|
||||
"delta_rss_bytes": 327680,
|
||||
"delta_rss_bytes": 131072,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 137.65105199965183,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 52760648,
|
||||
"total_delta_tx_bytes": 52805090,
|
||||
"rx_bytes_per_upload": 1055213,
|
||||
"tx_bytes_per_upload": 1056102,
|
||||
"max_delta_rss_bytes": 4587520
|
||||
"total_delta_rx_bytes": 52766222,
|
||||
"total_delta_tx_bytes": 52802666,
|
||||
"rx_bytes_per_upload": 1055324,
|
||||
"tx_bytes_per_upload": 1056053,
|
||||
"max_delta_rss_bytes": 131072
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.461,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.385,
|
||||
"latency_ms": {
|
||||
"p50": 67.3,
|
||||
"p95": 109.8,
|
||||
"p99": 118.7
|
||||
"p50": 49.7,
|
||||
"p95": 73.2,
|
||||
"p99": 80.6
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 26385813,
|
||||
"delta_tx_bytes": 26399597,
|
||||
"baseline_rss_bytes": 193232896,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 26383716,
|
||||
"delta_tx_bytes": 26401715,
|
||||
"baseline_rss_bytes": 255741952,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 194363392,
|
||||
"heap_used": 51280880,
|
||||
"external": 19455489,
|
||||
"array_buffers": 15663613
|
||||
"rss": 255873024,
|
||||
"heap_used": 52957000,
|
||||
"external": 26930642,
|
||||
"array_buffers": 23117596
|
||||
},
|
||||
"delta_rss_bytes": 1130496,
|
||||
"delta_rss_bytes": 131072,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 139.30256199993892,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 26391095,
|
||||
"delta_tx_bytes": 26404143,
|
||||
"baseline_rss_bytes": 178298880,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 26386387,
|
||||
"delta_tx_bytes": 26402657,
|
||||
"baseline_rss_bytes": 221036544,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 181444608,
|
||||
"heap_used": 50462384,
|
||||
"external": 17515725,
|
||||
"array_buffers": 13659712
|
||||
"rss": 221036544,
|
||||
"heap_used": 51459840,
|
||||
"external": 22079805,
|
||||
"array_buffers": 16097979
|
||||
},
|
||||
"delta_rss_bytes": 3145728,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 26214400,
|
||||
"attachments.decode.ms": 120.35195299994666,
|
||||
"attachments.proxy.bytes_to_s3": 26214400,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 52776908,
|
||||
"total_delta_tx_bytes": 52803740,
|
||||
"rx_bytes_per_upload": 1055538,
|
||||
"tx_bytes_per_upload": 1056075,
|
||||
"max_delta_rss_bytes": 3145728
|
||||
"total_delta_rx_bytes": 52770103,
|
||||
"total_delta_tx_bytes": 52804372,
|
||||
"rx_bytes_per_upload": 1055402,
|
||||
"tx_bytes_per_upload": 1056087,
|
||||
"max_delta_rss_bytes": 131072
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,195 +1,212 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:04+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:18:59+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "proxy",
|
||||
"size_bytes": 131072,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.221,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.169,
|
||||
"latency_ms": {
|
||||
"p50": 32.5,
|
||||
"p95": 61.7,
|
||||
"p99": 75.6
|
||||
"p50": 26.1,
|
||||
"p95": 46.2,
|
||||
"p99": 49.0
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 3382582,
|
||||
"delta_tx_bytes": 3398177,
|
||||
"baseline_rss_bytes": 172421120,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3382850,
|
||||
"delta_tx_bytes": 3398303,
|
||||
"baseline_rss_bytes": 468705280,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 177926144,
|
||||
"heap_used": 50033192,
|
||||
"external": 7706616,
|
||||
"array_buffers": 3914122
|
||||
"rss": 468705280,
|
||||
"heap_used": 50851544,
|
||||
"external": 134219881,
|
||||
"array_buffers": 130427173
|
||||
},
|
||||
"delta_rss_bytes": 5505024,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 100.31424599990714,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 3380734,
|
||||
"delta_tx_bytes": 3397755,
|
||||
"baseline_rss_bytes": 164986880,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3382858,
|
||||
"delta_tx_bytes": 3398701,
|
||||
"baseline_rss_bytes": 449990656,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 170360832,
|
||||
"heap_used": 49897896,
|
||||
"external": 7704663,
|
||||
"array_buffers": 3911977
|
||||
"rss": 451563520,
|
||||
"heap_used": 58537824,
|
||||
"external": 181003027,
|
||||
"array_buffers": 177201619
|
||||
},
|
||||
"delta_rss_bytes": 5373952,
|
||||
"delta_rss_bytes": 1572864,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 102.65141499997117,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 6763316,
|
||||
"total_delta_tx_bytes": 6795932,
|
||||
"rx_bytes_per_upload": 135266,
|
||||
"tx_bytes_per_upload": 135919,
|
||||
"max_delta_rss_bytes": 5505024
|
||||
"total_delta_rx_bytes": 6765708,
|
||||
"total_delta_tx_bytes": 6797004,
|
||||
"rx_bytes_per_upload": 135314,
|
||||
"tx_bytes_per_upload": 135940,
|
||||
"max_delta_rss_bytes": 1572864
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.178,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.198,
|
||||
"latency_ms": {
|
||||
"p50": 30.3,
|
||||
"p95": 39.9,
|
||||
"p99": 40.8
|
||||
"p50": 24.7,
|
||||
"p95": 79.6,
|
||||
"p99": 87.8
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 3378937,
|
||||
"delta_tx_bytes": 3395467,
|
||||
"baseline_rss_bytes": 177926144,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3378497,
|
||||
"delta_tx_bytes": 3395989,
|
||||
"baseline_rss_bytes": 468705280,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 181886976,
|
||||
"heap_used": 51028472,
|
||||
"external": 10337544,
|
||||
"array_buffers": 6545050
|
||||
"rss": 468705280,
|
||||
"heap_used": 51433088,
|
||||
"external": 135937131,
|
||||
"array_buffers": 132143156
|
||||
},
|
||||
"delta_rss_bytes": 3960832,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 133.3207659999607,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 3380009,
|
||||
"delta_tx_bytes": 3397063,
|
||||
"baseline_rss_bytes": 170360832,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3377682,
|
||||
"delta_tx_bytes": 3396121,
|
||||
"baseline_rss_bytes": 410624000,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 171278336,
|
||||
"heap_used": 50939136,
|
||||
"external": 8430160,
|
||||
"array_buffers": 4637666
|
||||
"rss": 410624000,
|
||||
"heap_used": 57652400,
|
||||
"external": 13565945,
|
||||
"array_buffers": 9765488
|
||||
},
|
||||
"delta_rss_bytes": 917504,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 68.74197999993339,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 6758946,
|
||||
"total_delta_tx_bytes": 6792530,
|
||||
"rx_bytes_per_upload": 135179,
|
||||
"tx_bytes_per_upload": 135851,
|
||||
"max_delta_rss_bytes": 3960832
|
||||
"total_delta_rx_bytes": 6756179,
|
||||
"total_delta_tx_bytes": 6792110,
|
||||
"rx_bytes_per_upload": 135124,
|
||||
"tx_bytes_per_upload": 135842,
|
||||
"max_delta_rss_bytes": 0
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 0.291,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 0.161,
|
||||
"latency_ms": {
|
||||
"p50": 41.2,
|
||||
"p95": 87.2,
|
||||
"p99": 93.6
|
||||
"p50": 26.1,
|
||||
"p95": 42.7,
|
||||
"p99": 45.7
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 3377137,
|
||||
"delta_tx_bytes": 3395161,
|
||||
"baseline_rss_bytes": 181886976,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 3374905,
|
||||
"delta_tx_bytes": 3395785,
|
||||
"baseline_rss_bytes": 254783488,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 182149120,
|
||||
"heap_used": 51984832,
|
||||
"external": 9554628,
|
||||
"array_buffers": 5762166
|
||||
"rss": 254783488,
|
||||
"heap_used": 51574496,
|
||||
"external": 12158693,
|
||||
"array_buffers": 8364940
|
||||
},
|
||||
"delta_rss_bytes": 262144,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 77.51481299975421,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 3377713,
|
||||
"delta_tx_bytes": 3396473,
|
||||
"baseline_rss_bytes": 171278336,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 3376331,
|
||||
"delta_tx_bytes": 3394989,
|
||||
"baseline_rss_bytes": 410624000,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 173244416,
|
||||
"heap_used": 52256384,
|
||||
"external": 10276505,
|
||||
"array_buffers": 6484011
|
||||
"rss": 410624000,
|
||||
"heap_used": 58715704,
|
||||
"external": 14697744,
|
||||
"array_buffers": 10896445
|
||||
},
|
||||
"delta_rss_bytes": 1966080,
|
||||
"delta_rss_bytes": 0,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 3276800,
|
||||
"attachments.decode.ms": 79.76343099982478,
|
||||
"attachments.proxy.bytes_to_s3": 3276800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 6754850,
|
||||
"total_delta_tx_bytes": 6791634,
|
||||
"rx_bytes_per_upload": 135097,
|
||||
"tx_bytes_per_upload": 135833,
|
||||
"max_delta_rss_bytes": 1966080
|
||||
"total_delta_rx_bytes": 6751236,
|
||||
"total_delta_tx_bytes": 6790774,
|
||||
"rx_bytes_per_upload": 135025,
|
||||
"tx_bytes_per_upload": 135815,
|
||||
"max_delta_rss_bytes": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,197 +1,214 @@
|
||||
{
|
||||
"date": "2026-10-22T20:02:34+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:19:32+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "proxy",
|
||||
"size_bytes": 9961472,
|
||||
"concurrency": 10,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 10,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 2.923,
|
||||
"latency_ms": {
|
||||
"p50": 217.7,
|
||||
"p95": 393.7,
|
||||
"p99": 469.2
|
||||
"p50": 245.8,
|
||||
"p95": 426.3,
|
||||
"p99": 473.7
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 249719999,
|
||||
"delta_tx_bytes": 249864966,
|
||||
"baseline_rss_bytes": 193277952,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 249684975,
|
||||
"delta_tx_bytes": 249854149,
|
||||
"baseline_rss_bytes": 257658880,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 208244736,
|
||||
"heap_used": 49103680,
|
||||
"external": 38092148,
|
||||
"array_buffers": 31938886
|
||||
"rss": 258445312,
|
||||
"heap_used": 50586328,
|
||||
"external": 54821684,
|
||||
"array_buffers": 51025026
|
||||
},
|
||||
"delta_rss_bytes": 14966784,
|
||||
"delta_rss_bytes": 786432,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.claim_expired": 1,
|
||||
"attachments.decode.ms": 319.71605499990983,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 249670108,
|
||||
"delta_tx_bytes": 249826185,
|
||||
"baseline_rss_bytes": 178913280,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 249696173,
|
||||
"delta_tx_bytes": 249850753,
|
||||
"baseline_rss_bytes": 242159616,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 195375104,
|
||||
"heap_used": 48823672,
|
||||
"external": 30056217,
|
||||
"array_buffers": 26265873
|
||||
"rss": 263458816,
|
||||
"heap_used": 50272920,
|
||||
"external": 64509948,
|
||||
"array_buffers": 60710825
|
||||
},
|
||||
"delta_rss_bytes": 16461824,
|
||||
"delta_rss_bytes": 21299200,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.decode.ms": 417.5356929998379,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
"attachments.upload.created": 25,
|
||||
"attachments.claim_expired": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 499390107,
|
||||
"total_delta_tx_bytes": 499691151,
|
||||
"rx_bytes_per_upload": 9987802,
|
||||
"tx_bytes_per_upload": 9993823,
|
||||
"max_delta_rss_bytes": 16461824
|
||||
"total_delta_rx_bytes": 499381148,
|
||||
"total_delta_tx_bytes": 499704902,
|
||||
"rx_bytes_per_upload": 9987623,
|
||||
"tx_bytes_per_upload": 9994098,
|
||||
"max_delta_rss_bytes": 21299200
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 3.32,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 2.962,
|
||||
"latency_ms": {
|
||||
"p50": 277.4,
|
||||
"p95": 513.9,
|
||||
"p99": 548.1
|
||||
"p50": 218.3,
|
||||
"p95": 399.3,
|
||||
"p99": 460.0
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 249653538,
|
||||
"delta_tx_bytes": 249812864,
|
||||
"baseline_rss_bytes": 193380352,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 249696535,
|
||||
"delta_tx_bytes": 249834513,
|
||||
"baseline_rss_bytes": 258445312,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 208535552,
|
||||
"heap_used": 49665920,
|
||||
"external": 36105007,
|
||||
"array_buffers": 32313340
|
||||
"rss": 278368256,
|
||||
"heap_used": 51479592,
|
||||
"external": 64969358,
|
||||
"array_buffers": 60432585
|
||||
},
|
||||
"delta_rss_bytes": 15155200,
|
||||
"delta_rss_bytes": 19922944,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.claim_expired": 1,
|
||||
"attachments.decode.ms": 418.99375499994494,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 249644423,
|
||||
"delta_tx_bytes": 249817785,
|
||||
"baseline_rss_bytes": 194199552,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 249668505,
|
||||
"delta_tx_bytes": 249828657,
|
||||
"baseline_rss_bytes": 263458816,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 208871424,
|
||||
"heap_used": 50742312,
|
||||
"external": 43475182,
|
||||
"array_buffers": 39684838
|
||||
"rss": 286236672,
|
||||
"heap_used": 50811912,
|
||||
"external": 98237420,
|
||||
"array_buffers": 75492114
|
||||
},
|
||||
"delta_rss_bytes": 14671872,
|
||||
"delta_rss_bytes": 22777856,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.claim_expired": 1,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.decode.ms": 377.89479400013806,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 499297961,
|
||||
"total_delta_tx_bytes": 499630649,
|
||||
"rx_bytes_per_upload": 9985959,
|
||||
"tx_bytes_per_upload": 9992613,
|
||||
"max_delta_rss_bytes": 15155200
|
||||
"total_delta_rx_bytes": 499365040,
|
||||
"total_delta_tx_bytes": 499663170,
|
||||
"rx_bytes_per_upload": 9987301,
|
||||
"tx_bytes_per_upload": 9993263,
|
||||
"max_delta_rss_bytes": 22777856
|
||||
},
|
||||
{
|
||||
"uploads": 50,
|
||||
"succeeded": 50,
|
||||
"failed": 0,
|
||||
"duration_s": 3.07,
|
||||
"outcomes": {
|
||||
"ok": 50
|
||||
},
|
||||
"duration_s": 2.985,
|
||||
"latency_ms": {
|
||||
"p50": 238.9,
|
||||
"p95": 391.0,
|
||||
"p99": 423.1
|
||||
"p50": 244.7,
|
||||
"p95": 375.1,
|
||||
"p99": 434.8
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 249690323,
|
||||
"delta_tx_bytes": 249843279,
|
||||
"baseline_rss_bytes": 193445888,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 249713919,
|
||||
"delta_tx_bytes": 249869668,
|
||||
"baseline_rss_bytes": 278368256,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 212447232,
|
||||
"heap_used": 48981896,
|
||||
"external": 28322088,
|
||||
"array_buffers": 24531744
|
||||
"rss": 280072192,
|
||||
"heap_used": 51096488,
|
||||
"external": 54668040,
|
||||
"array_buffers": 50874378
|
||||
},
|
||||
"delta_rss_bytes": 19001344,
|
||||
"delta_rss_bytes": 1703936,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.decode.ms": 335.8925800000434,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 249684428,
|
||||
"delta_tx_bytes": 249830235,
|
||||
"baseline_rss_bytes": 200146944,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 249686633,
|
||||
"delta_tx_bytes": 249847874,
|
||||
"baseline_rss_bytes": 243417088,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 200146944,
|
||||
"heap_used": 48496592,
|
||||
"external": 26712221,
|
||||
"array_buffers": 22921877
|
||||
"rss": 253378560,
|
||||
"heap_used": 50078992,
|
||||
"external": 54471131,
|
||||
"array_buffers": 50675083
|
||||
},
|
||||
"delta_rss_bytes": 0,
|
||||
"delta_rss_bytes": 9961472,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 25,
|
||||
"attachments.proxy.bytes_in": 249036800,
|
||||
"attachments.decode.ms": 318.2283639999805,
|
||||
"attachments.proxy.bytes_to_s3": 249036800,
|
||||
"attachments.mark_ready": 25,
|
||||
"attachments.upload.created": 25
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 499374751,
|
||||
"total_delta_tx_bytes": 499673514,
|
||||
"rx_bytes_per_upload": 9987495,
|
||||
"tx_bytes_per_upload": 9993470,
|
||||
"max_delta_rss_bytes": 19001344
|
||||
"total_delta_rx_bytes": 499400552,
|
||||
"total_delta_tx_bytes": 499717542,
|
||||
"rx_bytes_per_upload": 9988011,
|
||||
"tx_bytes_per_upload": 9994351,
|
||||
"max_delta_rss_bytes": 9961472
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1,195 +1,212 @@
|
||||
{
|
||||
"date": "2026-10-22T20:03:09+00:00",
|
||||
"git": "f048a37",
|
||||
"date": "2026-10-23T14:20:13+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "proxy",
|
||||
"size_bytes": 9961472,
|
||||
"concurrency": 20,
|
||||
"uploads_per_worker": 5,
|
||||
"repeat": 3
|
||||
"repeat": 3,
|
||||
"users": 20,
|
||||
"image": null
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 805306368",
|
||||
"1500000000 805306368"
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 100,
|
||||
"succeeded": 100,
|
||||
"failed": 0,
|
||||
"duration_s": 5.789,
|
||||
"outcomes": {
|
||||
"ok": 100
|
||||
},
|
||||
"duration_s": 6.03,
|
||||
"latency_ms": {
|
||||
"p50": 409.2,
|
||||
"p95": 812.5,
|
||||
"p99": 959.0
|
||||
"p50": 446.3,
|
||||
"p95": 781.2,
|
||||
"p99": 875.5
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 499859990,
|
||||
"delta_tx_bytes": 500110302,
|
||||
"baseline_rss_bytes": 189095936,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 499450818,
|
||||
"delta_tx_bytes": 499682679,
|
||||
"baseline_rss_bytes": 260186112,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 209506304,
|
||||
"heap_used": 49551104,
|
||||
"external": 37459480,
|
||||
"array_buffers": 28998398
|
||||
"rss": 270147584,
|
||||
"heap_used": 50815808,
|
||||
"external": 74823876,
|
||||
"array_buffers": 71026869
|
||||
},
|
||||
"delta_rss_bytes": 20410368,
|
||||
"delta_rss_bytes": 9961472,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 747.5779010000988,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 499688844,
|
||||
"delta_tx_bytes": 499961376,
|
||||
"baseline_rss_bytes": 179896320,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 499478040,
|
||||
"delta_tx_bytes": 499706687,
|
||||
"baseline_rss_bytes": 233414656,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 201883648,
|
||||
"heap_used": 48903104,
|
||||
"external": 30171785,
|
||||
"array_buffers": 23259151
|
||||
"rss": 272007168,
|
||||
"heap_used": 51073272,
|
||||
"external": 81928377,
|
||||
"array_buffers": 78003733
|
||||
},
|
||||
"delta_rss_bytes": 21987328,
|
||||
"delta_rss_bytes": 38592512,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 729.9557609999902,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 999548834,
|
||||
"total_delta_tx_bytes": 1000071678,
|
||||
"rx_bytes_per_upload": 9995488,
|
||||
"tx_bytes_per_upload": 10000717,
|
||||
"max_delta_rss_bytes": 21987328
|
||||
"total_delta_rx_bytes": 998928858,
|
||||
"total_delta_tx_bytes": 999389366,
|
||||
"rx_bytes_per_upload": 9989289,
|
||||
"tx_bytes_per_upload": 9993894,
|
||||
"max_delta_rss_bytes": 38592512
|
||||
},
|
||||
{
|
||||
"uploads": 100,
|
||||
"succeeded": 100,
|
||||
"failed": 0,
|
||||
"duration_s": 5.789,
|
||||
"outcomes": {
|
||||
"ok": 100
|
||||
},
|
||||
"duration_s": 5.959,
|
||||
"latency_ms": {
|
||||
"p50": 406.7,
|
||||
"p95": 756.8,
|
||||
"p99": 1110.8
|
||||
"p50": 433.3,
|
||||
"p95": 826.3,
|
||||
"p99": 1157.3
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 499409660,
|
||||
"delta_tx_bytes": 499704231,
|
||||
"baseline_rss_bytes": 204034048,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 499374042,
|
||||
"delta_tx_bytes": 499651950,
|
||||
"baseline_rss_bytes": 270147584,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 216682496,
|
||||
"heap_used": 50958080,
|
||||
"external": 42044393,
|
||||
"array_buffers": 38254049
|
||||
"rss": 272506880,
|
||||
"heap_used": 51829328,
|
||||
"external": 83084989,
|
||||
"array_buffers": 79288011
|
||||
},
|
||||
"delta_rss_bytes": 12648448,
|
||||
"delta_rss_bytes": 2359296,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 779.4219730002806,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 499385236,
|
||||
"delta_tx_bytes": 499657364,
|
||||
"baseline_rss_bytes": 196177920,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 499493122,
|
||||
"delta_tx_bytes": 499744106,
|
||||
"baseline_rss_bytes": 223895552,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 208781312,
|
||||
"heap_used": 49416712,
|
||||
"external": 29886702,
|
||||
"array_buffers": 26096358
|
||||
"rss": 268492800,
|
||||
"heap_used": 51545968,
|
||||
"external": 74440258,
|
||||
"array_buffers": 70643266
|
||||
},
|
||||
"delta_rss_bytes": 12603392,
|
||||
"delta_rss_bytes": 44597248,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 863.9362580000306,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 998794896,
|
||||
"total_delta_tx_bytes": 999361595,
|
||||
"rx_bytes_per_upload": 9987949,
|
||||
"tx_bytes_per_upload": 9993616,
|
||||
"max_delta_rss_bytes": 12648448
|
||||
"total_delta_rx_bytes": 998867164,
|
||||
"total_delta_tx_bytes": 999396056,
|
||||
"rx_bytes_per_upload": 9988672,
|
||||
"tx_bytes_per_upload": 9993961,
|
||||
"max_delta_rss_bytes": 44597248
|
||||
},
|
||||
{
|
||||
"uploads": 100,
|
||||
"succeeded": 100,
|
||||
"failed": 0,
|
||||
"duration_s": 6.222,
|
||||
"outcomes": {
|
||||
"ok": 100
|
||||
},
|
||||
"duration_s": 5.867,
|
||||
"latency_ms": {
|
||||
"p50": 452.3,
|
||||
"p95": 913.7,
|
||||
"p99": 1284.1
|
||||
"p50": 425.4,
|
||||
"p95": 748.6,
|
||||
"p99": 899.5
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "01e84e9e9e38",
|
||||
"delta_rx_bytes": 499462554,
|
||||
"delta_tx_bytes": 499707805,
|
||||
"baseline_rss_bytes": 208515072,
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 499413858,
|
||||
"delta_tx_bytes": 499718735,
|
||||
"baseline_rss_bytes": 272506880,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 213237760,
|
||||
"heap_used": 50201400,
|
||||
"external": 39684000,
|
||||
"array_buffers": 35893464
|
||||
"rss": 282468352,
|
||||
"heap_used": 51214136,
|
||||
"external": 94183394,
|
||||
"array_buffers": 90388084
|
||||
},
|
||||
"delta_rss_bytes": 4722688,
|
||||
"delta_rss_bytes": 9961472,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 737.3356790000107,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "d49b799653d6",
|
||||
"delta_rx_bytes": 499435292,
|
||||
"delta_tx_bytes": 499704897,
|
||||
"baseline_rss_bytes": 192315392,
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 499436776,
|
||||
"delta_tx_bytes": 499691520,
|
||||
"baseline_rss_bytes": 224206848,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 209580032,
|
||||
"heap_used": 50343440,
|
||||
"external": 38677040,
|
||||
"array_buffers": 34886696
|
||||
"rss": 287236096,
|
||||
"heap_used": 51412744,
|
||||
"external": 94514510,
|
||||
"array_buffers": 90719177
|
||||
},
|
||||
"delta_rss_bytes": 17264640,
|
||||
"delta_rss_bytes": 63029248,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 50,
|
||||
"attachments.proxy.bytes_in": 498073600,
|
||||
"attachments.decode.ms": 632.1155839997809,
|
||||
"attachments.proxy.bytes_to_s3": 498073600,
|
||||
"attachments.mark_ready": 50,
|
||||
"attachments.upload.created": 50
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 998897846,
|
||||
"total_delta_tx_bytes": 999412702,
|
||||
"rx_bytes_per_upload": 9988978,
|
||||
"tx_bytes_per_upload": 9994127,
|
||||
"max_delta_rss_bytes": 17264640
|
||||
"total_delta_rx_bytes": 998850634,
|
||||
"total_delta_tx_bytes": 999410255,
|
||||
"rx_bytes_per_upload": 9988506,
|
||||
"tx_bytes_per_upload": 9994103,
|
||||
"max_delta_rss_bytes": 63029248
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
{
|
||||
"date": "2026-10-23T14:21:43+00:00",
|
||||
"git": "9caa031",
|
||||
"params": {
|
||||
"mode": "proxy",
|
||||
"size_bytes": 10485760,
|
||||
"concurrency": 32,
|
||||
"uploads_per_worker": 2,
|
||||
"repeat": 3,
|
||||
"users": 32,
|
||||
"image": "worst-40mp-rgba16-adam7.png"
|
||||
},
|
||||
"host": {
|
||||
"nproc": 8,
|
||||
"mem_total_bytes": 16538955776
|
||||
},
|
||||
"api_container_limits_nanocpus_memory": [
|
||||
"1500000000 1073741824",
|
||||
"1500000000 1073741824"
|
||||
],
|
||||
"repeats": [
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 63,
|
||||
"failed": 1,
|
||||
"outcomes": {
|
||||
"ok": 63,
|
||||
"upload:429": 1
|
||||
},
|
||||
"duration_s": 26.314,
|
||||
"latency_ms": {
|
||||
"p50": 11982.1,
|
||||
"p95": 13221.2,
|
||||
"p99": 13881.3
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 337116624,
|
||||
"delta_tx_bytes": 326709435,
|
||||
"baseline_rss_bytes": 280637440,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 794800128,
|
||||
"heap_used": 52577168,
|
||||
"external": 200629533,
|
||||
"array_buffers": 196839189
|
||||
},
|
||||
"delta_rss_bytes": 514162688,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 31,
|
||||
"attachments.proxy.bytes_in": 325058560,
|
||||
"attachments.decode.ms": 25555.52753299987,
|
||||
"attachments.proxy.bytes_to_s3": 325058560,
|
||||
"attachments.mark_ready": 31,
|
||||
"attachments.upload.created": 31
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 337265287,
|
||||
"delta_tx_bytes": 337358402,
|
||||
"baseline_rss_bytes": 243548160,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 810434560,
|
||||
"heap_used": 53145984,
|
||||
"external": 236705259,
|
||||
"array_buffers": 220341467
|
||||
},
|
||||
"delta_rss_bytes": 566886400,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 32,
|
||||
"attachments.proxy.bytes_in": 335544320,
|
||||
"attachments.decode.ms": 26139.059334000223,
|
||||
"attachments.proxy.bytes_to_s3": 335544320,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.upload.created": 32
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 674381911,
|
||||
"total_delta_tx_bytes": 664067837,
|
||||
"rx_bytes_per_upload": 10537217,
|
||||
"tx_bytes_per_upload": 10376060,
|
||||
"max_delta_rss_bytes": 566886400
|
||||
},
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 63,
|
||||
"failed": 1,
|
||||
"outcomes": {
|
||||
"ok": 63,
|
||||
"upload:429": 1
|
||||
},
|
||||
"duration_s": 26.067,
|
||||
"latency_ms": {
|
||||
"p50": 11840.4,
|
||||
"p95": 12960.2,
|
||||
"p99": 13468.5
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 336715328,
|
||||
"delta_tx_bytes": 326375446,
|
||||
"baseline_rss_bytes": 440582144,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 792059904,
|
||||
"heap_used": 56538592,
|
||||
"external": 222265987,
|
||||
"array_buffers": 218475643
|
||||
},
|
||||
"delta_rss_bytes": 351477760,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 31,
|
||||
"attachments.proxy.bytes_in": 325058560,
|
||||
"attachments.decode.ms": 25179.0629260001,
|
||||
"attachments.proxy.bytes_to_s3": 325058560,
|
||||
"attachments.mark_ready": 31,
|
||||
"attachments.upload.created": 31
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 336711646,
|
||||
"delta_tx_bytes": 336796533,
|
||||
"baseline_rss_bytes": 456798208,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 804114432,
|
||||
"heap_used": 56361496,
|
||||
"external": 227834931,
|
||||
"array_buffers": 224044587
|
||||
},
|
||||
"delta_rss_bytes": 347316224,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 32,
|
||||
"attachments.proxy.bytes_in": 335544320,
|
||||
"attachments.decode.ms": 25936.202234999975,
|
||||
"attachments.proxy.bytes_to_s3": 335544320,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.upload.created": 32
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 673426974,
|
||||
"total_delta_tx_bytes": 663171979,
|
||||
"rx_bytes_per_upload": 10522296,
|
||||
"tx_bytes_per_upload": 10362062,
|
||||
"max_delta_rss_bytes": 351477760
|
||||
},
|
||||
{
|
||||
"uploads": 64,
|
||||
"succeeded": 64,
|
||||
"failed": 0,
|
||||
"outcomes": {
|
||||
"ok": 64
|
||||
},
|
||||
"duration_s": 26.191,
|
||||
"latency_ms": {
|
||||
"p50": 12369.3,
|
||||
"p95": 13068.5,
|
||||
"p99": 13838.5
|
||||
},
|
||||
"replicas": [
|
||||
{
|
||||
"instance_id": "90e2e1d73b23",
|
||||
"delta_rx_bytes": 336907021,
|
||||
"delta_tx_bytes": 336990630,
|
||||
"baseline_rss_bytes": 438906880,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 812994560,
|
||||
"heap_used": 53308256,
|
||||
"external": 217363492,
|
||||
"array_buffers": 213573148
|
||||
},
|
||||
"delta_rss_bytes": 374087680,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 32,
|
||||
"attachments.proxy.bytes_in": 335544320,
|
||||
"attachments.decode.ms": 25964.192683000234,
|
||||
"attachments.proxy.bytes_to_s3": 335544320,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.upload.created": 32,
|
||||
"attachments.claim_expired": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"instance_id": "9bb9a19b4693",
|
||||
"delta_rx_bytes": 336764548,
|
||||
"delta_tx_bytes": 336853328,
|
||||
"baseline_rss_bytes": 451035136,
|
||||
"peak_memory_bytes": {
|
||||
"rss": 822910976,
|
||||
"heap_used": 51718280,
|
||||
"external": 238155032,
|
||||
"array_buffers": 234364688
|
||||
},
|
||||
"delta_rss_bytes": 371875840,
|
||||
"counters": {
|
||||
"attachments.insert_pending": 32,
|
||||
"attachments.proxy.bytes_in": 335544320,
|
||||
"attachments.decode.ms": 25902.83660300006,
|
||||
"attachments.proxy.bytes_to_s3": 335544320,
|
||||
"attachments.mark_ready": 32,
|
||||
"attachments.upload.created": 32,
|
||||
"attachments.claim_expired": 1
|
||||
}
|
||||
}
|
||||
],
|
||||
"total_delta_rx_bytes": 673671569,
|
||||
"total_delta_tx_bytes": 673843958,
|
||||
"rx_bytes_per_upload": 10526118,
|
||||
"tx_bytes_per_upload": 10528812,
|
||||
"max_delta_rss_bytes": 374087680
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
scripts/lab4/consistency_check.sh
|
||||
bucket: messenger-attachments
|
||||
objects: 2580
|
||||
objects: 8398
|
||||
rows by status:
|
||||
33 pending
|
||||
2577 ready
|
||||
6 rejected
|
||||
84 pending
|
||||
8324 ready
|
||||
4 rejected
|
||||
orphans: 0
|
||||
missing: 0
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# container /mtusi-lab4-api-1, memory limit 1073741824 bytes, VIPS_DISC_THRESHOLD=1g, commit 4b53e03; same pipeline as ImageDecoder
|
||||
jpeg 7728x5152 3ch uchar bytes=4921012 decode_ms=61 peak_delta_rss_mib=4.5 ok
|
||||
jpeg 7728x5152 3ch uchar progressive bytes=4826968 decode_ms=273 peak_delta_rss_mib=118.1 ok
|
||||
jpeg 7728x5152 4ch uchar bytes=10601868 decode_ms=159 peak_delta_rss_mib=7.5 ok
|
||||
png 8000x5000 4ch ushort bytes=1420114 decode_ms=524 peak_delta_rss_mib=67.1 ok
|
||||
png 8000x5000 4ch ushort progressive bytes=364096 decode_ms=1231 peak_delta_rss_mib=338.5 ok
|
||||
png 8000x5000 3ch uchar progressive palette bytes=61042 decode_ms=356 peak_delta_rss_mib=126.0 ok
|
||||
png 8000x5000 4ch ushort progressive bytes=10485760 decode_ms=707 peak_delta_rss_mib=338.4 ok
|
||||
@@ -3,6 +3,6 @@
|
||||
The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
|
||||
RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app
|
||||
Test Files 1 passed (1)
|
||||
Tests 7 passed (7)
|
||||
Start at 23:00:12
|
||||
Duration 8.41s (transform 64ms, setup 0ms, import 94ms, tests 8.16s, environment 0ms)
|
||||
Tests 10 passed (10)
|
||||
Start at 17:11:07
|
||||
Duration 8.19s (transform 48ms, setup 0ms, import 72ms, tests 8.02s, environment 0ms)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
# attachment download survives the stop of either replica (sha256 of sample.png: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75)
|
||||
# commit 9caa031; attachment download survives the stop of either replica (sha256 of sample.png: 99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75)
|
||||
stopped mtusi-lab4-api-1
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: fc61f806b880 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: fc61f806b880 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: fc61f806b880 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 9bb9a19b4693 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 9bb9a19b4693 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 9bb9a19b4693 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
stopped mtusi-lab4-api-2
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: b50bb8514a7b sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: b50bb8514a7b sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: b50bb8514a7b sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 90e2e1d73b23 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 90e2e1d73b23 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
GET content -> HTTP/1.1 200 OK x-instance-id: 90e2e1d73b23 sha256=99ea7533c441f79cd630d15ce4d58d1ec4e06f6f0efb3b77a5c088305cd1bd75
|
||||
mtusi-lab4-api-1 Up 14 seconds (healthy)
|
||||
mtusi-lab4-api-2 Up 5 seconds (healthy)
|
||||
|
||||
@@ -1,21 +1,13 @@
|
||||
# commit 9caa031
|
||||
# failover round 1
|
||||
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8080"
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 140, "failed_attempts": 0, "first_recovery_seconds": 3.331}
|
||||
{"observed_instances_before": 2, "successful_writes": 133, "failed_attempts": 0, "first_recovery_seconds": 3.184}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
api mtusi-lab4-api-1 Up 26 seconds (healthy)
|
||||
Container mtusi-lab4-api-1 Running
|
||||
mtusi-lab4-api-1 Exited (0) 12 seconds ago
|
||||
mtusi-lab4-api-2 Up 31 seconds (healthy)
|
||||
# failover round 2
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 134, "failed_attempts": 0, "first_recovery_seconds": 3.359}
|
||||
{"observed_instances_before": 2, "successful_writes": 141, "failed_attempts": 0, "first_recovery_seconds": 3.249}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
mtusi-lab4-api-1 Up 50 seconds (healthy)
|
||||
mtusi-lab4-api-2 Exited (0) 12 seconds ago
|
||||
# failover round 3
|
||||
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
|
||||
{"observed_instances_before": 2, "successful_writes": 134, "failed_attempts": 0, "first_recovery_seconds": 3.328}
|
||||
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
mtusi-lab4-api-1 Up About a minute (healthy)
|
||||
mtusi-lab4-api-2 Exited (0) 12 seconds ago
|
||||
mtusi-lab4-api-1 Up About a minute (healthy)
|
||||
mtusi-lab4-api-2 Up 5 seconds (healthy)
|
||||
mtusi-lab4-api-1 Exited (0) 12 seconds ago
|
||||
mtusi-lab4-api-2 Up 53 seconds (healthy)
|
||||
mtusi-lab4-api-1 Up 5 seconds (healthy)
|
||||
mtusi-lab4-api-2 Up 58 seconds (healthy)
|
||||
|
||||
@@ -4,6 +4,6 @@ cd app && E2E_COMPOSE_DIR="/home/tomato/Projects/VP/mtusi2026lab4" E2E_COMPOSE_E
|
||||
The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
|
||||
RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app
|
||||
Test Files 1 passed (1)
|
||||
Tests 6 passed (6)
|
||||
Start at 23:00:31
|
||||
Duration 88.83s (transform 48ms, setup 0ms, import 73ms, tests 88.65s, environment 0ms)
|
||||
Tests 7 passed (7)
|
||||
Start at 17:11:25
|
||||
Duration 140.04s (transform 65ms, setup 0ms, import 80ms, tests 139.87s, environment 0ms)
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
|
||||
RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app
|
||||
Test Files 3 passed | 1 skipped (4)
|
||||
Tests 34 passed | 8 skipped (42)
|
||||
Start at 22:59:53
|
||||
Duration 4.87s (transform 409ms, setup 0ms, import 764ms, tests 9.39s, environment 0ms)
|
||||
Tests 44 passed | 9 skipped (53)
|
||||
Start at 17:10:37
|
||||
Duration 6.55s (transform 310ms, setup 0ms, import 591ms, tests 12.84s, environment 0ms)
|
||||
|
||||
@@ -1,29 +1,18 @@
|
||||
# commit 9caa031
|
||||
# before
|
||||
api Up 19 seconds (healthy)
|
||||
api Up 19 seconds (healthy)
|
||||
haproxy Up 11 minutes
|
||||
postgres Up 2 minutes (healthy)
|
||||
redis Up 3 minutes (healthy)
|
||||
s3 Up 3 minutes (healthy)
|
||||
/mtusi-lab4-postgres-1 2026-10-22T19:38:19.352217508Z
|
||||
/mtusi-lab4-redis-1 2026-10-22T19:37:15.343086395Z
|
||||
/mtusi-lab4-s3-1 2026-10-22T19:37:46.289807129Z
|
||||
/mtusi-lab4-api-1 2026-10-22T19:40:39.879853813Z
|
||||
/mtusi-lab4-api-2 2026-10-22T19:40:39.774525559Z
|
||||
/mtusi-lab4-haproxy-1 2026-10-22T19:29:53.978761189Z
|
||||
/mtusi-lab4-postgres-1 2026-10-23T14:13:29.263262079Z
|
||||
/mtusi-lab4-redis-1 2026-10-23T14:11:34.042926489Z
|
||||
/mtusi-lab4-s3-1 2026-10-23T14:12:05.200412031Z
|
||||
/mtusi-lab4-api-1 2026-10-23T14:11:19.011665615Z
|
||||
/mtusi-lab4-api-2 2026-10-23T14:11:19.118116521Z
|
||||
/mtusi-lab4-haproxy-1 2026-10-22T19:41:00.434084255Z
|
||||
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8080"
|
||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||
# after
|
||||
api Up 6 seconds (healthy)
|
||||
api Up 6 seconds (healthy)
|
||||
haproxy Up 9 seconds
|
||||
postgres Up 9 seconds (healthy)
|
||||
redis Up 9 seconds (healthy)
|
||||
s3 Up 9 seconds (healthy)
|
||||
/mtusi-lab4-postgres-1 2026-10-22T19:41:00.616425802Z
|
||||
/mtusi-lab4-redis-1 2026-10-22T19:41:00.545701172Z
|
||||
/mtusi-lab4-s3-1 2026-10-22T19:41:00.507714044Z
|
||||
/mtusi-lab4-api-1 2026-10-22T19:41:03.631509569Z
|
||||
/mtusi-lab4-api-2 2026-10-22T19:41:03.665389961Z
|
||||
/mtusi-lab4-haproxy-1 2026-10-22T19:41:00.434084255Z
|
||||
/mtusi-lab4-postgres-1 2026-10-23T14:23:26.500579665Z
|
||||
/mtusi-lab4-redis-1 2026-10-23T14:23:26.233233745Z
|
||||
/mtusi-lab4-s3-1 2026-10-23T14:23:26.420908434Z
|
||||
/mtusi-lab4-api-1 2026-10-23T14:23:29.194759152Z
|
||||
/mtusi-lab4-api-2 2026-10-23T14:23:29.224476065Z
|
||||
/mtusi-lab4-haproxy-1 2026-10-23T14:23:26.32966444Z
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
| mode | size, MiB | C | ok | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | p50, ms | p95, ms |
|
||||
|---|---|---|---|---|---|---|---|---|
|
||||
| direct | 0.12 | 10 | 150/150 | 0.07 | 0.01 | 0.40 | 45 | 65 |
|
||||
| proxy | 0.12 | 10 | 150/150 | 0.13 | 0.13 | 3.78 | 32 | 62 |
|
||||
| direct | 1.00 | 10 | 150/150 | 0.07 | 0.01 | 0.75 | 75 | 137 |
|
||||
| proxy | 1.00 | 10 | 150/150 | 1.01 | 1.01 | 4.38 | 59 | 110 |
|
||||
| direct | 9.50 | 10 | 150/150 | 0.07 | 0.01 | 0.88 | 346 | 571 |
|
||||
| proxy | 9.50 | 10 | 150/150 | 9.52 | 9.53 | 15.70 | 239 | 394 |
|
||||
| proxy | 9.50 | 20 | 300/300 | 9.53 | 9.53 | 16.46 | 409 | 812 |
|
||||
| mode | size, MiB | C | ok | failures | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | peak RSS, MiB | p50, ms | p95, ms |
|
||||
|---|---|---|---|---|---|---|---|---|---|---|
|
||||
| direct | 0.12 | 10 | 150/150 | — | 0.13 | 0.01 | 0.38 | 394.39 | 40 | 71 |
|
||||
| proxy | 0.12 | 10 | 150/150 | — | 0.13 | 0.13 | 0.00 | 446.99 | 26 | 46 |
|
||||
| direct | 1.00 | 10 | 150/150 | — | 1.01 | 0.01 | 0.00 | 244.16 | 71 | 107 |
|
||||
| proxy | 1.00 | 10 | 150/150 | — | 1.01 | 1.01 | 0.12 | 394.70 | 50 | 82 |
|
||||
| direct | 9.50 | 10 | 150/150 | — | 9.52 | 0.01 | 67.06 | 344.15 | 448 | 672 |
|
||||
| proxy | 9.50 | 10 | 150/150 | — | 9.52 | 9.53 | 20.31 | 272.98 | 245 | 399 |
|
||||
| proxy | 9.50 | 20 | 300/300 | — | 9.53 | 9.53 | 42.53 | 273.93 | 433 | 781 |
|
||||
| direct (worst-40mp-rgba16-adam7.png) | 10.00 | 32 | 167/192 | complete:429×25 | 9.24 | 0.01 | 366.88 | 790.94 | 11067 | 13423 |
|
||||
| proxy (worst-40mp-rgba16-adam7.png) | 10.00 | 32 | 190/192 | upload:429×2 | 10.04 | 9.90 | 356.76 | 784.79 | 11982 | 13068 |
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
The plugin "vite-tsconfig-paths" is detected. Vite now supports tsconfig paths resolution natively via the resolve.tsconfigPaths option. You can remove the plugin and set resolve.tsconfigPaths: true in your Vite config instead.
|
||||
RUN v4.1.11 /home/tomato/Projects/VP/mtusi2026lab4/app
|
||||
[Nest] 3057161 - 10/22/2026, 10:44:47 PM WARN [MessagesCacheService] Cache read failed, serving PostgreSQL: redis down
|
||||
[Nest] 3057161 - 10/22/2026, 10:44:47 PM WARN [MessagesCacheService] Cache fill failed: redis down
|
||||
Test Files 10 passed (10)
|
||||
Tests 36 passed (36)
|
||||
Start at 22:44:46
|
||||
Duration 1.93s (transform 718ms, setup 0ms, import 5.44s, tests 373ms, environment 1ms)
|
||||
[Nest] 4013602 - 10/23/2026, 5:10:35 PM WARN [MessagesCacheService] Cache fill failed: redis down
|
||||
[Nest] 4013620 - 10/23/2026, 5:10:37 PM WARN [AttachmentsService] Compensation of attachment 2dc5fe05-aac7-484f-935e-186a935e9224 deferred: Connection terminated unexpectedly
|
||||
Test Files 13 passed (13)
|
||||
Tests 48 passed (48)
|
||||
Start at 17:10:34
|
||||
Duration 2.68s (transform 652ms, setup 0ms, import 8.56s, tests 1.95s, environment 2ms)
|
||||
|
||||
@@ -104,59 +104,84 @@ def percentile(values, fraction):
|
||||
|
||||
|
||||
def one_upload(env, mode, token, chat_id, data, seed):
|
||||
"""Returns (ok, elapsed_ms, outcome); outcome names the failing step and status, e.g. "complete:429"."""
|
||||
digest = hashlib.sha256(data).hexdigest()
|
||||
filename = f"bench-{seed}.png"
|
||||
port = int(env.get("APP_PUBLIC_PORT", "8080"))
|
||||
started = time.perf_counter()
|
||||
if mode == "proxy":
|
||||
status, payload = request(
|
||||
"127.0.0.1", port, "POST",
|
||||
f"/api/v1/chats/{chat_id}/attachments?filename={urllib.parse.quote(filename)}",
|
||||
{"authorization": f"Bearer {token}", "content-type": "image/png"}, data,
|
||||
)
|
||||
ok = status == 201
|
||||
attachment = json.loads(payload) if ok else None
|
||||
else:
|
||||
status, ticket = api_json(
|
||||
env, "POST", f"/api/v1/chats/{chat_id}/attachments/direct-uploads", token,
|
||||
{"filename": filename, "content_type": "image/png", "size_bytes": len(data), "sha256": digest},
|
||||
)
|
||||
ok = status == 201
|
||||
attachment = None
|
||||
if ok:
|
||||
target = urllib.parse.urlsplit(ticket["url"])
|
||||
put_status, _ = request(
|
||||
target.hostname, target.port, "PUT", target.path + "?" + target.query,
|
||||
{**ticket["headers"]}, data,
|
||||
outcome, attachment = "ok", None
|
||||
try:
|
||||
if mode == "proxy":
|
||||
status, body = request(
|
||||
"127.0.0.1", port, "POST",
|
||||
f"/api/v1/chats/{chat_id}/attachments?filename={urllib.parse.quote(filename)}",
|
||||
{"authorization": f"Bearer {token}", "content-type": "image/png"}, data,
|
||||
)
|
||||
ok = put_status == 200
|
||||
if ok:
|
||||
status, attachment = api_json(
|
||||
env, "POST", f"/api/v1/attachments/{ticket['attachment_id']}/complete", token
|
||||
if status == 201:
|
||||
attachment = json.loads(body)
|
||||
else:
|
||||
outcome = f"upload:{status}"
|
||||
else:
|
||||
headers = {"authorization": f"Bearer {token}", "content-type": "application/json"}
|
||||
status, body = request(
|
||||
"127.0.0.1", port, "POST", f"/api/v1/chats/{chat_id}/attachments/direct-uploads", headers,
|
||||
json.dumps({"filename": filename, "content_type": "image/png",
|
||||
"size_bytes": len(data), "sha256": digest}).encode(),
|
||||
)
|
||||
if status != 201:
|
||||
outcome = f"init:{status}"
|
||||
else:
|
||||
ticket = json.loads(body)
|
||||
target = urllib.parse.urlsplit(ticket["url"])
|
||||
put_status, _ = request(
|
||||
target.hostname, target.port, "PUT", target.path + "?" + target.query,
|
||||
{**ticket["headers"]}, data,
|
||||
)
|
||||
ok = status == 200
|
||||
if put_status != 200:
|
||||
outcome = f"put:{put_status}"
|
||||
else:
|
||||
status, body = request(
|
||||
"127.0.0.1", port, "POST", f"/api/v1/attachments/{ticket['attachment_id']}/complete",
|
||||
{"authorization": f"Bearer {token}"},
|
||||
)
|
||||
if status == 200:
|
||||
attachment = json.loads(body)
|
||||
else:
|
||||
outcome = f"complete:{status}"
|
||||
except (OSError, http.client.HTTPException, ValueError) as error:
|
||||
outcome = f"error:{type(error).__name__}"
|
||||
elapsed_ms = (time.perf_counter() - started) * 1000
|
||||
if ok and (attachment is None or attachment["sha256"] != digest):
|
||||
ok = False
|
||||
return ok, elapsed_ms
|
||||
if outcome == "ok" and (attachment is None or attachment["sha256"] != digest):
|
||||
outcome = "checksum_mismatch"
|
||||
return outcome == "ok", elapsed_ms, outcome
|
||||
|
||||
|
||||
def run_once(env, args, token, chat_id, ids):
|
||||
def payload(args, seed):
|
||||
if args.image:
|
||||
with open(args.image, "rb") as handle:
|
||||
return handle.read()
|
||||
return noise_png(args.size_bytes, seed)
|
||||
|
||||
|
||||
def run_once(env, args, actors, ids):
|
||||
for container in ids:
|
||||
reset_metrics(container)
|
||||
time.sleep(0.2)
|
||||
baseline = {c: metrics(c) for c in ids}
|
||||
net_before = {c: net_bytes(c) for c in ids}
|
||||
latencies, failures = [], []
|
||||
outcomes = {}
|
||||
lock = threading.Lock()
|
||||
|
||||
def worker(index):
|
||||
for step in range(args.uploads_per_worker):
|
||||
seed = index * 1000 + step
|
||||
data = noise_png(args.size_bytes, seed)
|
||||
ok, elapsed = one_upload(env, args.mode, token, chat_id, data, seed)
|
||||
data = payload(args, seed)
|
||||
token, chat_id = actors[index % len(actors)]
|
||||
ok, elapsed, outcome = one_upload(env, args.mode, token, chat_id, data, seed)
|
||||
with lock:
|
||||
(latencies if ok else failures).append(elapsed)
|
||||
outcomes[outcome] = outcomes.get(outcome, 0) + 1
|
||||
|
||||
started = time.perf_counter()
|
||||
threads = [threading.Thread(target=worker, args=(i,)) for i in range(args.concurrency)]
|
||||
@@ -187,6 +212,7 @@ def run_once(env, args, token, chat_id, ids):
|
||||
"uploads": total,
|
||||
"succeeded": len(latencies),
|
||||
"failed": len(failures),
|
||||
"outcomes": outcomes,
|
||||
"duration_s": round(duration, 3),
|
||||
"latency_ms": {
|
||||
"p50": round(percentile(latencies, 0.50), 1),
|
||||
@@ -203,29 +229,39 @@ def run_once(env, args, token, chat_id, ids):
|
||||
|
||||
|
||||
def command_run(args):
|
||||
if args.image:
|
||||
args.size_bytes = os.path.getsize(args.image)
|
||||
if args.size_bytes <= 0:
|
||||
sys.exit("--size-bytes or --image is required")
|
||||
env = read_env()
|
||||
ids = containers()
|
||||
if not ids:
|
||||
sys.exit("no api containers found")
|
||||
name = f"bench_{uuid.uuid4().hex[:10]}"
|
||||
password = "bench:" + uuid.uuid4().hex
|
||||
status, user = api_json(env, "POST", "/api/v1/users",
|
||||
body={"username": name, "display_name": "bench", "password": password})
|
||||
assert status == 201, status
|
||||
status, session = api_json(env, "POST", "/api/v1/auth/sessions", basic=f"{name}:{password}")
|
||||
assert status == 201, status
|
||||
token = session["token"]
|
||||
status, chat = api_json(env, "POST", "/api/v1/chats", token, {"title": "bench", "member_ids": [user["id"]]})
|
||||
assert status == 201, status
|
||||
# One user per worker: the API caps concurrent uploads per user
|
||||
# (UPLOAD_MAX_IN_FLIGHT_PER_USER), and real traffic comes from many users.
|
||||
actors = []
|
||||
for _ in range(args.concurrency):
|
||||
name = f"bench_{uuid.uuid4().hex[:10]}"
|
||||
password = "bench:" + uuid.uuid4().hex
|
||||
status, user = api_json(env, "POST", "/api/v1/users",
|
||||
body={"username": name, "display_name": "bench", "password": password})
|
||||
assert status == 201, status
|
||||
status, session = api_json(env, "POST", "/api/v1/auth/sessions", basic=f"{name}:{password}")
|
||||
assert status == 201, status
|
||||
token = session["token"]
|
||||
status, chat = api_json(env, "POST", "/api/v1/chats", token, {"title": "bench", "member_ids": [user["id"]]})
|
||||
assert status == 201, status
|
||||
actors.append((token, chat["id"]))
|
||||
|
||||
# Warm-up: one upload per replica path, not measured.
|
||||
# Warm-up: two uploads per replica, not measured.
|
||||
for seed in range(len(ids) * 2):
|
||||
one_upload(env, args.mode, token, chat["id"], noise_png(args.size_bytes, 900000 + seed), seed)
|
||||
token, chat_id = actors[seed % len(actors)]
|
||||
one_upload(env, args.mode, token, chat_id, payload(args, 900000 + seed), seed)
|
||||
|
||||
limits = []
|
||||
for c in ids:
|
||||
limits.append(sh("docker", "inspect", "-f", "{{.HostConfig.NanoCpus}} {{.HostConfig.Memory}}", c))
|
||||
repeats = [run_once(env, args, token, chat["id"], ids) for _ in range(args.repeat)]
|
||||
repeats = [run_once(env, args, actors, ids) for _ in range(args.repeat)]
|
||||
mem_total = next(int(l.split()[1]) * 1024 for l in open("/proc/meminfo") if l.startswith("MemTotal"))
|
||||
result = {
|
||||
"date": datetime.now(timezone.utc).isoformat(timespec="seconds"),
|
||||
@@ -233,6 +269,7 @@ def command_run(args):
|
||||
"params": {
|
||||
"mode": args.mode, "size_bytes": args.size_bytes, "concurrency": args.concurrency,
|
||||
"uploads_per_worker": args.uploads_per_worker, "repeat": args.repeat,
|
||||
"users": args.concurrency, "image": os.path.basename(args.image) if args.image else None,
|
||||
},
|
||||
"host": {"nproc": os.cpu_count(), "mem_total_bytes": mem_total},
|
||||
"api_container_limits_nanocpus_memory": limits,
|
||||
@@ -245,7 +282,8 @@ def command_run(args):
|
||||
for index, item in enumerate(repeats):
|
||||
print(f"repeat {index + 1}: ok={item['succeeded']}/{item['uploads']} "
|
||||
f"rx/upload={item['rx_bytes_per_upload']} tx/upload={item['tx_bytes_per_upload']} "
|
||||
f"maxΔrss={item['max_delta_rss_bytes']} p50={item['latency_ms']['p50']}ms")
|
||||
f"maxΔrss={item['max_delta_rss_bytes']} p50={item['latency_ms']['p50']}ms "
|
||||
f"outcomes={item['outcomes']}")
|
||||
|
||||
|
||||
def mib(value):
|
||||
@@ -260,17 +298,25 @@ def command_summarize(args):
|
||||
p = data["params"]
|
||||
reps = data["repeats"]
|
||||
med = lambda key: statistics.median(r[key] for r in reps) # noqa: E731
|
||||
rows.append((p["mode"], p["size_bytes"], p["concurrency"], reps, med, data))
|
||||
rows.sort(key=lambda r: (r[1], r[0], r[2]))
|
||||
print("| mode | size, MiB | C | ok | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | p50, ms | p95, ms |")
|
||||
print("|---|---|---|---|---|---|---|---|---|")
|
||||
label = p["mode"] + (f" ({p['image']})" if p.get("image") else "")
|
||||
rows.append((label, p["size_bytes"], p["concurrency"], reps, med, data))
|
||||
rows.sort(key=lambda r: (r[0].count("("), r[1], r[0], r[2]))
|
||||
print("| mode | size, MiB | C | ok | failures | API rx/upload, MiB | API tx/upload, MiB | max Δrss, MiB | peak RSS, MiB | p50, ms | p95, ms |")
|
||||
print("|---|---|---|---|---|---|---|---|---|---|---|")
|
||||
for mode, size, conc, reps, med, _data in rows:
|
||||
peak = max(x["peak_memory_bytes"]["rss"] for r in reps for x in r["replicas"])
|
||||
failed = {}
|
||||
for rep in reps:
|
||||
for name, count in rep.get("outcomes", {}).items():
|
||||
if name != "ok":
|
||||
failed[name] = failed.get(name, 0) + count
|
||||
failures = ", ".join(f"{name}×{count}" for name, count in sorted(failed.items())) or "—"
|
||||
ok = sum(r["succeeded"] for r in reps)
|
||||
total = sum(r["uploads"] for r in reps)
|
||||
p50 = statistics.median(r["latency_ms"]["p50"] for r in reps)
|
||||
p95 = statistics.median(r["latency_ms"]["p95"] for r in reps)
|
||||
print(f"| {mode} | {mib(size)} | {conc} | {ok}/{total} | {mib(med('rx_bytes_per_upload'))} | "
|
||||
f"{mib(med('tx_bytes_per_upload'))} | {mib(med('max_delta_rss_bytes'))} | {p50:.0f} | {p95:.0f} |")
|
||||
print(f"| {mode} | {mib(size)} | {conc} | {ok}/{total} | {failures} | {mib(med('rx_bytes_per_upload'))} | "
|
||||
f"{mib(med('tx_bytes_per_upload'))} | {mib(med('max_delta_rss_bytes'))} | {mib(peak)} | {p50:.0f} | {p95:.0f} |")
|
||||
|
||||
|
||||
def main():
|
||||
@@ -278,7 +324,8 @@ def main():
|
||||
sub = parser.add_subparsers(dest="command", required=True)
|
||||
run = sub.add_parser("run")
|
||||
run.add_argument("--mode", choices=["proxy", "direct"], required=True)
|
||||
run.add_argument("--size-bytes", type=int, required=True)
|
||||
run.add_argument("--size-bytes", type=int, default=0)
|
||||
run.add_argument("--image", help="upload this file instead of generated noise PNGs")
|
||||
run.add_argument("--concurrency", type=int, default=10)
|
||||
run.add_argument("--uploads-per-worker", type=int, default=5)
|
||||
run.add_argument("--repeat", type=int, default=3)
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Peak RSS of one full decode check with the same sharp pipeline as
|
||||
// app/src/attachments/image/image-decoder.ts, on worst-case inputs near
|
||||
// MAX_IMAGE_PIXELS. Runs where the API runs (same libvips, VIPS_DISC_THRESHOLD):
|
||||
// docker compose exec -T api node - < scripts/lab4/decode_memory.mjs # reads files from IMAGES (paths in the container)
|
||||
// or on the host from app/: IMAGES="a.png b.jpg" node ../scripts/lab4/decode_memory.mjs
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const sharp = createRequire(`${process.cwd()}/`)('sharp');
|
||||
sharp.cache(false);
|
||||
sharp.concurrency(1);
|
||||
for (const file of (process.env.IMAGES ?? '').split(/\s+/u).filter(Boolean)) {
|
||||
const data = readFileSync(file);
|
||||
const meta = await sharp(data).metadata();
|
||||
const base = process.memoryUsage().rss;
|
||||
let peak = base;
|
||||
const timer = setInterval(() => {
|
||||
peak = Math.max(peak, process.memoryUsage().rss);
|
||||
}, 5);
|
||||
const started = Date.now();
|
||||
let verdict = 'ok';
|
||||
try {
|
||||
await sharp(data, { failOn: 'warning', sequentialRead: true, limitInputPixels: 40_000_000 })
|
||||
.resize(64, 64, { fit: 'inside' })
|
||||
.toBuffer();
|
||||
} catch (error) {
|
||||
verdict = `rejected: ${String(error.message).split('\n')[0]}`;
|
||||
}
|
||||
clearInterval(timer);
|
||||
console.log(
|
||||
`${meta.format} ${meta.width}x${meta.height} ${meta.channels}ch ${meta.depth}${meta.isProgressive ? ' progressive' : ''}${meta.isPalette ? ' palette' : ''} bytes=${data.length} decode_ms=${Date.now() - started} peak_delta_rss_mib=${((peak - base) / 1048576).toFixed(1)} ${verdict}`,
|
||||
);
|
||||
}
|
||||
@@ -48,3 +48,31 @@ def noise_png(size: int, seed: int = 0) -> bytes:
|
||||
raise ValueError("size is too small")
|
||||
continue
|
||||
return pad_png(png, size)
|
||||
|
||||
|
||||
ADAM7 = [(0, 0, 8, 8), (4, 0, 8, 8), (0, 4, 4, 8), (2, 0, 4, 4), (0, 2, 2, 4), (1, 0, 2, 2), (0, 1, 1, 2)]
|
||||
|
||||
|
||||
def worst_decode_png(size: int = 10_485_760, width: int = 8000, height: int = 5000) -> bytes:
|
||||
"""The heaviest valid upload to decode: 40 MP RGBA 16-bit, Adam7-interlaced
|
||||
(the decoder must hold the whole image), padded to exactly `size` bytes."""
|
||||
compressor = zlib.compressobj(1)
|
||||
parts = []
|
||||
for x0, y0, dx, dy in ADAM7:
|
||||
pass_width = (width - x0 + dx - 1) // dx if width > x0 else 0
|
||||
pass_height = (height - y0 + dy - 1) // dy if height > y0 else 0
|
||||
if pass_width == 0 or pass_height == 0:
|
||||
continue
|
||||
row = bytes(1 + pass_width * 8)
|
||||
for _ in range(pass_height):
|
||||
parts.append(compressor.compress(row))
|
||||
parts.append(compressor.flush())
|
||||
ihdr = struct.pack(">IIBBBBB", width, height, 16, 6, 0, 0, 1)
|
||||
png = SIGNATURE + chunk(b"IHDR", ihdr) + chunk(b"IDAT", b"".join(parts)) + chunk(b"IEND", b"")
|
||||
return pad_png(png, size)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
sys.stdout.buffer.write(worst_decode_png())
|
||||
|
||||
@@ -19,5 +19,18 @@ for size in 131072 1048576 9961472; do
|
||||
done
|
||||
echo "== proxy size=9961472 c=20"
|
||||
bench proxy 9961472 20
|
||||
# Worst case for memory: every request carries the heaviest valid image
|
||||
# (40 MP RGBA16 Adam7 PNG padded to 10 MiB, ~340 MiB per decode) and C=32
|
||||
# saturates UPLOAD_MAX_IN_FLIGHT (16) on both replicas.
|
||||
tmp=$(mktemp -d)
|
||||
trap 'rm -rf "$tmp"' EXIT
|
||||
worst="$tmp/worst-40mp-rgba16-adam7.png"
|
||||
python3 scripts/lab4/pngkit.py > "$worst"
|
||||
for mode in proxy direct; do
|
||||
echo "== $mode worst-case image c=32"
|
||||
python3 scripts/lab4/attachments_bench.py run --mode "$mode" --image "$worst" \
|
||||
--concurrency 32 --uploads-per-worker 2 --repeat 3 \
|
||||
--output "$out/$mode-worst-c32.json"
|
||||
done
|
||||
python3 scripts/lab4/attachments_bench.py summarize "$out"/*.json > evidence/lab4/summary.md
|
||||
cat evidence/lab4/summary.md
|
||||
|
||||
Reference in New Issue
Block a user