Обновить evidence и цифры в отчёте по финальному прогону
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,17 +46,17 @@ PostgreSQL, серверные сессии и Valkey
|
|||||||
|
|
||||||
### 2.2. Оценка «4»
|
### 2.2. Оценка «4»
|
||||||
|
|
||||||
| Критерий | Чем доказано |
|
| Критерий | Чем доказано |
|
||||||
|----------------------------------------------------------------------|---------------------------------------------------------------------------------------|
|
|----------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|
|
||||||
| Valkey с конкретной ролью (кэш сессий), источник истины — PostgreSQL | `EXISTS messenger:session:<sha256>` = 1 после первого запроса (`evidence/level4.txt`) |
|
| Valkey с конкретной ролью (кэш сессий), источник истины — PostgreSQL | `EXISTS messenger:session:<sha256>` = 1 после первого запроса (`evidence/level4.txt`) |
|
||||||
| Корректный expiry кэша | TTL записи = min(60 s, остаток жизни сессии); тест `api_short_ttl` |
|
| Корректный expiry кэша | TTL записи = min(60 s, остаток жизни сессии); тест `api_short_ttl` |
|
||||||
| Инвалидация при logout без гонки | tombstone `revoked` + заполнение через `SET NX` |
|
| Инвалидация при logout без гонки | tombstone `revoked` + заполнение через `SET NX` |
|
||||||
| Поведение при отказе Valkey (stop и pause) | задержка ≤ 0.26–0.30 s, токен, отозванный во время отказа, остаётся 401, в том числе после рестарта API |
|
| Поведение при отказе Valkey (stop и pause) | задержка ≤ 0.26–0.30 s, токен, отозванный во время отказа, остаётся 401, в том числе после рестарта API |
|
||||||
| Поведение при отказе PostgreSQL | `503 unavailable` за ~3 s, `ready` 503, `live` 200, анонимный запрос 401 |
|
| Поведение при отказе PostgreSQL | `503 unavailable` за ~3 s, `ready` 503, `live` 200, анонимный запрос 401 |
|
||||||
| Пул соединений и таймауты | `app/db.py`, `app/cache.py` |
|
| Пул соединений и таймауты | `app/db.py`, `app/cache.py` |
|
||||||
| Индекс истории обоснован EXPLAIN | keyset: 5 buffers против 208 (OFFSET) и 667 (без индекса) |
|
| Индекс истории обоснован EXPLAIN | keyset: 5 buffers против 208 (OFFSET) и 783 (без индекса) |
|
||||||
| Гонка регистрации | 20 параллельных запросов → `{201: 1, 409: 19}` |
|
| Гонка регистрации | 20 параллельных запросов → `{201: 1, 409: 19}` |
|
||||||
| Эксперимент отказа повторён с Valkey | persistence-тест перезапускает `db`, `valkey`, `api` |
|
| Эксперимент отказа повторён с Valkey | persistence-тест перезапускает `db`, `valkey`, `api` |
|
||||||
|
|
||||||
## 3. Запуск из чистого clone
|
## 3. Запуск из чистого clone
|
||||||
|
|
||||||
@@ -456,13 +456,13 @@ LIMIT 51; -- limit + 1, чтобы понять, есть ли сле
|
|||||||
|
|
||||||
### 11.2. Замер (`make db-checks`, `evidence/explain.txt`)
|
### 11.2. Замер (`make db-checks`, `evidence/explain.txt`)
|
||||||
|
|
||||||
Данные: один чат с 10 000 сообщений (всего в таблице ~50 000). Запрашивается страница после 9000-го сообщения.
|
Данные: один чат с 10 000 сообщений (всего в таблице ~59 000). Запрашивается страница после 9000-го сообщения.
|
||||||
|
|
||||||
| Вариант | План | Buffers | Время |
|
| Вариант | План | Buffers | Время |
|
||||||
|----------------------------------------------------------|---------------------------------------------------------------|--------------------|---------|
|
|----------------------------------------------------------|---------------------------------------------------------------|--------------------|---------|
|
||||||
| keyset + `messages_keyset_idx` | `Index Scan using messages_keyset_idx`, cursor в `Index Cond` | 5 (`hit=4 read=1`) | ~0.1 ms |
|
| keyset + `messages_keyset_idx` | `Index Scan using messages_keyset_idx`, cursor в `Index Cond` | 5 (`hit=4 read=1`) | ~0.1 ms |
|
||||||
| `OFFSET 9000` | `Sort` 9051 строк, 9000 из них отбрасываются | 208 | ~3.5 ms |
|
| `OFFSET 9000` | `Sort` 9051 строк, 9000 из них отбрасываются | 208 | ~3.7 ms |
|
||||||
| без индекса (удалён внутри транзакции, затем `ROLLBACK`) | `Seq Scan on messages`, ~49 000 строк отброшено фильтром | 667 | ~2.0 ms |
|
| без индекса (удалён внутри транзакции, затем `ROLLBACK`) | `Seq Scan on messages`, ~58 000 строк отброшено фильтром | 783 | ~2.2 ms |
|
||||||
|
|
||||||
Главная метрика — Buffers (прочитанные страницы по 8 КБ). Время на маленьких данных скачет, а число буферов стабильно. Keyset читает только нужную страницу независимо от глубины; OFFSET и Seq Scan читают тем больше, чем дальше страница.
|
Главная метрика — Buffers (прочитанные страницы по 8 КБ). Время на маленьких данных скачет, а число буферов стабильно. Keyset читает только нужную страницу независимо от глубины; OFFSET и Seq Scan читают тем больше, чем дальше страница.
|
||||||
|
|
||||||
@@ -494,10 +494,10 @@ git status --short # secrets и venv в списке отсутствуют
|
|||||||
|
|
||||||
| Метрика | Значение |
|
| Метрика | Значение |
|
||||||
|-------------------|-----------------------|
|
|-------------------|-----------------------|
|
||||||
| Успешных запросов | 4 776 |
|
| Успешных запросов | 4 071 |
|
||||||
| Ошибок | 0 |
|
| Ошибок | 0 |
|
||||||
| Successful RPS | ≈ 318 |
|
| Successful RPS | ≈ 271 |
|
||||||
| p50 / p95 / p99 | 12.1 / 15.6 / 19.4 ms |
|
| p50 / p95 / p99 | 13.4 / 22.9 / 31.9 ms |
|
||||||
|
|
||||||
Это один прогон, генератор нагрузки работает на той же машине, у closed-loop есть coordinated omission, CPU/RAM не измерялись.
|
Это один прогон, генератор нагрузки работает на той же машине, у closed-loop есть coordinated omission, CPU/RAM не измерялись.
|
||||||
Это не оценка максимальной пропускной способности, а подтверждение, что API стабильно пишет под параллельной нагрузкой без ошибок.
|
Это не оценка максимальной пропускной способности, а подтверждение, что API стабильно пишет под параллельной нагрузкой без ошибок.
|
||||||
|
|||||||
+1
-1
@@ -31,7 +31,7 @@
|
|||||||
## Нагрузка
|
## Нагрузка
|
||||||
|
|
||||||
Профиль: 4 concurrent клиента, 15 seconds, closed-loop `POST /api/v1/chats/{chat_id}/messages`, без automatic retries.
|
Профиль: 4 concurrent клиента, 15 seconds, closed-loop `POST /api/v1/chats/{chat_id}/messages`, без automatic retries.
|
||||||
Результат: 4776 успешных запросов, 0 ошибок, ≈318 RPS, p50/p95/p99 = 12.1/15.6/19.4 ms.
|
Результат: 4071 успешный запрос, 0 ошибок, ≈271 RPS, p50/p95/p99 = 13.4/22.9/31.9 ms.
|
||||||
|
|
||||||
Это локальное измерение на Docker Desktop/WSL2, а не production SLA.
|
Это локальное измерение на Docker Desktop/WSL2, а не production SLA.
|
||||||
Latency включает client overhead; closed-loop нагрузка подвержена coordinated omission.
|
Latency включает client overhead; closed-loop нагрузка подвержена coordinated omission.
|
||||||
|
|||||||
+26
-26
@@ -5,64 +5,64 @@ PASS: chat row was rolled back together with members
|
|||||||
PASS: no chats without members exist in the database
|
PASS: no chats without members exist in the database
|
||||||
|
|
||||||
== EXPLAIN for message history pagination
|
== EXPLAIN for message history pagination
|
||||||
messages total: 50010; in explained chat: 10000
|
messages total: 59232; in explained chat: 10000
|
||||||
PASS: explained chat has >= 10 000 messages
|
PASS: explained chat has >= 10 000 messages
|
||||||
|
|
||||||
-- first page
|
-- first page
|
||||||
Limit (actual time=0.011..0.018 rows=51 loops=1)
|
Limit (actual time=0.009..0.015 rows=51 loops=1)
|
||||||
Buffers: shared hit=4
|
Buffers: shared hit=4
|
||||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.010..0.014 rows=51 loops=1)
|
-> Index Scan using messages_keyset_idx on messages (actual time=0.009..0.012 rows=51 loops=1)
|
||||||
Index Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
Index Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
||||||
Buffers: shared hit=4
|
Buffers: shared hit=4
|
||||||
Planning:
|
Planning:
|
||||||
Buffers: shared hit=8
|
Buffers: shared hit=6
|
||||||
Planning Time: 0.075 ms
|
Planning Time: 0.067 ms
|
||||||
Execution Time: 0.033 ms
|
Execution Time: 0.031 ms
|
||||||
|
|
||||||
-- keyset page after position 9000
|
-- keyset page after position 9000
|
||||||
Limit (actual time=0.083..0.093 rows=51 loops=1)
|
Limit (actual time=0.012..0.020 rows=51 loops=1)
|
||||||
Buffers: shared hit=5
|
Buffers: shared hit=5
|
||||||
-> Index Scan using messages_keyset_idx on messages (actual time=0.082..0.089 rows=51 loops=1)
|
-> Index Scan using messages_keyset_idx on messages (actual time=0.011..0.017 rows=51 loops=1)
|
||||||
Index Cond: ((chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 19:08:45.800971+00'::timestamp with time zone, '6f9dad83-2a94-400a-877b-7202790747a3'::uuid)))
|
Index Cond: ((chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 19:08:45.800971+00'::timestamp with time zone, '6f9dad83-2a94-400a-877b-7202790747a3'::uuid)))
|
||||||
Buffers: shared hit=5
|
Buffers: shared hit=5
|
||||||
Planning Time: 0.040 ms
|
Planning Time: 0.051 ms
|
||||||
Execution Time: 0.149 ms
|
Execution Time: 0.069 ms
|
||||||
|
|
||||||
-- OFFSET 9000 (not used by the API)
|
-- OFFSET 9000 (not used by the API)
|
||||||
Limit (actual time=3.359..3.364 rows=51 loops=1)
|
Limit (actual time=3.472..3.479 rows=51 loops=1)
|
||||||
Buffers: shared hit=208
|
Buffers: shared hit=208
|
||||||
-> Sort (actual time=2.897..3.166 rows=9051 loops=1)
|
-> Sort (actual time=2.992..3.279 rows=9051 loops=1)
|
||||||
Sort Key: created_at, id
|
Sort Key: created_at, id
|
||||||
Sort Method: quicksort Memory: 1713kB
|
Sort Method: quicksort Memory: 1713kB
|
||||||
Buffers: shared hit=208
|
Buffers: shared hit=208
|
||||||
-> Bitmap Heap Scan on messages (actual time=0.209..0.786 rows=10000 loops=1)
|
-> Bitmap Heap Scan on messages (actual time=0.190..0.756 rows=10000 loops=1)
|
||||||
Recheck Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
Recheck Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
||||||
Heap Blocks: exact=134
|
Heap Blocks: exact=134
|
||||||
Buffers: shared hit=208
|
Buffers: shared hit=208
|
||||||
-> Bitmap Index Scan on messages_keyset_idx (actual time=0.194..0.194 rows=10000 loops=1)
|
-> Bitmap Index Scan on messages_keyset_idx (actual time=0.177..0.178 rows=10000 loops=1)
|
||||||
Index Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
Index Cond: (chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid)
|
||||||
Buffers: shared hit=74
|
Buffers: shared hit=74
|
||||||
Planning Time: 0.048 ms
|
Planning Time: 0.046 ms
|
||||||
Execution Time: 3.476 ms
|
Execution Time: 3.653 ms
|
||||||
|
|
||||||
-- keyset page WITHOUT messages_keyset_idx (rolled back)
|
-- keyset page WITHOUT messages_keyset_idx (rolled back)
|
||||||
Limit (actual time=1.986..1.991 rows=51 loops=1)
|
Limit (actual time=2.135..2.140 rows=51 loops=1)
|
||||||
Buffers: shared hit=667
|
Buffers: shared hit=783
|
||||||
-> Sort (actual time=1.985..1.986 rows=51 loops=1)
|
-> Sort (actual time=2.133..2.135 rows=51 loops=1)
|
||||||
Sort Key: created_at, id
|
Sort Key: created_at, id
|
||||||
Sort Method: top-N heapsort Memory: 31kB
|
Sort Method: top-N heapsort Memory: 31kB
|
||||||
Buffers: shared hit=667
|
Buffers: shared hit=783
|
||||||
-> Seq Scan on messages (actual time=0.398..1.897 rows=999 loops=1)
|
-> Seq Scan on messages (actual time=0.349..2.058 rows=999 loops=1)
|
||||||
Filter: ((chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 19:08:45.800971+00'::timestamp with time zone, '6f9dad83-2a94-400a-877b-7202790747a3'::uuid)))
|
Filter: ((chat_id = 'bc6206c8-0e5d-48f3-94ea-a5fe15e0a9e5'::uuid) AND (ROW(created_at, id) > ROW('2026-10-01 19:08:45.800971+00'::timestamp with time zone, '6f9dad83-2a94-400a-877b-7202790747a3'::uuid)))
|
||||||
Rows Removed by Filter: 49011
|
Rows Removed by Filter: 58233
|
||||||
Buffers: shared hit=667
|
Buffers: shared hit=783
|
||||||
Planning:
|
Planning:
|
||||||
Buffers: shared hit=4
|
Buffers: shared hit=4
|
||||||
Planning Time: 0.109 ms
|
Planning Time: 0.092 ms
|
||||||
Execution Time: 2.019 ms
|
Execution Time: 2.168 ms
|
||||||
PASS: first page reads the index in order, no Sort
|
PASS: first page reads the index in order, no Sort
|
||||||
PASS: keyset cursor is an Index Cond, not a filter over the history
|
PASS: keyset cursor is an Index Cond, not a filter over the history
|
||||||
PASS: keyset deep page touches fewer buffers than OFFSET (5 < 208)
|
PASS: keyset deep page touches fewer buffers than OFFSET (5 < 208)
|
||||||
PASS: index reduces buffers for the deep page (5 < 667)
|
PASS: index reduces buffers for the deep page (5 < 783)
|
||||||
|
|
||||||
PASS: db checks
|
PASS: db checks
|
||||||
|
|||||||
+6
-6
@@ -2,16 +2,16 @@
|
|||||||
"lab": 2,
|
"lab": 2,
|
||||||
"workload": "closed-loop POST messages; no automatic retries",
|
"workload": "closed-loop POST messages; no automatic retries",
|
||||||
"requested_duration_seconds": 15.0,
|
"requested_duration_seconds": 15.0,
|
||||||
"elapsed_seconds": 15.018,
|
"elapsed_seconds": 15.019,
|
||||||
"concurrency": 4,
|
"concurrency": 4,
|
||||||
"successful_requests": 4776,
|
"successful_requests": 4071,
|
||||||
"failed_requests": 0,
|
"failed_requests": 0,
|
||||||
"error_ratio": 0.0,
|
"error_ratio": 0.0,
|
||||||
"successful_rps": 318.026,
|
"successful_rps": 271.065,
|
||||||
"successful_latency_ms": {
|
"successful_latency_ms": {
|
||||||
"p50": 12.148,
|
"p50": 13.402,
|
||||||
"p95": 15.627,
|
"p95": 22.878,
|
||||||
"p99": 19.403
|
"p99": 31.89
|
||||||
},
|
},
|
||||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -2,16 +2,16 @@
|
|||||||
"lab": 2,
|
"lab": 2,
|
||||||
"workload": "closed-loop POST messages; no automatic retries",
|
"workload": "closed-loop POST messages; no automatic retries",
|
||||||
"requested_duration_seconds": 15.0,
|
"requested_duration_seconds": 15.0,
|
||||||
"elapsed_seconds": 15.018,
|
"elapsed_seconds": 15.019,
|
||||||
"concurrency": 4,
|
"concurrency": 4,
|
||||||
"successful_requests": 4776,
|
"successful_requests": 4071,
|
||||||
"failed_requests": 0,
|
"failed_requests": 0,
|
||||||
"error_ratio": 0.0,
|
"error_ratio": 0.0,
|
||||||
"successful_rps": 318.026,
|
"successful_rps": 271.065,
|
||||||
"successful_latency_ms": {
|
"successful_latency_ms": {
|
||||||
"p50": 12.148,
|
"p50": 13.402,
|
||||||
"p95": 15.627,
|
"p95": 22.878,
|
||||||
"p99": 19.403
|
"p99": 31.89
|
||||||
},
|
},
|
||||||
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
"note": "Latency percentiles cover successes only. Timeouts/errors are counted separately; closed-loop has coordinated omission and client overhead."
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-10
@@ -1,14 +1,14 @@
|
|||||||
## containers before restart hook
|
## containers before restart hook
|
||||||
api running Up 24 seconds 2026-10-03 10:27:58 +0300 MSK
|
api running Up 6 minutes 2026-10-03 10:50:58 +0300 MSK
|
||||||
api_short_ttl running Up 32 seconds 2026-10-03 10:27:58 +0300 MSK
|
api_short_ttl running Up 7 minutes 2026-10-03 10:50:58 +0300 MSK
|
||||||
db running Up About a minute (healthy) 2026-10-02 21:00:15 +0300 MSK
|
db running Up 6 minutes (healthy) 2026-10-02 21:00:15 +0300 MSK
|
||||||
migrate exited Exited (0) 33 seconds ago 2026-10-03 10:27:58 +0300 MSK
|
migrate exited Exited (0) 7 minutes ago 2026-10-03 10:50:58 +0300 MSK
|
||||||
valkey running Up About a minute (healthy) 2026-10-02 21:09:53 +0300 MSK
|
valkey running Up 6 minutes (healthy) 2026-10-02 21:09:53 +0300 MSK
|
||||||
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
Executing explicit persistence hook; hook output suppressed to avoid leaking secrets.
|
||||||
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
PASS: persistence preserved confirmed data and existing session. Hook scope needs operator evidence.
|
||||||
## containers after restart hook (Status shows new uptime)
|
## containers after restart hook (Status shows new uptime)
|
||||||
api running Up 2 seconds 2026-10-03 10:27:58 +0300 MSK
|
api running Up 1 second 2026-10-03 10:50:58 +0300 MSK
|
||||||
api_short_ttl running Up 37 seconds 2026-10-03 10:27:58 +0300 MSK
|
api_short_ttl running Up 7 minutes 2026-10-03 10:50:58 +0300 MSK
|
||||||
db running Up 3 seconds (health: starting) 2026-10-02 21:00:15 +0300 MSK
|
db running Up 2 seconds (health: starting) 2026-10-02 21:00:15 +0300 MSK
|
||||||
migrate exited Exited (0) 37 seconds ago 2026-10-03 10:27:58 +0300 MSK
|
migrate exited Exited (0) 7 minutes ago 2026-10-03 10:50:58 +0300 MSK
|
||||||
valkey running Up 3 seconds (health: starting) 2026-10-02 21:09:53 +0300 MSK
|
valkey running Up 2 seconds (health: starting) 2026-10-02 21:09:53 +0300 MSK
|
||||||
|
|||||||
Reference in New Issue
Block a user