выполнение ЛР3 на 4

This commit is contained in:
Ilya
2026-10-21 12:20:11 +03:00
parent 0ab3a341aa
commit 6f4f74d691
37 changed files with 2854 additions and 15 deletions
+151
View File
@@ -0,0 +1,151 @@
{
"profile": "closed loop, 8 workers, each: POST message (retry same key) + GET history; client timeout 2 s",
"action": "scripts/stop-container.sh messenger-lab3-api-1",
"action_started_s": 5.01,
"action_finished_s": 5.85,
"action_returncode": 0,
"action_output": [
"2026-10-15T11:50:36Z stopped messenger-lab3-api-1 instance=api-44e6d584 state=exited"
],
"elapsed_s": 25.01,
"requests": 15020,
"successful": 15020,
"errors": 0,
"error_ratio": 0.0,
"successful_rps": 600.5,
"latency_ms_success": {
"p50": 7.9,
"p95": 45.1,
"p99": 59.3,
"max": 1019.3
},
"slow_over_500ms_after_action": 16,
"error_window_s": null,
"recovery_s_after_action": 2.72,
"instances_before": {
"api-44e6d584": 2031,
"api-183aa91a": 2034
},
"instances_last_5s": {
"api-183aa91a": 2848
},
"timeline_ok_err_per_s": {
"0": [
702,
0
],
"1": [
658,
0
],
"2": [
872,
0
],
"3": [
933,
0
],
"4": [
887,
0
],
"5": [
436,
0
],
"6": [
13,
0
],
"7": [
196,
0
],
"8": [
679,
0
],
"9": [
639,
0
],
"10": [
581,
0
],
"11": [
687,
0
],
"12": [
616,
0
],
"13": [
582,
0
],
"14": [
644,
0
],
"15": [
574,
0
],
"16": [
655,
0
],
"17": [
619,
0
],
"18": [
536,
0
],
"19": [
653,
0
],
"20": [
634,
0
],
"21": [
463,
0
],
"22": [
618,
0
],
"23": [
655,
0
],
"24": [
484,
0
],
"25": [
4,
0
]
},
"docker_stats_mid": [
"messenger-lab3-api-2\t50.73%\t86.94MiB / 256MiB",
"messenger-lab3-lb-1\t13.03%\t15.18MiB / 128MiB",
"messenger-lab3-postgres-1\t21.00%\t49.02MiB / 512MiB",
"messenger-lab3-valkey-1\t1.77%\t10.82MiB / 96MiB"
],
"integrity": {
"stored_messages": 7510,
"confirmed_writes": 7510,
"duplicate_ids": 0,
"duplicate_texts": 0,
"confirmed_missing": 0
}
}
+151
View File
@@ -0,0 +1,151 @@
{
"profile": "closed loop, 8 workers, each: POST message (retry same key) + GET history; client timeout 2 s",
"action": "scripts/stop-container.sh messenger-lab3-api-2",
"action_started_s": 5.02,
"action_finished_s": 5.63,
"action_returncode": 0,
"action_output": [
"2026-10-15T11:51:13Z stopped messenger-lab3-api-2 instance=api-183aa91a state=exited"
],
"elapsed_s": 25.01,
"requests": 15264,
"successful": 15264,
"errors": 0,
"error_ratio": 0.0,
"successful_rps": 610.3,
"latency_ms_success": {
"p50": 8.1,
"p95": 43.8,
"p99": 57.5,
"max": 1019.9
},
"slow_over_500ms_after_action": 16,
"error_window_s": null,
"recovery_s_after_action": 2.52,
"instances_before": {
"api-183aa91a": 2312,
"api-85c04c87": 2313
},
"instances_last_5s": {
"api-85c04c87": 2967
},
"timeline_ok_err_per_s": {
"0": [
863,
0
],
"1": [
1010,
0
],
"2": [
963,
0
],
"3": [
999,
0
],
"4": [
766,
0
],
"5": [
305,
0
],
"6": [
14,
0
],
"7": [
277,
0
],
"8": [
658,
0
],
"9": [
575,
0
],
"10": [
524,
0
],
"11": [
650,
0
],
"12": [
584,
0
],
"13": [
646,
0
],
"14": [
571,
0
],
"15": [
580,
0
],
"16": [
544,
0
],
"17": [
634,
0
],
"18": [
623,
0
],
"19": [
502,
0
],
"20": [
562,
0
],
"21": [
641,
0
],
"22": [
494,
0
],
"23": [
623,
0
],
"24": [
651,
0
],
"25": [
5,
0
]
},
"docker_stats_mid": [
"messenger-lab3-api-1\t51.61%\t86.96MiB / 256MiB",
"messenger-lab3-lb-1\t14.03%\t15.85MiB / 128MiB",
"messenger-lab3-postgres-1\t30.28%\t47.1MiB / 512MiB",
"messenger-lab3-valkey-1\t1.79%\t10.82MiB / 96MiB"
],
"integrity": {
"stored_messages": 7632,
"confirmed_writes": 7632,
"duplicate_ids": 0,
"duplicate_texts": 0,
"confirmed_missing": 0
}
}
+90
View File
@@ -0,0 +1,90 @@
=== round 1 2026-10-15T11:45:37Z
NAME STATUS
messenger-lab3-api-1 Up 40 seconds (healthy)
messenger-lab3-api-2 Up 40 seconds (healthy)
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 110, "failed_attempts": 0, "first_recovery_seconds": 3.411}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:45:41Z stopped messenger-lab3-api-2 (2179542de855) instance=api-6a5e985e state=exited
NAME STATUS
messenger-lab3-api-1 Up 57 seconds (healthy)
messenger-lab3-api-2 Exited (0) 14 seconds ago
--- restore:
NAME STATUS
messenger-lab3-api-1 Up About a minute (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
=== round 2 2026-10-15T11:46:05Z
NAME STATUS
messenger-lab3-api-1 Up About a minute (healthy)
messenger-lab3-api-2 Up 8 seconds (healthy)
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 112, "failed_attempts": 0, "first_recovery_seconds": 2.682}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:46:07Z stopped messenger-lab3-api-2 (2179542de855) instance=api-60495ffd state=exited
NAME STATUS
messenger-lab3-api-1 Up About a minute (healthy)
messenger-lab3-api-2 Exited (0) 14 seconds ago
--- restore:
NAME STATUS
messenger-lab3-api-1 Up About a minute (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
=== round 3 2026-10-15T11:46:43Z
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 116, "failed_attempts": 0, "first_recovery_seconds": 3.031}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:46:46Z stopped messenger-lab3-api-2 (2179542de855) instance=api-ddb0f40b state=exited
NAME STATUS
messenger-lab3-api-1 Up 2 minutes (healthy)
messenger-lab3-api-2 Exited (0) 14 seconds ago
--- restore:
NAME STATUS
messenger-lab3-api-1 Up 2 minutes (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
=== round 4 2026-10-15T11:47:11Z
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 123, "failed_attempts": 0, "first_recovery_seconds": 1.565}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:47:14Z stopped messenger-lab3-api-2 (2179542de855) instance=api-a0e07848 state=exited
NAME STATUS
messenger-lab3-api-1 Up 2 minutes (healthy)
messenger-lab3-api-2 Exited (0) 14 seconds ago
--- restore:
NAME STATUS
messenger-lab3-api-1 Up 2 minutes (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
=== round 5 2026-10-15T11:47:38Z
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 111, "failed_attempts": 0, "first_recovery_seconds": 2.691}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:47:42Z stopped messenger-lab3-api-2 (2179542de855) instance=api-1968c7c7 state=exited
NAME STATUS
messenger-lab3-api-1 Up 2 minutes (healthy)
messenger-lab3-api-2 Exited (0) 14 seconds ago
--- restore:
NAME STATUS
messenger-lab3-api-1 Up 3 minutes (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
=== round 6 (one extra LB request first to shift round-robin parity) 2026-10-15T11:48:18Z
python3 tests/resilience.py --mode failover --action-script "scripts/stop-one.sh" --base-url "http://localhost:8088"
Executing explicit failover hook; hook output suppressed to avoid leaking secrets.
{"observed_instances_before": 2, "successful_writes": 114, "failed_attempts": 0, "first_recovery_seconds": 2.913}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
--- after hook:
2026-10-15T11:48:21Z stopped messenger-lab3-api-1 (d58678cd6981) instance=api-2afcbc6e state=exited
NAME STATUS
messenger-lab3-api-1 Exited (0) 14 seconds ago
messenger-lab3-api-2 Up 37 seconds (healthy)
--- restore:
NAME STATUS
messenger-lab3-api-1 Up 5 seconds (healthy)
messenger-lab3-api-2 Up 44 seconds (healthy)
+11
View File
@@ -0,0 +1,11 @@
ok - round 1: 32 parallel requests, 1 message, replicas {'api-44e6d584': 16, 'api-183aa91a': 16}
ok - round 2: 32 parallel requests, 1 message, replicas {'api-183aa91a': 16, 'api-44e6d584': 16}
ok - round 3: 32 parallel requests, 1 message, replicas {'api-44e6d584': 16, 'api-183aa91a': 16}
ok - round 4: 32 parallel requests, 1 message, replicas {'api-183aa91a': 16, 'api-44e6d584': 16}
ok - round 5: 32 parallel requests, 1 message, replicas {'api-183aa91a': 16, 'api-44e6d584': 16}
ok - different body with same key -> 409, original replays unchanged
ok - same key independent per user and per chat
ok - missing/invalid Idempotency-Key -> 400, max-length key accepted
ok - replay needs a valid session and chat access (404 outsider, 401 revoked)
ok - DB rows in chat: 8, history items: 8, no duplicate texts
PASS: shared idempotency
+11
View File
@@ -0,0 +1,11 @@
# all API replicas stopped -> LB answers itself
Container messenger-lab3-api-4 Stopped
HTTP/1.1 503 Service Unavailable
x-request-id: 288cf625-3642-4f98-90c3-5685c8d020f5
content-type: application/json
{"error":{"code":"unavailable","message":"no healthy API replica","request_id":"288cf625-3642-4f98-90c3-5685c8d020f5"}}
NAME STATUS
messenger-lab3-api-3 Up 5 seconds (healthy)
messenger-lab3-api-4 Up 5 seconds (healthy)
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 30.0,
"elapsed_seconds": 30.019,
"concurrency": 4,
"successful_requests": 25240,
"failed_requests": 0,
"error_ratio": 0.0,
"successful_rps": 840.8,
"successful_latency_ms": {
"p50": 4.39,
"p95": 6.434,
"p99": 10.283
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+31
View File
@@ -0,0 +1,31 @@
=== 2026-10-15T11:48:52Z before
NAME STATUS CREATED AT
messenger-lab3-api-1 Up 15 seconds (healthy) 2026-10-15 14:44:55 +0300 MSK
messenger-lab3-api-2 Up 54 seconds (healthy) 2026-10-15 14:44:55 +0300 MSK
messenger-lab3-lb-1 Up 3 minutes (healthy) 2026-10-15 14:44:55 +0300 MSK
messenger-lab3-migrate-1 Exited (0) 15 seconds ago 2026-10-15 14:44:55 +0300 MSK
messenger-lab3-postgres-1 Up 4 minutes (healthy) 2026-10-15 14:44:00 +0300 MSK
messenger-lab3-valkey-1 Up 4 minutes (healthy) 2026-10-15 14:44:00 +0300 MSK
/messenger-lab3-api-1 started=2026-10-15T11:48:37.123716387Z
/messenger-lab3-api-2 started=2026-10-15T11:47:58.013947425Z
/messenger-lab3-lb-1 started=2026-10-15T11:44:57.43671605Z
/messenger-lab3-postgres-1 started=2026-10-15T11:44:00.488171093Z
/messenger-lab3-valkey-1 started=2026-10-15T11:44:00.486537093Z
python3 tests/resilience.py --mode persistence --action-script "scripts/restart.sh" --base-url "http://localhost:8088"
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
NAME STATUS
messenger-lab3-api-1 Up 5 seconds (healthy)
messenger-lab3-api-2 Up 5 seconds (healthy)
messenger-lab3-lb-1 Up 5 seconds (healthy)
messenger-lab3-migrate-1 Exited (0) 6 seconds ago
messenger-lab3-postgres-1 Up 9 seconds (healthy)
messenger-lab3-valkey-1 Up 9 seconds (healthy)
/messenger-lab3-api-1 started=2026-10-15T11:48:59.064957134Z
/messenger-lab3-api-2 started=2026-10-15T11:48:58.9953378Z
/messenger-lab3-lb-1 started=2026-10-15T11:48:59.147870509Z
/messenger-lab3-postgres-1 started=2026-10-15T11:48:55.83871384Z
/messenger-lab3-valkey-1 started=2026-10-15T11:48:55.838344632Z
DRIVER VOLUME NAME
local messenger-lab3_pgdata
+259
View File
@@ -0,0 +1,259 @@
{
"profile": "closed loop, 8 workers, each: POST message (retry same key) + GET history; client timeout 2 s",
"action": "scripts/rolling-update.sh",
"action_started_s": 5.02,
"action_finished_s": 23.01,
"action_returncode": 0,
"action_output": [
"#13 DONE 0.0s",
"11:52:12 new /messenger-lab3-api-3 healthy; stopping old /messenger-lab3-api-1",
"11:52:20 new /messenger-lab3-api-4 healthy; stopping old /messenger-lab3-api-2",
"NAME IMAGE STATUS",
"messenger-lab3-api-3 mtusi-messenger:lab3 Up 16 seconds (healthy)",
"messenger-lab3-api-4 mtusi-messenger:lab3 Up 8 seconds (healthy)"
],
"elapsed_s": 50.01,
"requests": 41154,
"successful": 41154,
"errors": 0,
"error_ratio": 0.0,
"successful_rps": 822.9,
"latency_ms_success": {
"p50": 7.4,
"p95": 16.3,
"p99": 53.7,
"max": 1022.8
},
"slow_over_500ms_after_action": 24,
"error_window_s": null,
"recovery_s_after_action": 19.86,
"instances_before": {
"api-85c04c87": 2165,
"api-e53b9e96": 2165
},
"instances_last_5s": {
"api-57303f43": 1991,
"api-aef30e7d": 1991
},
"timeline_ok_err_per_s": {
"0": [
688,
0
],
"1": [
790,
0
],
"2": [
968,
0
],
"3": [
976,
0
],
"4": [
889,
0
],
"5": [
693,
0
],
"6": [
592,
0
],
"7": [
754,
0
],
"8": [
1146,
0
],
"9": [
1063,
0
],
"10": [
841,
0
],
"11": [
848,
0
],
"12": [
907,
0
],
"13": [
1028,
0
],
"14": [
473,
0
],
"15": [
274,
0
],
"16": [
953,
0
],
"17": [
877,
0
],
"18": [
898,
0
],
"19": [
917,
0
],
"20": [
1006,
0
],
"21": [
988,
0
],
"22": [
627,
0
],
"23": [
22,
0
],
"24": [
153,
0
],
"25": [
901,
0
],
"26": [
935,
0
],
"27": [
861,
0
],
"28": [
924,
0
],
"29": [
987,
0
],
"30": [
707,
0
],
"31": [
1004,
0
],
"32": [
906,
0
],
"33": [
829,
0
],
"34": [
911,
0
],
"35": [
881,
0
],
"36": [
883,
0
],
"37": [
914,
0
],
"38": [
818,
0
],
"39": [
925,
0
],
"40": [
751,
0
],
"41": [
1027,
0
],
"42": [
869,
0
],
"43": [
823,
0
],
"44": [
937,
0
],
"45": [
790,
0
],
"46": [
820,
0
],
"47": [
801,
0
],
"48": [
885,
0
],
"49": [
690,
0
],
"50": [
4,
0
]
},
"docker_stats_mid": [
"messenger-lab3-api-1\t51.08%\t175.1MiB / 256MiB",
"messenger-lab3-api-2\t50.01%\t82.92MiB / 256MiB",
"messenger-lab3-api-3\t49.31%\t50.11MiB / 256MiB",
"messenger-lab3-lb-1\t32.61%\t16.47MiB / 128MiB",
"messenger-lab3-postgres-1\t52.87%\t92.39MiB / 512MiB",
"messenger-lab3-valkey-1\t4.29%\t10.84MiB / 96MiB"
],
"integrity": {
"stored_messages": 20577,
"confirmed_writes": 20577,
"duplicate_ids": 0,
"duplicate_texts": 0,
"confirmed_missing": 0
}
}
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8088"
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.
+10
View File
@@ -0,0 +1,10 @@
2026-10-15T11:45:41Z stopped messenger-lab3-api-2 (2179542de855) instance=api-6a5e985e state=exited
2026-10-15T11:46:07Z stopped messenger-lab3-api-2 (2179542de855) instance=api-60495ffd state=exited
2026-10-15T11:46:46Z stopped messenger-lab3-api-2 (2179542de855) instance=api-ddb0f40b state=exited
2026-10-15T11:47:14Z stopped messenger-lab3-api-2 (2179542de855) instance=api-a0e07848 state=exited
2026-10-15T11:47:42Z stopped messenger-lab3-api-2 (2179542de855) instance=api-1968c7c7 state=exited
2026-10-15T11:48:21Z stopped messenger-lab3-api-1 (d58678cd6981) instance=api-2afcbc6e state=exited
2026-10-15T11:50:36Z stopped messenger-lab3-api-1 instance=api-44e6d584 state=exited
2026-10-15T11:51:13Z stopped messenger-lab3-api-2 instance=api-183aa91a state=exited
2026-10-15T12:01:37Z stopped messenger-lab3-api-1 (698dc5937ee2) instance=api-3bacb399 state=exited
2026-10-15T12:02:02Z stopped messenger-lab3-api-1 instance=api-8dd03a25 state=exited
+49
View File
@@ -0,0 +1,49 @@
# 2026-10-15T11:54:10Z one session (one Bearer token, single login) served by different replicas via LB
1 200 X-Instance-Id=api-255e07d5 user=u_demo_b7ea3c6d31d8
2 200 X-Instance-Id=api-624de536 user=u_demo_b7ea3c6d31d8
3 200 X-Instance-Id=api-255e07d5 user=u_demo_b7ea3c6d31d8
4 200 X-Instance-Id=api-624de536 user=u_demo_b7ea3c6d31d8
5 200 X-Instance-Id=api-255e07d5 user=u_demo_b7ea3c6d31d8
6 200 X-Instance-Id=api-624de536 user=u_demo_b7ea3c6d31d8
# instance id -> container mapping (alias file inside each container)
/messenger-lab3-api-3 api-624de536
/messenger-lab3-api-4 api-255e07d5
# published ports: only lb
NAME PORTS
messenger-lab3-api-3 8080/tcp
messenger-lab3-api-4 8080/tcp
messenger-lab3-lb-1 127.0.0.1:8088->8080/tcp
messenger-lab3-postgres-1
messenger-lab3-valkey-1
# limits (NanoCpus, Memory bytes)
/messenger-lab3-api-3 cpus=500000000 mem=268435456
/messenger-lab3-api-4 cpus=500000000 mem=268435456
/messenger-lab3-lb-1 cpus=500000000 mem=134217728
/messenger-lab3-postgres-1 cpus=1000000000 mem=536870912
/messenger-lab3-valkey-1 cpus=250000000 mem=100663296
# images
CONTAINER REPOSITORY TAG IMAGE ID SIZE
messenger-lab3-api-3 mtusi-messenger lab3 ae4ccc72928e 221MB
messenger-lab3-api-4 mtusi-messenger lab3 ae4ccc72928e 221MB
messenger-lab3-lb-1 haproxy 3.2.4-alpine 5b478a21578f 32.8MB
messenger-lab3-migrate-1 mtusi-messenger lab3 ae4ccc72928e 221MB
messenger-lab3-postgres-1 postgres 17.6-alpine3.22 29e645e20571 270MB
messenger-lab3-valkey-1 valkey/valkey 8.1.4-alpine3.22 b9cc2f089926 47.6MB
# migrations: applied once by the one-shot migrate service
INFO migrate: migrations up to date: 0 applied now, 2 before
INFO migrate: migrations up to date: 0 applied now, 2 before
INFO migrate: migrations up to date: 0 applied now, 2 before
version | applied_at
------------------+-------------------------------
0001_init | 2026-10-15 11:44:03.489347+00
0002_idempotency | 2026-10-15 11:44:03.497728+00
(2 rows)
# direct access to postgres from host / lb is impossible (internal network):
nc: bad address 'postgres'
postgres unreachable from lb