forked from mtusi2026/mtusi2026lab3
ЛР 3: масштабирование и отказоустойчивость API
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"scenario": "sequential failover of each API replica",
|
||||
"replicas": 2,
|
||||
"results": [
|
||||
{
|
||||
"target_instance_id": "170796a1dad0",
|
||||
"window_seconds": 15.038,
|
||||
"successful_reads": 81,
|
||||
"successful_writes": 82,
|
||||
"failed_attempts": 0,
|
||||
"successful_rps": 10.839,
|
||||
"first_recovery_seconds": 1.306
|
||||
},
|
||||
{
|
||||
"target_instance_id": "feb12e05fd43",
|
||||
"window_seconds": 15.079,
|
||||
"successful_reads": 75,
|
||||
"successful_writes": 76,
|
||||
"failed_attempts": 0,
|
||||
"successful_rps": 10.014,
|
||||
"first_recovery_seconds": 2.672
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
# Lab3 level 4 evidence — 2026-11-03
|
||||
|
||||
Environment: Windows host, Docker Desktop Engine 28.0.1, Compose deployment on
|
||||
one machine, two API replicas limited to 0.75 CPU / 768 MiB each. All requests
|
||||
used Nginx at `http://localhost:8080`; API ports were not published.
|
||||
|
||||
## Sequential failover
|
||||
|
||||
Command:
|
||||
|
||||
```text
|
||||
python student_tests/failover_each.py --action-script scripts/stop-one.cmd \
|
||||
--restore-script scripts/restore-api.cmd --window 15 \
|
||||
--output evidence/failover-each-2026-11-03.json
|
||||
```
|
||||
|
||||
| Target instance | Successful reads | Successful writes | Errors | Successful RPS | First recovery |
|
||||
| --- | ---: | ---: | ---: | ---: | ---: |
|
||||
| `170796a1dad0` | 81 | 82 | 0 | 10.839 | 1.306 s |
|
||||
| `feb12e05fd43` | 75 | 76 | 0 | 10.014 | 2.672 s |
|
||||
|
||||
The stopped replica was restored and observed again before the next target was
|
||||
stopped. Confirmed messages remained readable after both failures.
|
||||
|
||||
## Shared idempotency
|
||||
|
||||
`python student_tests/idempotency_concurrent.py` passed: 32 concurrent requests with
|
||||
one key used two API instance IDs and created exactly one message.
|
||||
|
||||
## Sequential replacement under load
|
||||
|
||||
Command:
|
||||
|
||||
```text
|
||||
python student_tests/rolling_update.py --action-script scripts/rolling-update.cmd \
|
||||
--duration 180 --concurrency 4 \
|
||||
--output evidence/rolling-update-2026-11-03.json
|
||||
```
|
||||
|
||||
- Rolling action: 115.800 s.
|
||||
- Four instance IDs observed: two original and two replacements.
|
||||
- Successful writes: 12,147; failed attempts: 177.
|
||||
- Successful RPS: 67.439; error ratio: 1.4362%.
|
||||
- Successful latency: p50 37.729 ms, p95 189.374 ms, p99 215.986 ms.
|
||||
|
||||
This is a closed-loop single-host experiment. It includes coordinated omission
|
||||
and client overhead; latency percentiles cover successes only. Brief failures
|
||||
are retained in the result rather than hidden by client retries. PostgreSQL,
|
||||
Nginx and the Docker host remain single points of failure.
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"scenario": "hard loss of one Swarm worker",
|
||||
"failed_node": "hla-swarm-worker2",
|
||||
"old_task_id": "sesmka0dxn5k",
|
||||
"tasks_before": [
|
||||
{
|
||||
"task_id": "zmboecjxvdyn",
|
||||
"node": "hla-swarm-manager"
|
||||
},
|
||||
{
|
||||
"task_id": "sesmka0dxn5k",
|
||||
"node": "hla-swarm-worker2"
|
||||
}
|
||||
],
|
||||
"tasks_after_relocation": [
|
||||
{
|
||||
"task_id": "zmboecjxvdyn",
|
||||
"node": "hla-swarm-manager"
|
||||
},
|
||||
{
|
||||
"task_id": "pke5uf5okm69",
|
||||
"node": "hla-swarm-worker1"
|
||||
}
|
||||
],
|
||||
"instance_ids_before": [
|
||||
"1726221ff80d",
|
||||
"edb5532a721e"
|
||||
],
|
||||
"instance_ids_after": [
|
||||
"1726221ff80d",
|
||||
"81c7197f2bfe"
|
||||
],
|
||||
"successful_reads": 165,
|
||||
"successful_writes": 166,
|
||||
"failed_attempts": 0,
|
||||
"first_recovery_seconds": 1.796,
|
||||
"successful_rps": 11.033,
|
||||
"experiment_seconds_including_rejoin": 73.763,
|
||||
"confirmed_data_preserved": true,
|
||||
"database_node_failed": false,
|
||||
"note": "PostgreSQL, Nginx, manager quorum and local volumes are not protected by this experiment."
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
# Swarm worker-node failover — 2026-11-03
|
||||
|
||||
Topology: one Swarm manager and two workers, implemented as three privileged
|
||||
Docker-in-Docker daemons. Two API tasks used `max_replicas_per_node=1`. Nginx,
|
||||
PostgreSQL and Redis remained on the live manager. Images were pulled by nodes
|
||||
from the disposable local registry by digest.
|
||||
|
||||
Command:
|
||||
|
||||
```text
|
||||
python student_tests/node_failover.py --base-url http://localhost:18080 \
|
||||
--window 30 --output evidence/node-failover-2026-11-03.json
|
||||
```
|
||||
|
||||
Observed result:
|
||||
|
||||
- Hard-stopped node: `hla-swarm-worker2` (the entire nested Docker daemon).
|
||||
- Old API task: `sesmka0dxn5k` on `worker2`.
|
||||
- Replacement API task: `pke5uf5okm69` on `worker1`.
|
||||
- Other API task remained on manager.
|
||||
- Instance IDs changed from `1726221ff80d` / `edb5532a721e` to
|
||||
`1726221ff80d` / `81c7197f2bfe`.
|
||||
- Successful reads: 165; successful writes: 166; failed attempts: 0.
|
||||
- First successful operation after node-stop started: 1.796 s.
|
||||
- Successful operations per second during the 30 s window: 11.033.
|
||||
- The pre-failure confirmed message and every response-confirmed in-flight
|
||||
message remained readable.
|
||||
- The stopped worker rejoined in `Ready` state after the experiment.
|
||||
|
||||
Protected scope: loss of one worker carrying an API task while manager/state
|
||||
remain alive. Not protected and not claimed: PostgreSQL node loss, manager
|
||||
quorum loss, Nginx loss, local-volume loss, underlay loss, or physical host
|
||||
loss. `database_node_failed` is explicitly `false` in the raw JSON.
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"scenario": "sequential API replacement under closed-loop writes",
|
||||
"requested_duration_seconds": 180.0,
|
||||
"elapsed_seconds": 180.118,
|
||||
"rolling_action_seconds": 115.8,
|
||||
"concurrency": 4,
|
||||
"observed_instance_ids": [
|
||||
"5782a3226f58",
|
||||
"d3604e18baea",
|
||||
"e54e39339867",
|
||||
"e55cbed4e283"
|
||||
],
|
||||
"successful_requests": 12147,
|
||||
"failed_requests": 177,
|
||||
"error_ratio": 0.014362,
|
||||
"successful_rps": 67.439,
|
||||
"successful_latency_ms": {
|
||||
"p50": 37.729,
|
||||
"p95": 189.374,
|
||||
"p99": 215.986
|
||||
},
|
||||
"note": "Closed-loop result on one host; success latency excludes failures."
|
||||
}
|
||||
Reference in New Issue
Block a user