ЛР 5 — БВТ2301 — Курлова — на 5

RabbitMQ + transactional outbox, отдельный worker (thumbnail/crop/WebP), lease и heartbeat, retry с backoff+jitter, DLQ и replay, admission control; тесты отказов, трек 1 и отчёт.
This commit is contained in:
alenchha
2026-11-06 12:10:16 +03:00
parent 276dbdad8a
commit 633fb96920
57 changed files with 5194 additions and 22 deletions
+13
View File
@@ -0,0 +1,13 @@
# failover — 2026-11-06T09:01:21Z
## run 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": 131, "failed_attempts": 0, "first_recovery_seconds": 0.571}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
api-1 running
## run 2
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": 131, "failed_attempts": 0, "first_recovery_seconds": 0.784}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
api-2 running
+82
View File
@@ -0,0 +1,82 @@
# grade 4 failure windows — 2026-11-06T08:58:05Z, base commit 276dbda + working tree, FAULT_INJECTION=1
$ python3 student-tests/test_failure_windows.py
11:58:05 scenario A: scenario_a
11:58:05 client saw: missing X-Request-Id
11:58:05 committed attachment b5b077f9-ac62-4fa2-8936-9c1b3ee7b3a3 survived the API crash
11:58:06 statuses: processing -> ready
11:58:06 audit attempt=1 enqueued api:api-2
11:58:06 audit attempt=1 claimed 926c7492ded8:13fd47b0
11:58:06 audit attempt=1 succeeded 926c7492ded8:13fd47b0
11:58:07 scenario A PASS (1.7s)
11:58:07 scenario B: scenario_b
11:58:30 statuses: queued -> processing -> queued -> ready
11:58:31 audit attempt=1 enqueued api:api-1
11:58:31 audit attempt=1 claimed 0a275053a46c:9a3ac0c4
11:58:31 audit attempt=1 retry_scheduled sweeper:0a275053a46c:e765083 lease_expired delay=1.6s
11:58:31 audit attempt=2 claimed 926c7492ded8:13fd47b0
11:58:31 audit attempt=2 succeeded 926c7492ded8:13fd47b0
11:58:32 scenario B PASS (24.9s)
11:58:32 scenario C: scenario_c
11:58:32 statuses: queued -> ready
11:58:32 audit attempt=1 enqueued api:api-2
11:58:32 audit attempt=1 claimed 0a275053a46c:e765083c
11:58:32 audit attempt=1 succeeded 0a275053a46c:e765083c
11:58:42 scenario C PASS (10.3s)
11:58:42 scenario D: scenario_d
11:58:55 statuses: processing -> queued -> ready
11:58:56 audit attempt=1 enqueued api:api-1
11:58:56 audit attempt=1 claimed 926c7492ded8:13fd47b0
11:58:56 audit attempt=1 retry_scheduled 926c7492ded8:13fd47b0 dependency_unavailable delay=1.7s
11:58:56 audit attempt=2 claimed 0a275053a46c:fd20ea5b
11:58:56 audit attempt=2 retry_scheduled 0a275053a46c:fd20ea5b dependency_unavailable delay=3.13s
11:58:56 audit attempt=3 claimed 926c7492ded8:13fd47b0
11:58:56 audit attempt=3 retry_scheduled 926c7492ded8:13fd47b0 dependency_unavailable delay=7.83s
11:58:56 audit attempt=4 claimed 0a275053a46c:fd20ea5b
11:58:56 audit attempt=4 succeeded 0a275053a46c:fd20ea5b
11:58:56 backoff delays: [1.7, 3.13, 7.83]
11:58:56 scenario D PASS (14.3s)
11:58:56 scenario E: scenario_e
11:58:57 audit attempt=1 enqueued api:api-2
11:58:57 audit attempt=1 claimed 926c7492ded8:13fd47b0
11:58:57 audit attempt=1 failed 926c7492ded8:13fd47b0 invalid_image
11:58:57 scenario E PASS (0.8s)
11:58:57 scenario F: scenario_f
11:59:22 failed registry contains the job; replay
11:59:46 statuses: queued -> processing -> ready
11:59:46 audit attempt=1 enqueued api:api-1
11:59:46 audit attempt=1 claimed 0a275053a46c:fd20ea5b
11:59:46 audit attempt=1 retry_scheduled 0a275053a46c:fd20ea5b dependency_unavailable delay=1.05s
11:59:46 audit attempt=2 claimed 926c7492ded8:13fd47b0
11:59:46 audit attempt=2 retry_scheduled 926c7492ded8:13fd47b0 dependency_unavailable delay=2.84s
11:59:46 audit attempt=3 claimed 0a275053a46c:fd20ea5b
11:59:46 audit attempt=3 retry_scheduled 0a275053a46c:fd20ea5b dependency_unavailable delay=5.8s
11:59:46 audit attempt=4 claimed 926c7492ded8:13fd47b0
11:59:46 audit attempt=4 retry_scheduled 926c7492ded8:13fd47b0 dependency_unavailable delay=12.89s
11:59:46 audit attempt=5 claimed 0a275053a46c:fd20ea5b
11:59:46 audit attempt=5 failed 0a275053a46c:fd20ea5b retry_exhausted
11:59:46 audit attempt=6 replayed operator:test-suite
11:59:46 audit attempt=6 claimed 926c7492ded8:13fd47b0
11:59:46 audit attempt=6 retry_scheduled 926c7492ded8:13fd47b0 dependency_unavailable delay=22.22s
11:59:46 audit attempt=7 claimed 0a275053a46c:fd20ea5b
11:59:46 audit attempt=7 succeeded 0a275053a46c:fd20ea5b
11:59:49 second replay refused: job is succeeded, attachment is ready
11:59:50 scenario F PASS (52.5s)
11:59:50 scenario G: scenario_g
12:00:15 statuses: queued -> processing -> queued -> processing -> ready
12:00:16 audit attempt=1 enqueued api:api-2
12:00:16 audit attempt=1 claimed 926c7492ded8:13fd47b0
12:00:16 audit attempt=1 retry_scheduled sweeper:0a275053a46c:fd20ea5 lease_expired delay=1.8s
12:00:16 audit attempt=2 claimed 0a275053a46c:fd20ea5b
12:00:16 audit attempt=2 succeeded 0a275053a46c:fd20ea5b
12:00:47 scenario G PASS (57.8s)
12:00:47 scenario H: scenario_h
12:00:55 DLQ depth 1 -> 2
12:00:55 scenario H PASS (7.1s)
12:00:55 scenario I: scenario_i
12:00:59 broker down: upload 202, outbox holds 1 unpublished job
12:01:05 statuses: queued -> processing -> ready
12:01:05 audit attempt=1 enqueued api:api-1
12:01:05 audit attempt=1 claimed 0a275053a46c:fd20ea5b
12:01:05 audit attempt=1 succeeded 0a275053a46c:fd20ea5b
12:01:06 scenario I PASS (11.8s)
PASS: failure windows A B C D E F G H I
+36
View File
@@ -0,0 +1,36 @@
# persistence — 2026-11-06T09:01:14Z
$ cat scripts/restart.sh
#!/bin/sh
# Restart API, LB, worker and every store (postgres, valkey, minio, rabbitmq) keeping all volumes.
set -eu
cd "$(dirname "$0")/.."
docker compose restart -t 10 postgres valkey minio rabbitmq
docker compose restart -t 25 worker api-1 api-2 nginx
## containers StartedAt before
mtusi-lab5-api-1-1 2026-11-06T08:57:35.409218424Z
mtusi-lab5-api-2-1 2026-11-06T08:58:05.819373965Z
mtusi-lab5-minio-1 2026-11-06T08:23:49.358710597Z
mtusi-lab5-nginx-1 2026-11-06T08:23:50.667392333Z
mtusi-lab5-postgres-1 2026-11-06T08:23:49.384126305Z
mtusi-lab5-rabbitmq-1 2026-11-06T09:00:59.611106504Z
mtusi-lab5-valkey-1 2026-11-06T08:23:49.401115472Z
mtusi-lab5-worker-1 2026-11-06T08:57:50.89592275Z
mtusi-lab5-worker-2 2026-11-06T08:58:32.593535839Z
$ make test-persistence ACTION_SCRIPT=scripts/restart.sh
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.
## containers StartedAt after
mtusi-lab5-api-1-1 2026-11-06T09:01:17.294250804Z
mtusi-lab5-api-2-1 2026-11-06T09:01:17.309623971Z
mtusi-lab5-minio-1 2026-11-06T09:01:15.638306762Z
mtusi-lab5-nginx-1 2026-11-06T09:01:16.932816596Z
mtusi-lab5-postgres-1 2026-11-06T09:01:15.667794262Z
mtusi-lab5-rabbitmq-1 2026-11-06T09:01:16.680692637Z
mtusi-lab5-valkey-1 2026-11-06T09:01:15.692763803Z
mtusi-lab5-worker-1 2026-11-06T09:01:20.784383042Z
mtusi-lab5-worker-2 2026-11-06T09:01:20.824222792Z
## volumes
mtusi-lab5_miniodata
mtusi-lab5_pgdata
mtusi-lab5_rabbitmqdata
+6
View File
@@ -0,0 +1,6 @@
# make check / make test — 2026-11-06T08:57:29Z, base commit 276dbda + working tree, macOS arm64, Docker 29.7, 10 CPU/8 GiB VM
$ make check && make test
python3 scripts/check_contract.py
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab5 public API scenario; infrastructure and grading evidence remain separate.
+28
View File
@@ -0,0 +1,28 @@
{"label": "c1-p1-r1", "tag": "09c4ed86", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 300, "drained": true, "drain_after_load_s": 19.81, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 6.076, "lag_p50_s": 9.771, "lag_p95_s": 18.388, "lag_max_s": 19.342, "ttr_p50_s": 9.936, "ttr_p95_s": 18.551, "ttr_max_s": 19.497, "pending_max": 117, "worker_mem_peak_mib": 91.8, "worker_mem_median_mib": 83.3, "worker_cpu_peak_pct": 96.1, "at": "2026-11-06T11:32:11"}
{"label": "c2-p2-r1", "tag": "1e2fd008", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 300, "drained": true, "drain_after_load_s": 1.2, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 9.976, "lag_p50_s": 0.007, "lag_p95_s": 0.03, "lag_max_s": 0.066, "ttr_p50_s": 0.172, "ttr_p95_s": 0.217, "ttr_max_s": 0.245, "pending_max": 3, "worker_mem_peak_mib": 94.9, "worker_mem_median_mib": 84.6, "worker_cpu_peak_pct": 190.1, "at": "2026-11-06T11:32:51"}
{"label": "c4-p4-r1", "tag": "8befd323", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.91, "offered": 300, "drained": true, "drain_after_load_s": 1.22, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 9.979, "lag_p50_s": 0.007, "lag_p95_s": 0.01, "lag_max_s": 0.022, "ttr_p50_s": 0.17, "ttr_p95_s": 0.186, "ttr_max_s": 0.225, "pending_max": 2, "worker_mem_peak_mib": 95.8, "worker_mem_median_mib": 83.0, "worker_cpu_peak_pct": 172.3, "at": "2026-11-06T11:33:31"}
{"label": "c2-p16-r1", "tag": "50386d2d", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.91, "offered": 300, "drained": true, "drain_after_load_s": 1.18, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 9.978, "lag_p50_s": 0.007, "lag_p95_s": 0.013, "lag_max_s": 0.046, "ttr_p50_s": 0.17, "ttr_p95_s": 0.19, "ttr_max_s": 0.219, "pending_max": 2, "worker_mem_peak_mib": 96.4, "worker_mem_median_mib": 82.8, "worker_cpu_peak_pct": 164.1, "at": "2026-11-06T11:34:11"}
{"label": "c1-p1-r1", "tag": "2e5ee814", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.93, "offered": 150, "drained": true, "drain_after_load_s": 18.68, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 3.123, "lag_p50_s": 9.361, "lag_p95_s": 17.324, "lag_max_s": 18.089, "ttr_p50_s": 9.669, "ttr_p95_s": 17.622, "ttr_max_s": 18.39, "pending_max": 58, "worker_mem_peak_mib": 108.8, "worker_mem_median_mib": 79.6, "worker_cpu_peak_pct": 95.9, "at": "2026-11-06T11:35:09"}
{"label": "c2-p2-r1", "tag": "f236141e", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.93, "offered": 150, "drained": true, "drain_after_load_s": 1.27, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 4.898, "lag_p50_s": 0.336, "lag_p95_s": 0.578, "lag_max_s": 0.635, "ttr_p50_s": 0.738, "ttr_p95_s": 0.971, "ttr_max_s": 1.023, "pending_max": 5, "worker_mem_peak_mib": 148.3, "worker_mem_median_mib": 109.7, "worker_cpu_peak_pct": 190.5, "at": "2026-11-06T11:35:50"}
{"label": "c4-p4-r1", "tag": "7dd1545c", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.94, "offered": 150, "drained": true, "drain_after_load_s": 1.2, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 4.956, "lag_p50_s": 0.034, "lag_p95_s": 0.082, "lag_max_s": 0.172, "ttr_p50_s": 0.425, "ttr_p95_s": 0.492, "ttr_max_s": 0.588, "pending_max": 2, "worker_mem_peak_mib": 126.5, "worker_mem_median_mib": 105.6, "worker_cpu_peak_pct": 198.6, "at": "2026-11-06T11:36:30"}
{"label": "c2-p16-r1", "tag": "2e139fa3", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 150, "drained": true, "drain_after_load_s": 1.24, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 4.903, "lag_p50_s": 0.301, "lag_p95_s": 0.602, "lag_max_s": 0.649, "ttr_p50_s": 0.699, "ttr_p95_s": 0.999, "ttr_max_s": 1.036, "pending_max": 5, "worker_mem_peak_mib": 168.3, "worker_mem_median_mib": 101.8, "worker_cpu_peak_pct": 189.7, "at": "2026-11-06T11:37:11"}
{"label": "c1-p1-r1", "tag": "f7c65b4d", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.81, "offered": 90, "drained": true, "drain_after_load_s": 18.64, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 1.871, "lag_p50_s": 8.815, "lag_p95_s": 17.208, "lag_max_s": 18.01, "ttr_p50_s": 9.335, "ttr_p95_s": 17.735, "ttr_max_s": 18.533, "pending_max": 34, "worker_mem_peak_mib": 197.9, "worker_mem_median_mib": 174.5, "worker_cpu_peak_pct": 100.2, "at": "2026-11-06T11:38:08"}
{"label": "c2-p2-r1", "tag": "b593ef8c", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.96, "offered": 90, "drained": true, "drain_after_load_s": 1.23, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 2.914, "lag_p50_s": 0.012, "lag_p95_s": 0.239, "lag_max_s": 0.41, "ttr_p50_s": 0.626, "ttr_p95_s": 0.855, "ttr_max_s": 1.142, "pending_max": 3, "worker_mem_peak_mib": 322.1, "worker_mem_median_mib": 183.5, "worker_cpu_peak_pct": 196.4, "at": "2026-11-06T11:38:48"}
{"label": "c4-p4-r1", "tag": "1e1f1621", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.89, "offered": 90, "drained": true, "drain_after_load_s": 2.38, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 2.837, "lag_p50_s": 0.142, "lag_p95_s": 0.89, "lag_max_s": 1.078, "ttr_p50_s": 1.481, "ttr_p95_s": 2.289, "ttr_max_s": 2.57, "pending_max": 7, "worker_mem_peak_mib": 485.2, "worker_mem_median_mib": 336.5, "worker_cpu_peak_pct": 203.2, "at": "2026-11-06T11:39:29"}
{"label": "c2-p16-r1", "tag": "6d4dbd63", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 31.36, "offered": 90, "drained": true, "drain_after_load_s": 8.22, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 2.335, "lag_p50_s": 0.887, "lag_p95_s": 6.334, "lag_max_s": 6.523, "ttr_p50_s": 1.857, "ttr_p95_s": 7.375, "ttr_max_s": 7.667, "pending_max": 13, "worker_mem_peak_mib": 275.3, "worker_mem_median_mib": 190.6, "worker_cpu_peak_pct": 196.2, "at": "2026-11-06T11:40:17"}
{"label": "c1-p1-r2", "tag": "73bf39d6", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.91, "offered": 300, "drained": true, "drain_after_load_s": 31.13, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 4.978, "lag_p50_s": 14.078, "lag_p95_s": 29.005, "lag_max_s": 30.141, "ttr_p50_s": 14.279, "ttr_p95_s": 29.175, "ttr_max_s": 30.364, "pending_max": 145, "worker_mem_peak_mib": 87.6, "worker_mem_median_mib": 79.8, "worker_cpu_peak_pct": 96.4, "at": "2026-11-06T11:41:27"}
{"label": "c2-p2-r2", "tag": "b5f91857", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 300, "drained": true, "drain_after_load_s": 16.12, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 6.579, "lag_p50_s": 7.808, "lag_p95_s": 14.677, "lag_max_s": 15.458, "ttr_p50_s": 8.089, "ttr_p95_s": 14.96, "ttr_max_s": 15.765, "pending_max": 96, "worker_mem_peak_mib": 104.0, "worker_mem_median_mib": 90.2, "worker_cpu_peak_pct": 193.0, "at": "2026-11-06T11:42:22"}
{"label": "c4-p4-r2", "tag": "4a06a2db", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 300, "drained": true, "drain_after_load_s": 24.98, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 5.578, "lag_p50_s": 10.647, "lag_p95_s": 23.151, "lag_max_s": 23.579, "ttr_p50_s": 11.356, "ttr_p95_s": 23.652, "ttr_max_s": 24.047, "pending_max": 134, "worker_mem_peak_mib": 120.3, "worker_mem_median_mib": 100.8, "worker_cpu_peak_pct": 210.9, "at": "2026-11-06T11:43:27"}
{"label": "c2-p16-r2", "tag": "fcd642ae", "size": "small", "file_kib": 80, "rate": 10.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 300, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.92, "offered": 300, "drained": true, "drain_after_load_s": 14.88, "succeeded": 300, "failed": 0, "retries": 0, "throughput_jobs_s": 6.827, "lag_p50_s": 7.553, "lag_p95_s": 13.428, "lag_max_s": 13.882, "ttr_p50_s": 7.87, "ttr_p95_s": 13.72, "ttr_max_s": 14.122, "pending_max": 97, "worker_mem_peak_mib": 106.1, "worker_mem_median_mib": 88.6, "worker_cpu_peak_pct": 193.4, "at": "2026-11-06T11:44:20"}
{"label": "c1-p1-r2", "tag": "31ff31ee", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 30.11, "offered": 150, "drained": true, "drain_after_load_s": 31.34, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 2.477, "lag_p50_s": 18.359, "lag_p95_s": 29.508, "lag_max_s": 30.392, "ttr_p50_s": 18.781, "ttr_p95_s": 29.83, "ttr_max_s": 30.727, "pending_max": 83, "worker_mem_peak_mib": 110.4, "worker_mem_median_mib": 98.7, "worker_cpu_peak_pct": 98.8, "at": "2026-11-06T11:45:30"}
{"label": "c2-p2-r2", "tag": "629220cd", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.98, "offered": 150, "drained": true, "drain_after_load_s": 5.68, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 4.272, "lag_p50_s": 1.973, "lag_p95_s": 4.696, "lag_max_s": 4.871, "ttr_p50_s": 2.554, "ttr_p95_s": 5.134, "ttr_max_s": 5.304, "pending_max": 23, "worker_mem_peak_mib": 136.3, "worker_mem_median_mib": 108.4, "worker_cpu_peak_pct": 188.6, "at": "2026-11-06T11:46:13"}
{"label": "c4-p4-r2", "tag": "a553faab", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 30.07, "offered": 150, "drained": true, "drain_after_load_s": 8.24, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 4.042, "lag_p50_s": 2.017, "lag_p95_s": 5.392, "lag_max_s": 6.512, "ttr_p50_s": 2.993, "ttr_p95_s": 6.574, "ttr_max_s": 7.505, "pending_max": 24, "worker_mem_peak_mib": 204.7, "worker_mem_median_mib": 136.8, "worker_cpu_peak_pct": 202.2, "at": "2026-11-06T11:47:00"}
{"label": "c2-p16-r2", "tag": "de9f2ad5", "size": "medium", "file_kib": 3908, "rate": 5.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 150, "rejected_503": 0, "other_errors": 0, "send_seconds": 30.03, "offered": 150, "drained": true, "drain_after_load_s": 11.59, "succeeded": 150, "failed": 0, "retries": 0, "throughput_jobs_s": 3.703, "lag_p50_s": 3.276, "lag_p95_s": 8.968, "lag_max_s": 9.955, "ttr_p50_s": 3.976, "ttr_p95_s": 9.518, "ttr_max_s": 10.622, "pending_max": 35, "worker_mem_peak_mib": 159.9, "worker_mem_median_mib": 109.1, "worker_cpu_peak_pct": 189.4, "at": "2026-11-06T11:47:50"}
{"label": "c1-p1-r2", "tag": "9e51fc5d", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 1, "prefetch": 1, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 29.88, "offered": 90, "drained": true, "drain_after_load_s": 27.83, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 1.592, "lag_p50_s": 11.683, "lag_p95_s": 24.82, "lag_max_s": 26.202, "ttr_p50_s": 12.359, "ttr_p95_s": 25.449, "ttr_max_s": 26.881, "pending_max": 41, "worker_mem_peak_mib": 196.8, "worker_mem_median_mib": 173.9, "worker_cpu_peak_pct": 100.8, "at": "2026-11-06T11:48:57"}
{"label": "c2-p2-r2", "tag": "3d93c160", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 31.54, "offered": 90, "drained": true, "drain_after_load_s": 15.14, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 1.956, "lag_p50_s": 6.214, "lag_p95_s": 13.308, "lag_max_s": 14.352, "ttr_p50_s": 7.253, "ttr_p95_s": 14.445, "ttr_max_s": 15.382, "pending_max": 25, "worker_mem_peak_mib": 266.7, "worker_mem_median_mib": 194.0, "worker_cpu_peak_pct": 198.1, "at": "2026-11-06T11:49:53"}
{"label": "c4-p4-r2", "tag": "2e50998d", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 4, "prefetch": 4, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 31.45, "offered": 90, "drained": true, "drain_after_load_s": 12.87, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 2.051, "lag_p50_s": 4.859, "lag_p95_s": 10.405, "lag_max_s": 11.567, "ttr_p50_s": 6.358, "ttr_p95_s": 12.708, "ttr_max_s": 13.84, "pending_max": 23, "worker_mem_peak_mib": 548.7, "worker_mem_median_mib": 329.9, "worker_cpu_peak_pct": 202.3, "at": "2026-11-06T11:50:46"}
{"label": "c2-p16-r2", "tag": "63cdb6c9", "size": "large", "file_kib": 400, "rate": 3.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 16, "max_pending": null, "accepted": 90, "rejected_503": 0, "other_errors": 0, "send_seconds": 30.01, "offered": 90, "drained": true, "drain_after_load_s": 9.24, "succeeded": 90, "failed": 0, "retries": 0, "throughput_jobs_s": 2.309, "lag_p50_s": 1.364, "lag_p95_s": 8.043, "lag_max_s": 8.52, "ttr_p50_s": 2.146, "ttr_p95_s": 8.84, "ttr_max_s": 9.233, "pending_max": 20, "worker_mem_peak_mib": 285.6, "worker_mem_median_mib": 193.4, "worker_cpu_peak_pct": 197.2, "at": "2026-11-06T11:51:35"}
{"label": "overload-soft-only-r1", "tag": "44ae8a0a", "size": "large", "file_kib": 400, "rate": 8.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": 30, "accepted": 128, "rejected_503": 112, "other_errors": 0, "send_seconds": 29.88, "offered": 240, "drained": true, "drain_after_load_s": 28.41, "succeeded": 128, "failed": 0, "retries": 0, "throughput_jobs_s": 2.239, "lag_p50_s": 18.807, "lag_p95_s": 31.84, "lag_max_s": 32.462, "ttr_p50_s": 19.553, "ttr_p95_s": 32.708, "ttr_max_s": 33.358, "pending_max": 74, "worker_mem_peak_mib": 354.1, "worker_mem_median_mib": 192.1, "worker_cpu_peak_pct": 200.8, "at": "2026-11-06T11:52:48", "recovery_probe_ready_s": 0.23}
{"label": "overload-soft-only-r2", "tag": "3ca187f1", "size": "large", "file_kib": 400, "rate": 8.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": 30, "accepted": 143, "rejected_503": 97, "other_errors": 0, "send_seconds": 29.88, "offered": 240, "drained": true, "drain_after_load_s": 30.71, "succeeded": 143, "failed": 0, "retries": 0, "throughput_jobs_s": 2.379, "lag_p50_s": 15.954, "lag_p95_s": 33.178, "lag_max_s": 34.043, "ttr_p50_s": 16.722, "ttr_p95_s": 34.072, "ttr_max_s": 34.912, "pending_max": 81, "worker_mem_peak_mib": 336.4, "worker_mem_median_mib": 210.1, "worker_cpu_peak_pct": 198.1, "at": "2026-11-06T11:54:05", "recovery_probe_ready_s": 0.51}
{"label": "overload-strict-r1", "tag": "c0336ae6", "size": "large", "file_kib": 400, "rate": 8.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": 30, "accepted": 108, "rejected_503": 132, "other_errors": 0, "send_seconds": 34.25, "offered": 240, "drained": true, "drain_after_load_s": 12.45, "succeeded": 108, "failed": 0, "retries": 0, "throughput_jobs_s": 2.376, "lag_p50_s": 12.922, "lag_p95_s": 18.092, "lag_max_s": 18.737, "ttr_p50_s": 13.77, "ttr_p95_s": 18.916, "ttr_max_s": 19.593, "pending_max": 30, "worker_mem_peak_mib": 315.6, "worker_mem_median_mib": 200.0, "worker_cpu_peak_pct": 196.8, "at": "2026-11-06T11:56:03", "recovery_probe_ready_s": 0.23}
{"label": "overload-strict-r2", "tag": "de4b3bbc", "size": "large", "file_kib": 400, "rate": 8.0, "duration": 30.0, "replicas": 1, "concurrency": 2, "prefetch": 2, "max_pending": 30, "accepted": 100, "rejected_503": 140, "other_errors": 0, "send_seconds": 30.69, "offered": 240, "drained": true, "drain_after_load_s": 15.17, "succeeded": 100, "failed": 0, "retries": 0, "throughput_jobs_s": 2.212, "lag_p50_s": 12.916, "lag_p95_s": 15.414, "lag_max_s": 16.136, "ttr_p50_s": 13.843, "ttr_p95_s": 16.417, "ttr_max_s": 17.059, "pending_max": 30, "worker_mem_peak_mib": 380.1, "worker_mem_median_mib": 207.9, "worker_cpu_peak_pct": 197.6, "at": "2026-11-06T11:57:07", "recovery_probe_ready_s": 0.24}
+21
View File
@@ -0,0 +1,21 @@
| size | rate/s | c/p | n | accepted | throughput jobs/s | lag p95 s | ttr p50 s | ttr p95 s | pending max | worker mem peak MiB | cpu peak % |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| small | 10.0 | 1/1 | 2 | 300 | 5.53 (4.98–6.08) | 23.70 (18.39–29.00) | 12.11 (9.94–14.28) | 23.86 (18.55–29.18) | 131 (117–145) | 90 (88–92) | 96 (96–96) |
| small | 10.0 | 2/2 | 2 | 300 | 8.28 (6.58–9.98) | 7.35 (0.03–14.68) | 4.13 (0.17–8.09) | 7.59 (0.22–14.96) | 50 (3–96) | 99 (95–104) | 192 (190–193) |
| small | 10.0 | 2/16 | 2 | 300 | 8.40 (6.83–9.98) | 6.72 (0.01–13.43) | 4.02 (0.17–7.87) | 6.96 (0.19–13.72) | 50 (2–97) | 101 (96–106) | 179 (164–193) |
| small | 10.0 | 4/4 | 2 | 300 | 7.78 (5.58–9.98) | 11.58 (0.01–23.15) | 5.76 (0.17–11.36) | 11.92 (0.19–23.65) | 68 (2–134) | 108 (96–120) | 192 (172–211) |
| medium | 5.0 | 1/1 | 2 | 150 | 2.80 (2.48–3.12) | 23.42 (17.32–29.51) | 14.22 (9.67–18.78) | 23.73 (17.62–29.83) | 70 (58–83) | 110 (109–110) | 97 (96–99) |
| medium | 5.0 | 2/2 | 2 | 150 | 4.58 (4.27–4.90) | 2.64 (0.58–4.70) | 1.65 (0.74–2.55) | 3.05 (0.97–5.13) | 14 (5–23) | 142 (136–148) | 190 (189–190) |
| medium | 5.0 | 2/16 | 2 | 150 | 4.30 (3.70–4.90) | 4.79 (0.60–8.97) | 2.34 (0.70–3.98) | 5.26 (1.00–9.52) | 20 (5–35) | 164 (160–168) | 190 (189–190) |
| medium | 5.0 | 4/4 | 2 | 150 | 4.50 (4.04–4.96) | 2.74 (0.08–5.39) | 1.71 (0.42–2.99) | 3.53 (0.49–6.57) | 13 (2–24) | 166 (126–205) | 200 (199–202) |
| large | 3.0 | 1/1 | 2 | 90 | 1.73 (1.59–1.87) | 21.01 (17.21–24.82) | 10.85 (9.34–12.36) | 21.59 (17.73–25.45) | 38 (34–41) | 197 (197–198) | 100 (100–101) |
| large | 3.0 | 2/2 | 2 | 90 | 2.44 (1.96–2.91) | 6.77 (0.24–13.31) | 3.94 (0.63–7.25) | 7.65 (0.85–14.45) | 14 (3–25) | 294 (267–322) | 197 (196–198) |
| large | 3.0 | 2/16 | 2 | 90 | 2.32 (2.31–2.33) | 7.19 (6.33–8.04) | 2.00 (1.86–2.15) | 8.11 (7.38–8.84) | 16 (13–20) | 280 (275–286) | 197 (196–197) |
| large | 3.0 | 4/4 | 2 | 90 | 2.44 (2.05–2.84) | 5.65 (0.89–10.40) | 3.92 (1.48–6.36) | 7.50 (2.29–12.71) | 15 (7–23) | 517 (485–549) | 203 (202–203) |
| overload run | offered | accepted | rejected 503 | other errors | pending max (limit) | throughput | ttr p95 s | drain after load s | recovery probe ready s |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| overload-soft-only-r1 | 240 @ 8.0/s | 128 | 112 | 0 | 74 (30) | 2.24 | 32.708 | 28.41 | 0.23 |
| overload-soft-only-r2 | 240 @ 8.0/s | 143 | 97 | 0 | 81 (30) | 2.38 | 34.072 | 30.71 | 0.51 |
| overload-strict-r1 | 240 @ 8.0/s | 108 | 132 | 0 | 30 (30) | 2.38 | 18.916 | 12.45 | 0.23 |
| overload-strict-r2 | 240 @ 8.0/s | 100 | 140 | 0 | 30 (30) | 2.21 | 16.417 | 15.17 | 0.24 |
+20
View File
@@ -0,0 +1,20 @@
ok 320x200 -> thumbnail 256x160
ok crop 128x128
ok optimized WebP 320x200, no upscale
ok thumbnail/crop are JPEG
ok 40x10: thumbnail 40x10, crop 128x128
ok 3000x2 -> 256x1 / 1280x1 (min 1px)
ok 1001x999 -> 256x255 (floor)
ok EXIF orientation applied: 400x200 (o=6) -> 128x256
ok rotated content: red half on top after orientation 6
ok EXIF removed from thumbnail/optimized
ok transparent PNG -> white JPEG thumbnail
ok WebP optimized keeps alpha
ok 16-bit PNG, CMYK JPEG, palette+transparency PNG are processed
ok pixel limit enforced before decode -> image_too_large (exit 4)
ok corrupted PNG -> invalid_image (exit 3)
ok 36 Mpx PNG with 160 MiB address-space limit -> image_too_complex (exit 5), got 5
ok 39.5 Mpx PNG (31 MB file) ok in 0.9s, peak child RSS 322 MiB
ok CPU limit exhausted -> SIGXCPU (worker: permanent image_too_complex), got -24
ok 39.5 Mpx JPEG (7 MB file) ok in 0.3s, peak child RSS 335 MiB
RESULT: PASS
+16
View File
@@ -0,0 +1,16 @@
# grade 3 demo — 2026-11-06T08:57:30Z, base commit 276dbda + working tree, macOS arm64, Docker 29.7, 10 CPU/8 GiB VM
$ python3 student-tests/test_worker_down.py
11:57:30 stop all workers
11:57:31 upload 202 queued id=4ebb6253-d722-4c83-b9fe-87f15342c14b
11:57:31 message 0fdac623-179d-40f3-8792-3332b63e2623 created with queued attachment
11:57:34 broker queue while worker is down: {'messages': 1, 'ready': 1, 'unacked': 0}
11:57:34 restart api-1 api-2 rabbitmq (volumes kept)
11:57:47 started before: mtusi-lab5-api-1-1 2026-11-06T08:57:08.369668592Z; mtusi-lab5-api-2-1 2026-11-06T08:57:08.47338055Z; mtusi-lab5-rabbitmq-1 2026-11-06T08:23:50.417899292Z
11:57:47 started after: mtusi-lab5-api-1-1 2026-11-06T08:57:35.409218424Z; mtusi-lab5-api-2-1 2026-11-06T08:57:35.46578734Z; mtusi-lab5-rabbitmq-1 2026-11-06T08:57:36.162050341Z
11:57:47 broker queue after broker restart: {'messages': 1, 'ready': 1, 'unacked': 0}
11:57:47 start workers
11:57:52 status sequence observed: queued -> ready
11:57:52 objects: ['attachments/4ebb6253-d722-4c83-b9fe-87f15342c14b/original', 'attachments/4ebb6253-d722-4c83-b9fe-87f15342c14b/v1/crop.jpg', 'attachments/4ebb6253-d722-4c83-b9fe-87f15342c14b/v1/optimized.webp', 'attachments/4ebb6253-d722-4c83-b9fe-87f15342c14b/v1/thumbnail.jpg']
11:57:52 redelivery: republish the finished job through the outbox (duplicate message)
11:57:58 duplicate acked as no-op: variants=3 successes=1
PASS: worker down / API+broker restart / redelivery no-op