forked from mtusi2026/mtusi2026lab3
1x4, 2x2 and 4x1 at 4 CPU and 2 GiB of API, workers equal to CPUs, 32 pool connections and 128 balancer slots in every layout, three repeats from 600 to 6 830 rps. All three keep up with the offered load up to 4 560 rps; the peaks are 5 375 rps for 1x4 (5 332..5 384), 4 964 for 2x2 (4 894..5 104) and 4 724 for 4x1 (4 686..4 794). At the peak the API uses 95 % of its four CPUs in every layout, PostgreSQL 82..89 % of its two, the balancer 40 % of one, and about half of the 32 database connections wait for the lock on a chat row. Smaller replicas cost more: at 3 040 rps the API burns 215 % CPU as 1x4, 243 % as 2x2 and about 280 % as 4x1, and p95 at 4 560 rps grows from 9 to 69 and 150 ms. The first attempt was aborted when a neighbour's image build froze the Docker API; its summary is kept under aborted/. Twelve steps of the rerun were rejected as disturbed and repeated. A config's SLO capacity now needs a majority of saturated repeats, since a median is robust to one disturbed repeat and "any repeat" is not. Series B starts at 450 rps per CPU. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
2.8 KiB
2.8 KiB
| 1 | calls | total_ms | mean_ms | rows | shared_blks_hit | shared_blks_read | query |
|---|---|---|---|---|---|---|---|
| 2 | 146157 | 39218.089 | 0.268 | 146157 | 986375 | 0 | SELECT c.id, c.title, c.created_at, c.last_message_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chats c WHERE c.id = $1 FOR UPDATE |
| 3 | 83244 | 8899.647 | 0.107 | 83244 | 3066679 | 0 | WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys |
| 4 | 62913 | 6547.863 | 0.104 | 62913 | 2296135 | 0 | WITH message AS ( INSERT INTO messages (id, chat_id, sender_id, text, created_at) VALUES ($1, $2, $3, $4, $5) RETURNING id, chat_id, sender_id, created_at ), receipt AS ( INSERT INTO idempotency_keys |
| 5 | 146157 | 1620.984 | 0.011 | 0 | 584628 | 0 | SELECT k.fingerprint, m.id, m.chat_id, m.sender_id, m.text, m.created_at FROM idempotency_keys k JOIN messages m ON m.id = k.message_id WHERE k.chat_id = $1 AND k.user_id = $2 AND k.key = $3 AND k.cre |
| 6 | 36240 | 1566.374 | 0.043 | 1845451 | 1932299 | 0 | SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2 |
| 7 | 36240 | 762.921 | 0.021 | 36240 | 289982 | 0 | SELECT c.id, c.title, c.created_at, ARRAY(SELECT user_id FROM chat_members WHERE chat_id = c.id ORDER BY position) AS member_ids FROM chat_members m JOIN chats c ON c.id = m.chat_id WHERE m.chat_id = |
| 8 | 218761 | 571.493 | 0.003 | 0 | 0 | 0 | RESET ALL |
| 9 | 218761 | 254.458 | 0.001 | 218761 | 0 | 0 | SELECT pg_advisory_unlock_all() |
| 10 | 218761 | 35.530 | 0.000 | 0 | 0 | 0 | CLOSE ALL |
| 11 | 146207 | 33.174 | 0.000 | 0 | 0 | 0 | COMMIT |
| 12 | 218761 | 25.041 | 0.000 | 0 | 0 | 0 | UNLISTEN * |
| 13 | 146207 | 24.011 | 0.000 | 0 | 0 | 0 | BEGIN |
| 14 | 22 | 10.378 | 0.472 | 44 | 792 | 0 | WITH RECURSIVE typeinfo_tree( oid, ns, name, kind, basetype, elemtype, elemdelim, range_subtype, attrtypoids, attrnames, depth) AS ( SELECT ti.oid, ti.ns, ti.name, ti.kind, ti.basetype, ti.elemtype, t |
| 15 | 20 | 1.156 | 0.058 | 20 | 267 | 0 | WITH expired AS (DELETE FROM sessions WHERE user_id = $2 AND expires_at <= $3) INSERT INTO sessions (token_hash, user_id, created_at, expires_at) VALUES ($1, $2, $3, $4) |
| 16 | 20 | 1.075 | 0.054 | 20 | 166 | 0 | INSERT INTO users (id, username, display_name, password_hash, created_at) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (username) DO NOTHING RETURNING $6 |
| 17 | 10 | 0.754 | 0.075 | 20 | 297 | 0 | INSERT INTO chat_members (chat_id, user_id, position, chat_created_at) SELECT $1, member.user_id, member.position, $3 FROM unnest($2::uuid[]) WITH ORDINALITY AS member (user_id, position) |
| 18 | 27 | 0.251 | 0.009 | 27 | 81 | 0 | SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2 |
| 19 | 20 | 0.185 | 0.009 | 20 | 60 | 0 | SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1 |
| 20 | 10 | 0.165 | 0.017 | 10 | 33 | 0 | INSERT INTO chats (id, title, created_at) VALUES ($1, $2, $3) |
| 21 | 22 | 0.072 | 0.003 | 22 | 0 | 0 | SELECT current_setting($1) AS cur, set_config($2, $3, $4) AS new |