lab2: add missing evidence from benchmark
Skeleton contracts / contracts (pull_request) Canceled after 0s
Skeleton contracts / contracts (pull_request) Canceled after 0s
This commit is contained in:
+5
-5
@@ -1,5 +1,5 @@
|
||||
# Доказательства
|
||||
|
||||
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
|
||||
|
||||
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
|
||||
# Доказательства
|
||||
|
||||
Храните небольшие обезличенные результаты: команды и stdout проверок, JSON/CSV агрегатов нагрузки, EXPLAIN, dashboard JSON, текст разбора отказа. Укажите дату, commit, аппаратные лимиты и профиль нагрузки.
|
||||
|
||||
Не добавляйте .env, session tokens, cookies, приватные ключи, credentials, реальные сообщения, raw dumps и signed URLs. Для скриншотов скрывайте секреты. Большие логи/бинарные traces сохраняйте отдельно по правилам преподавателя; одного скриншота без методики недостаточно.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
=== Cache benchmark: 5000 GET, concurrency=100 ===
|
||||
|
||||
WITH CACHE:
|
||||
RPS: 7027
|
||||
p50: 12.6 ms
|
||||
p95: 23.4 ms
|
||||
p99: 62.1 ms
|
||||
Status: 5000/5000 [200]
|
||||
|
||||
WITHOUT CACHE (CACHE_ENABLED=false):
|
||||
RPS: 5735
|
||||
p50: 12.8 ms
|
||||
p95: 26.8 ms
|
||||
p99: 196.9 ms
|
||||
Status: 5000/5000 [200]
|
||||
|
||||
Difference:
|
||||
RPS: -18% без кэша
|
||||
p95: -13% без кэша
|
||||
p99: -68% без кэша (рост в 3 раза)
|
||||
|
||||
Conclusion:
|
||||
Кэш истории в Redis снижает p99 задержку в 3 раза
|
||||
при 100 конкурентных клиентах. RPS растёт на 18%.
|
||||
Основной эффект — в хвосте (tail latency), что критично
|
||||
для UX и SLA.
|
||||
@@ -1,7 +1,7 @@
|
||||
Limit (cost=0.29..77.21 rows=50 width=64) (actual time=0.284..0.443 rows=50 loops=1)
|
||||
Buffers: shared hit=1 read=3
|
||||
-> Index Scan using messages_chat_created_id_idx on messages
|
||||
Index Cond: ((chat_id = 'aa29af3d-b946-4358-b7e6-eb6aedaf1ee0'::uuid) AND (ROW(created_at, id) > ROW('1970-01-01 00:00:00+00'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))
|
||||
Buffers: shared hit=1 read=3
|
||||
Planning Time: 0.762 ms
|
||||
Limit (cost=0.29..77.21 rows=50 width=64) (actual time=0.284..0.443 rows=50 loops=1)
|
||||
Buffers: shared hit=1 read=3
|
||||
-> Index Scan using messages_chat_created_id_idx on messages
|
||||
Index Cond: ((chat_id = 'aa29af3d-b946-4358-b7e6-eb6aedaf1ee0'::uuid) AND (ROW(created_at, id) > ROW('1970-01-01 00:00:00+00'::timestamp with time zone, '00000000-0000-0000-0000-000000000000'::uuid)))
|
||||
Buffers: shared hit=1 read=3
|
||||
Planning Time: 0.762 ms
|
||||
Execution Time: 0.496 ms
|
||||
@@ -1,7 +1,7 @@
|
||||
=== /health/ready with postgres stopped ===
|
||||
HTTP/1.1 503 Service Unavailable
|
||||
{"error":{"code":"unavailable","message":"Сервис недоступен","request_id":"4f7910a29991bfebaa3aa40f"}}
|
||||
|
||||
=== /health/ready after postgres start ===
|
||||
HTTP/1.1 200 OK
|
||||
=== /health/ready with postgres stopped ===
|
||||
HTTP/1.1 503 Service Unavailable
|
||||
{"error":{"code":"unavailable","message":"Сервис недоступен","request_id":"4f7910a29991bfebaa3aa40f"}}
|
||||
|
||||
=== /health/ready after postgres start ===
|
||||
HTTP/1.1 200 OK
|
||||
{"status":"ok"}
|
||||
@@ -1,2 +1,2 @@
|
||||
1) "session:<redacted-1>"
|
||||
1) "session:<redacted-1>"
|
||||
2) "session:<redacted-2>"
|
||||
@@ -1,3 +1,3 @@
|
||||
aof_enabled:1
|
||||
aof_last_bgrewrite_status:ok
|
||||
aof_enabled:1
|
||||
aof_last_bgrewrite_status:ok
|
||||
aof_last_write_status:ok
|
||||
+27
-27
@@ -1,28 +1,28 @@
|
||||
=== STALE READ EXPERIMENT (трек 5.1) ===
|
||||
|
||||
BUG MODE (invalidation OFF):
|
||||
|
||||
1. Redis cache populated from GET /messages:
|
||||
Key: messages:aa29af3d-b946-4358-b7e6-eb6aedaf1ee0:
|
||||
Value: 50 items (seed 1..50)
|
||||
|
||||
2. POST STALE_1 → 201 Created.
|
||||
DB has STALE_1: 1
|
||||
|
||||
3. Cache still contains OLD page (without STALE_1):
|
||||
items in cache: 50
|
||||
STALE_1 in cache: 0
|
||||
|
||||
CONCLUSION:
|
||||
- DB has STALE_1 = 1
|
||||
- Cache has STALE_1 = 0
|
||||
- Client reads from cache → does NOT see own message
|
||||
- STALE READ CONFIRMED
|
||||
|
||||
FIXED MODE (invalidation ON):
|
||||
|
||||
MessageService.Send вызывает MessageCache.Invalidate(chatID) при флаге invalidate=true.
|
||||
Инвалидация удаляет все ключи messages:{chatID}:* из Redis.
|
||||
Следующий GET /messages идёт в БД и возвращает свежие данные.
|
||||
|
||||
=== STALE READ EXPERIMENT (трек 5.1) ===
|
||||
|
||||
BUG MODE (invalidation OFF):
|
||||
|
||||
1. Redis cache populated from GET /messages:
|
||||
Key: messages:aa29af3d-b946-4358-b7e6-eb6aedaf1ee0:
|
||||
Value: 50 items (seed 1..50)
|
||||
|
||||
2. POST STALE_1 → 201 Created.
|
||||
DB has STALE_1: 1
|
||||
|
||||
3. Cache still contains OLD page (without STALE_1):
|
||||
items in cache: 50
|
||||
STALE_1 in cache: 0
|
||||
|
||||
CONCLUSION:
|
||||
- DB has STALE_1 = 1
|
||||
- Cache has STALE_1 = 0
|
||||
- Client reads from cache → does NOT see own message
|
||||
- STALE READ CONFIRMED
|
||||
|
||||
FIXED MODE (invalidation ON):
|
||||
|
||||
MessageService.Send вызывает MessageCache.Invalidate(chatID) при флаге invalidate=true.
|
||||
Инвалидация удаляет все ключи messages:{chatID}:* из Redis.
|
||||
Следующий GET /messages идёт в БД и возвращает свежие данные.
|
||||
|
||||
Защита реализована в коде: internal/repository/redis/message_cache.go, метод Invalidate.
|
||||
Reference in New Issue
Block a user