Record the growth series of track 1

One to eight replicas of 1 CPU, 512 MiB and one worker each, three
repeats per rate; the 4x1 point comes from series A. Peak successful
RPS: 1 720 for one replica, 2 936 for two, 4 724 for four and only
4 260 for eight, lower than four. Up to two replicas the API is the
limit (101 % and 201 % of its CPU). At eight replicas the API uses 473
of its 800 % and the balancer 40 % of a core, while PostgreSQL is at
178 of 200 %, 47.5 of the 64 pool connections wait for a chat row lock
and the balancer queue holds 744 requests. The locking SELECT ... FOR
UPDATE of the chat takes 14.2 ms on average, 97 % of all statement
time of the step, and about 7 connections sit idle in transaction:
the lock holders wait for the application between round trips.

A universal scalability law fit over 1, 2, 4 and 8 CPUs gives
sigma 0.014 and kappa 0.038, a peak near five replicas and a decline
after it. No step of this series was rejected as disturbed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1d3RLHNBBMA6UqBLLJv27
This commit is contained in:
Artyom
2026-10-29 01:05:39 +03:00
co-authored by Claude Opus 5.5
parent be19abf364
commit 3bdc8fad23
298 changed files with 40364 additions and 2 deletions
@@ -0,0 +1,21 @@
calls,total_ms,mean_ms,rows,shared_blks_hit,shared_blks_read,query
134390,1951684.708,14.523,134390,2986403,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"
84167,12342.310,0.147,84167,3226700,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 "
50223,7437.553,0.148,50223,1951368,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 "
33817,1985.218,0.059,1722158,1823640,0,"SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2"
134390,1871.461,0.014,0,440462,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"
33817,972.942,0.029,33817,372280,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 = "
202485,826.245,0.004,0,0,0,RESET ALL
202485,301.555,0.001,202485,0,0,SELECT pg_advisory_unlock_all()
202485,37.701,0.000,0,0,0,CLOSE ALL
134440,36.009,0.000,0,0,0,COMMIT
202485,26.368,0.000,0,0,0,UNLISTEN *
134440,24.249,0.000,0,0,0,BEGIN
33,6.149,0.186,66,1188,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"
20,1.574,0.079,20,222,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)"
20,1.406,0.070,20,121,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"
9,1.083,0.120,18,275,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)"
390,0.466,0.001,390,0,0,SELECT 1
34,0.309,0.009,34,102,0,"SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2"
20,0.246,0.012,20,40,0,"SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1"
33,0.176,0.005,33,0,0,"SELECT current_setting($1) AS cur, set_config($2, $3, $4) AS new"
1 calls total_ms mean_ms rows shared_blks_hit shared_blks_read query
2 134390 1951684.708 14.523 134390 2986403 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 84167 12342.310 0.147 84167 3226700 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 50223 7437.553 0.148 50223 1951368 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 33817 1985.218 0.059 1722158 1823640 0 SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2
6 134390 1871.461 0.014 0 440462 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
7 33817 972.942 0.029 33817 372280 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 202485 826.245 0.004 0 0 0 RESET ALL
9 202485 301.555 0.001 202485 0 0 SELECT pg_advisory_unlock_all()
10 202485 37.701 0.000 0 0 0 CLOSE ALL
11 134440 36.009 0.000 0 0 0 COMMIT
12 202485 26.368 0.000 0 0 0 UNLISTEN *
13 134440 24.249 0.000 0 0 0 BEGIN
14 33 6.149 0.186 66 1188 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.574 0.079 20 222 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.406 0.070 20 121 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 9 1.083 0.120 18 275 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 390 0.466 0.001 390 0 0 SELECT 1
19 34 0.309 0.009 34 102 0 SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2
20 20 0.246 0.012 20 40 0 SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1
21 33 0.176 0.005 33 0 0 SELECT current_setting($1) AS cur, set_config($2, $3, $4) AS new