Выполнена лабораторная работа 4

This commit is contained in:
2026-11-16 20:06:52 +03:00
parent ec540a1a72
commit 0cd7200b1f
51 changed files with 2133 additions and 38 deletions
+82
View File
@@ -0,0 +1,82 @@
# Фактические результаты
## Загрузка: 10 клиентов одновременно
| Байт | Успех / ошибки | Время, с | RPS | p50, с | p95/p99, с | Наблюдаемый максимум RAM, MiB | Cgroup peak за жизнь API, MiB |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 787247 | 10 / 0 | 4.349 | 2.30 | 0.939 | 1.552 | 79.20 | 148.36 |
| 3147775 | 10 / 0 | 4.808 | 2.08 | 1.516 | 1.895 | 101.30 | 148.36 |
Профиль: одна волна на размер, без повторов HTTP. Docker stats опрашивается параллельно; время ожидания мониторинга исключено из RPS. p95 и p99 при n=10 совпадают с максимумом (nearest rank). Cgroup peak включает прогрев и все предыдущие запросы процесса; это верхняя граница памяти волны, а не её изолированный расход.
## Reconciler: внедрённые orphan и missing
| Режим | Объекты | Метаданные ready | LIST | HEAD | Удалено | Помечено missing | Время, с |
| --- | --- | --- | --- | --- | --- | --- | --- |
| dry_run | 54 | 53 | 1 | 44 | 0 | 0 | 0.811 |
| apply | 54 | 53 | 1 | 49 | 1 | 1 | 0.861 |
| repeat | 53 | 52 | 1 | 52 | 0 | 0 | 1.316 |
## Стоимость обхода: три повтора на размер
| Дополнительные объекты | Всего объектов | LIST | HEAD | Медиана, с | Минимум / максимум, с |
| --- | --- | --- | --- | --- | --- |
| 10 | 63 | 1 | 1 | 0.998 | 0.554 / 2.476 |
| 100 | 153 | 1 | 1 | 0.839 | 0.808 / 0.880 |
Сбой INSERT после успешного PUT: число объектов до и после компенсации — 53 и 53. Старое вложение, используемое сообщением, сохранено; SHA-256/байты и ссылка сообщения проверены.
## Проверки
### contract.txt
```text
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
```
### smoke.txt
```text
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
```
### acceptance.txt
```text
PASS: negative images, ACL, private S3, interrupted upload, concurrent uploads, reconciliation, S3 outage
```
### consistency.txt
```text
PASS: failure after S3 PUT compensates, old used attachment survives, scan cost measured twice with three repeats
```
### persistence.txt
```text
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
```
### failover-1.txt
```text
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 96, "failed_attempts": 6, "first_recovery_seconds": 4.274}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
```
### failover-2.txt
```text
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 99, "failed_attempts": 3, "first_recovery_seconds": 3.328}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
```
### smoke-final.txt
```text
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
```
+251
View File
@@ -0,0 +1,251 @@
{
"negative_tests": "PASS: byte/pixel limits, corrupt/truncated images, MIME mismatch, filename, ACL, foreign and unknown attachment",
"private_bucket": {
"anonymous_get": 403
},
"uploads": [
{
"size_bytes": 787247,
"concurrency": 10,
"success": 10,
"errors": 0,
"seconds": 4.3491024999530055,
"successful_rps": 2.299324975695113,
"p50": 0.9388057499891147,
"p95": 1.552345400035847,
"p99": 1.552345400035847,
"baseline": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "31.36%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "14.98%",
"MemUsage": "76.69MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "795kB / 281kB",
"PIDs": "8"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "1.67%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "13.87%",
"MemUsage": "71.03MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "11.7MB / 650kB",
"PIDs": "8"
}
],
"samples": [
{
"BlockIO": "0B / 0B",
"CPUPerc": "22.72%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "14.97%",
"MemUsage": "76.65MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "799kB / 289kB",
"PIDs": "7"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "8.94%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "13.82%",
"MemUsage": "70.77MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "11.7MB / 654kB",
"PIDs": "8"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "16.40%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "15.47%",
"MemUsage": "79.2MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "4.79MB / 4.28MB",
"PIDs": "9"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "15.99%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "14.72%",
"MemUsage": "75.34MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "15.6MB / 4.64MB",
"PIDs": "10"
}
],
"lifetime_cgroup_peak_bytes": {
"4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e": 155566080,
"0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd": 150491136
}
},
{
"size_bytes": 3147775,
"concurrency": 10,
"success": 10,
"errors": 0,
"seconds": 4.808497400023043,
"successful_rps": 2.079651743172842,
"p50": 1.5156683000095654,
"p95": 1.8952780999825336,
"p99": 1.8952780999825336,
"baseline": [
{
"BlockIO": "69.6kB / 0B",
"CPUPerc": "1.63%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "15.46%",
"MemUsage": "79.15MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "4.79MB / 4.29MB",
"PIDs": "9"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "1.70%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "14.72%",
"MemUsage": "75.36MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "15.7MB / 4.65MB",
"PIDs": "10"
}
],
"samples": [
{
"BlockIO": "69.6kB / 0B",
"CPUPerc": "15.45%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "15.56%",
"MemUsage": "79.66MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "4.79MB / 4.3MB",
"PIDs": "9"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "15.82%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "14.74%",
"MemUsage": "75.46MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "15.7MB / 4.65MB",
"PIDs": "10"
},
{
"BlockIO": "69.6kB / 0B",
"CPUPerc": "51.64%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "19.12%",
"MemUsage": "97.88MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "20.7MB / 17MB",
"PIDs": "11"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "52.52%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "19.79%",
"MemUsage": "101.3MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "31.1MB / 14.2MB",
"PIDs": "11"
},
{
"BlockIO": "69.6kB / 0B",
"CPUPerc": "2.01%",
"Container": "4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e",
"ID": "4eba80629d64",
"MemPerc": "17.12%",
"MemUsage": "87.64MiB / 512MiB",
"Name": "mtusi-lab4-api-1",
"NetIO": "20.7MB / 20.1MB",
"PIDs": "10"
},
{
"BlockIO": "0B / 0B",
"CPUPerc": "2.95%",
"Container": "0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd",
"ID": "0fe6963e2e3f",
"MemPerc": "16.87%",
"MemUsage": "86.39MiB / 512MiB",
"Name": "mtusi-lab4-api-2",
"NetIO": "31.5MB / 20.5MB",
"PIDs": "9"
}
],
"lifetime_cgroup_peak_bytes": {
"4eba80629d64309da396f81516e404de8b9b38544e565800710f50cb6c77572e": 155566080,
"0fe6963e2e3f298ea2bc81dd0c50713412627b76bb0871dc97321c0311e250cd": 150491136
}
}
],
"interrupted_upload": "Connection closed after 100 bytes of declared 100000; no S3 PUT before validation",
"reconciler": {
"dry_run": {
"apply": false,
"grace_seconds": 60,
"objects": 54,
"metadata": 53,
"list_requests": 1,
"head_requests": 44,
"orphan_candidates": 1,
"missing_candidates": 1,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 1,
"referenced_preserved": 52,
"elapsed_seconds": 0.811033
},
"apply": {
"apply": true,
"grace_seconds": 60,
"objects": 54,
"metadata": 53,
"list_requests": 1,
"head_requests": 49,
"orphan_candidates": 1,
"missing_candidates": 1,
"deleted": 1,
"marked_failed": 1,
"fresh_preserved": 1,
"referenced_preserved": 52,
"elapsed_seconds": 0.860571
},
"repeat": {
"apply": true,
"grace_seconds": 60,
"objects": 53,
"metadata": 52,
"list_requests": 1,
"head_requests": 52,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 1,
"referenced_preserved": 52,
"elapsed_seconds": 1.31619
}
},
"s3_outage": {
"ready": 503
}
}
+1
View File
@@ -0,0 +1 @@
PASS: negative images, ACL, private S3, interrupted upload, concurrent uploads, reconciliation, S3 outage
+42
View File
@@ -0,0 +1,42 @@
[
{
"name": "/mtusi-lab4-api-1",
"id": "4eba80629d64",
"started": "2026-11-16T14:50:45.918611054Z",
"image": "mtusi-lab4-api:1.1.0",
"memory_limit": 536870912,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-api-2",
"id": "0fe6963e2e3f",
"started": "2026-11-16T14:50:45.756873756Z",
"image": "mtusi-lab4-api:1.1.0",
"memory_limit": 536870912,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-lb-1",
"id": "b037c886a390",
"started": "2026-11-16T14:50:44.691408938Z",
"image": "haproxy:3.0.7-alpine",
"memory_limit": 134217728,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-postgres-1",
"id": "01a11c4599ef",
"started": "2026-11-16T14:50:44.737552905Z",
"image": "postgres:17.2-alpine",
"memory_limit": 536870912,
"cpus": 1.0
},
{
"name": "/mtusi-lab4-s3-1",
"id": "1e4d8a357ae6",
"started": "2026-11-16T14:50:45.849082671Z",
"image": "chrislusf/seaweedfs:3.85",
"memory_limit": 536870912,
"cpus": 1.0
}
]
+42
View File
@@ -0,0 +1,42 @@
[
{
"name": "/mtusi-lab4-api-1",
"id": "4eba80629d64",
"started": "2026-11-16T14:45:51.305158139Z",
"image": "mtusi-lab4-api:1.1.0",
"memory_limit": 536870912,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-api-2",
"id": "0fe6963e2e3f",
"started": "2026-11-16T14:45:51.57620223Z",
"image": "mtusi-lab4-api:1.1.0",
"memory_limit": 536870912,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-lb-1",
"id": "b037c886a390",
"started": "2026-11-16T14:32:24.804548928Z",
"image": "haproxy:3.0.7-alpine",
"memory_limit": 134217728,
"cpus": 0.5
},
{
"name": "/mtusi-lab4-postgres-1",
"id": "01a11c4599ef",
"started": "2026-11-16T14:32:24.878985233Z",
"image": "postgres:17.2-alpine",
"memory_limit": 536870912,
"cpus": 1.0
},
{
"name": "/mtusi-lab4-s3-1",
"id": "1e4d8a357ae6",
"started": "2026-11-16T14:48:26.751569712Z",
"image": "chrislusf/seaweedfs:3.85",
"memory_limit": 536870912,
"cpus": 1.0
}
]
+128
View File
@@ -0,0 +1,128 @@
{
"database_failure_after_put": {
"before_objects": 53,
"after_objects": 53,
"http_status": 503
},
"scan_cost": [
{
"extra_objects": 10,
"repeats": [
{
"apply": false,
"grace_seconds": 3600,
"objects": 63,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 10,
"referenced_preserved": 53,
"elapsed_seconds": 0.554496
},
{
"apply": false,
"grace_seconds": 3600,
"objects": 63,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 10,
"referenced_preserved": 53,
"elapsed_seconds": 2.475882
},
{
"apply": false,
"grace_seconds": 3600,
"objects": 63,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 10,
"referenced_preserved": 53,
"elapsed_seconds": 0.997638
}
]
},
{
"extra_objects": 100,
"repeats": [
{
"apply": false,
"grace_seconds": 3600,
"objects": 153,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 100,
"referenced_preserved": 53,
"elapsed_seconds": 0.83912
},
{
"apply": false,
"grace_seconds": 3600,
"objects": 153,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 100,
"referenced_preserved": 53,
"elapsed_seconds": 0.807927
},
{
"apply": false,
"grace_seconds": 3600,
"objects": 153,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 100,
"referenced_preserved": 53,
"elapsed_seconds": 0.879804
}
]
}
],
"old_used_attachment": {
"checksum_matches": true,
"message_reference_preserved": true,
"apply": {
"apply": true,
"grace_seconds": 3600,
"objects": 153,
"metadata": 53,
"list_requests": 1,
"head_requests": 1,
"orphan_candidates": 0,
"missing_candidates": 0,
"deleted": 0,
"marked_failed": 0,
"fresh_preserved": 100,
"referenced_preserved": 53,
"elapsed_seconds": 0.793124
}
}
}
+1
View File
@@ -0,0 +1 @@
PASS: failure after S3 PUT compensates, old used attachment survives, scan cost measured twice with three repeats
+1
View File
@@ -0,0 +1 @@
PASS: offline skeleton structure, local refs and Python syntax; application NOT tested.
+8
View File
@@ -0,0 +1,8 @@
{
"ServerVersion": "29.1.3",
"OperatingSystem": "Docker Desktop (containerized)",
"Architecture": "x86_64",
"NCPU": 8,
"MemTotal": 8214183936,
"KernelVersion": "6.18.58.1-microsoft-standard-WSL2"
}
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 96, "failed_attempts": 6, "first_recovery_seconds": 4.274}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+3
View File
@@ -0,0 +1,3 @@
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 99, "failed_attempts": 3, "first_recovery_seconds": 3.328}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+2
View File
@@ -0,0 +1,2 @@
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
+3
View File
@@ -0,0 +1,3 @@
Container mtusi-lab4-api-2 Running
Container mtusi-lab4-api-1 Starting
Container mtusi-lab4-api-1 Started
+3
View File
@@ -0,0 +1,3 @@
Container mtusi-lab4-api-1 Running
Container mtusi-lab4-api-2 Starting
Container mtusi-lab4-api-2 Started
+27
View File
@@ -0,0 +1,27 @@
annotated-types==0.8.0
anyio==4.16.0
argon2-cffi==23.1.0
argon2-cffi-bindings==26.2.0
boto3==1.36.26
botocore==1.36.26
cffi==2.1.1
click==8.5.1
fastapi==0.115.6
h11==0.16.0
idna==3.20
jmespath==1.1.0
pillow==11.1.0
psycopg==3.2.3
psycopg-binary==3.2.3
psycopg-pool==3.3.3
pycparser==3.12
pydantic==2.14.3
pydantic_core==2.50.4
python-dateutil==2.9.0.post0
s3transfer==0.11.3
six==1.17.0
starlette==0.41.3
typing-inspection==0.4.5
typing_extensions==4.16.0
urllib3==2.8.0
uvicorn==0.34.0
+1
View File
@@ -0,0 +1 @@
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
+1
View File
@@ -0,0 +1 @@
PASS: lab4 public API scenario; infrastructure and grading evidence remain separate.
+24
View File
@@ -0,0 +1,24 @@
{
"sha256": {
"compose.yaml": "6901392374b4ac92f183782886168bac9b42b1bd2bae3a432f31d443872781b9",
"Dockerfile": "190e39b1ce03433d0010ddf063a46ab82e539dc16c9be2ce8704bc39d89015ce",
"infra/filer.toml": "ae3c01bf7708f5d4a319fdb454f753be0f137fe7c31269f1c413cbccc860f5c7",
"infra/haproxy.cfg": "3dbce285792a5347d5588eea9f0d8558295202a5bccf42ec05bc027376871f41",
"infra/README.md": "33a4f7b870fd0b2bed98d46daf26d45dd7436176739672925246f8e3fe7c2278",
"migrations/001_initial.sql": "6e4c5ff62e1fd04f0c3cdeaf129709a8942d40baf2515db9d1c0f8d8491173e3",
"migrations/002_attachments.sql": "e3a5e05767086a5121706cc4c341eed2d906366aba70d03ce6ca16bb7cca34c3",
"migrations/003_attachment_fields.sql": "78fe93590db8508dec1bae48f5a074d4dfa081ec4e0c33558011a7082dc085a2",
"requirements.txt": "602bd0923251ac8874a32b5b9a102692f34fb6a486744bec6af25766ea0a8e1e",
"src/__init__.py": "01ba4719c80b6fe911b091a7c05124b64eeece964e09c058ef8f9805daca546b",
"src/attachments.py": "6cb081938be6101886cd438240935a413e6ed0be203cb95d2b9489b0ac090a53",
"src/bootstrap_storage.py": "9f10a9cc4accac2e9c0323b319ef89677f90cdcb6b950ef43c62f98349ba7ba9",
"src/healthcheck.py": "403007af34767db13e501295a849a5187e8cffbfdfafc4890fa022442a8c27d3",
"src/main.py": "5bf0610186532d856e96b3014a2c1c3ac8ed63937c655036e1460a7de2521db1",
"src/migrate.py": "dedbaa3e5810b9cca9b70347a6489bfc2286aa572f612e5c9079ca027a72f44a",
"src/reconcile.py": "89118be83b3b213713862e7409c3e9ccbf792a55590ce1295bfc4e769c6a016f",
"src/storage.py": "090ada62b5c5c537d7af99df5b245982bb688bd0b33af644eec98bf9fe0f5834",
"student-tests/acceptance.py": "5f6264dc9f65742d7787682aa19f96d9c9db3f087a116f1617814d8914cf9cdf",
"student-tests/consistency.py": "ce32d6c89b0030b44d08751cc5fde53df855142e1058698c620ef65edff3293d"
},
"container_sources_match": true
}
+2
View File
@@ -0,0 +1,2 @@
{"target_instance": "4eba80629d64", "container_id": "4eba80629d64", "name": "/mtusi-lab4-api-1", "status_after": "exited", "finished_at": "2026-11-16T14:51:20.539870025Z"}
{"target_instance": "0fe6963e2e3f", "container_id": "0fe6963e2e3f", "name": "/mtusi-lab4-api-2", "status_after": "exited", "finished_at": "2026-11-16T14:51:44.938007996Z"}