level 4: redis cache etc
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
rows_in_chat: 10000
|
||||
query: keyset page after the 50th message, LIMIT 51
|
||||
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
Limit (cost=0.29..4.19 rows=51 width=58) (actual time=0.047..0.070 rows=51 loops=1)
|
||||
Buffers: shared hit=4
|
||||
-> Index Scan using messages_history_idx on messages (cost=0.29..762.42 rows=9950 width=58) (actual time=0.044..0.063 rows=51 loops=1)
|
||||
Index Cond: ((chat_id = '49b53d26-7fad-40e0-8811-59eae519e639'::uuid) AND (ROW(created_at, id) > ROW('2024-01-01 00:00:00.00005+00'::timestamp with time zone, '38a04f80-174d-4233-ac1b-f319ea7668f3'::uuid)))
|
||||
Buffers: shared hit=4
|
||||
Planning:
|
||||
Buffers: shared hit=106
|
||||
Planning Time: 0.886 ms
|
||||
Execution Time: 0.363 ms
|
||||
(9 rows)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
Grade 4 checks. No tokens or passwords.
|
||||
|
||||
python scripts/check_grade4.py
|
||||
PASS: one 201 and seven 409 for the same username
|
||||
PASS: unknown member rolls back chat and membership
|
||||
PASS: wrong password and unknown user share the same 401 challenge
|
||||
PASS: logout returns 204, then 401, and drops the cache key
|
||||
PASS: Redis outage falls back to PostgreSQL and still rejects anonymous requests
|
||||
PASS: PostgreSQL outage is 503 for a bearer and 401 without one
|
||||
PASS: SESSION_TTL_SECONDS=2 rejects the same token after 3 seconds
|
||||
PASS: grade 4 checks
|
||||
|
||||
After that script the API environment was SESSION_TTL_SECONDS=3600.
|
||||
|
||||
python scripts/explain_history.py
|
||||
PASS: history index used at 10000 messages
|
||||
Plan: Index Scan using messages_history_idx, LIMIT 51, Buffers shared hit=4, no Seq Scan.
|
||||
Saved as evidence/explain.txt. The seed chat was deleted afterwards.
|
||||
|
||||
Smoke on the rebuilt image:
|
||||
PASS: lab2 public API scenario
|
||||
|
||||
Persistence, hook scripts/restart.sh restarts api, postgres and redis.
|
||||
Ran inside docker:28-cli because Windows CreateProcess cannot execute the shell script.
|
||||
PASS: persistence preserved confirmed data and existing session.
|
||||
Container IDs unchanged:
|
||||
api 87a78974fbc8
|
||||
postgres cbe7139645a5
|
||||
redis e271b1f6ea0e
|
||||
Volume still present: mtusi2026lab2-fork_pgdata
|
||||
Redis has no volume; the session row in PostgreSQL is what survived.
|
||||
Reference in New Issue
Block a user