Добавить две реплики API за HAProxy и проверку отказа одной из них.

Общие сессии и ключ идемпотентности позволяют продолжать чтение и запись, когда одна реплика остановлена.
This commit is contained in:
2026-11-06 17:31:40 +03:00
parent 4303783848
commit d065cffb4e
31 changed files with 980 additions and 109 deletions
+4
View File
@@ -0,0 +1,4 @@
messenger-lab3-api-1 Up 25 seconds (healthy)
messenger-lab3-haproxy-1 Up 25 seconds (healthy)
messenger-lab3-postgres-1 Up 25 seconds (healthy)
messenger-lab3-redis-1 Up 25 seconds (healthy)
+4
View File
@@ -0,0 +1,4 @@
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": 121, "failed_attempts": 1, "first_recovery_seconds": 0.209}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+4
View File
@@ -0,0 +1,4 @@
messenger-lab3-api-2 Up 16 seconds (healthy)
messenger-lab3-haproxy-1 Up 42 seconds (healthy)
messenger-lab3-postgres-1 Up 42 seconds (healthy)
messenger-lab3-redis-1 Up 42 seconds (healthy)
+4
View File
@@ -0,0 +1,4 @@
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": 120, "failed_attempts": 1, "first_recovery_seconds": 2.435}
PASS: failover preserved confirmed data and existing session. Hook scope needs operator evidence.
+37
View File
@@ -0,0 +1,37 @@
{
"instances_before": [
"884d89d0d7f2",
"c785aa003e06"
],
"failover": [
{
"ok": 3678,
"fail": 45,
"after_ok": 2613,
"target_after_stop": 0,
"first_recovery_s": 0.002,
"hook_exit": 0,
"hook_seconds": 0.406,
"target": "884d89d0d7f2",
"successful_rps": 306.5
},
{
"ok": 3918,
"fail": 57,
"after_ok": 2889,
"target_after_stop": 0,
"first_recovery_s": 0.001,
"hook_exit": 0,
"hook_seconds": 0.431,
"target": "c785aa003e06",
"successful_rps": 326.5
}
],
"idempotency_race": {
"parallel_requests": 12,
"distinct_ids": 1,
"successes": 12,
"errors": [],
"history_copies": 1
}
}
+24
View File
@@ -0,0 +1,24 @@
GET /health/live via http://127.0.0.1:8080
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
d5e8c2b90b42
de5c28c8b010
--- container hostnames ---
/messenger-lab3-api-5 de5c28c8b010
/messenger-lab3-api-6 d5e8c2b90b42
+3
View File
@@ -0,0 +1,3 @@
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.
+17
View File
@@ -0,0 +1,17 @@
{
"lab": 3,
"workload": "closed-loop POST messages; no automatic retries",
"requested_duration_seconds": 40.0,
"elapsed_seconds": 40.013,
"concurrency": 4,
"successful_requests": 14411,
"failed_requests": 61,
"error_ratio": 0.004215,
"successful_rps": 360.155,
"successful_latency_ms": {
"p50": 6.583,
"p95": 45.927,
"p99": 85.417
},
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
}
+6
View File
@@ -0,0 +1,6 @@
version | applied_at
---------------------+-------------------------------
001_init.sql | 2026-11-05 15:32:01.011829+00
002_idempotency.sql | 2026-11-05 15:32:01.026576+00
(2 rows)
+2
View File
@@ -0,0 +1,2 @@
python3 tests/smoke.py --base-url "http://localhost:8080"
PASS: lab3 public API scenario; infrastructure and grading evidence remain separate.