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,19 @@
calls,total_ms,mean_ms,rows,shared_blks_hit,shared_blks_read,query
28907,2382.041,0.082,28907,902626,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 "
28907,362.359,0.013,28907,115853,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"
28907,222.540,0.008,0,86721,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"
7095,152.786,0.022,358486,111488,0,"SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2"
7095,95.988,0.014,7095,35475,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 = "
43286,64.877,0.001,0,0,0,RESET ALL
43286,42.540,0.001,43286,0,0,SELECT pg_advisory_unlock_all()
43286,5.756,0.000,0,0,0,CLOSE ALL
28957,4.641,0.000,0,0,0,COMMIT
43286,4.241,0.000,0,0,0,UNLISTEN *
28957,3.562,0.000,0,0,0,BEGIN
20,1.548,0.077,20,105,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"
20,1.367,0.068,20,239,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)"
10,0.713,0.071,20,228,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)"
20,0.283,0.014,20,40,0,"SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1"
20,0.154,0.008,20,40,0,"SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2"
10,0.122,0.012,10,26,0,"INSERT INTO chats (id, title, created_at) VALUES ($1, $2, $3)"
99,0.104,0.001,99,0,0,SELECT 1
1 calls total_ms mean_ms rows shared_blks_hit shared_blks_read query
2 28907 2382.041 0.082 28907 902626 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
3 28907 362.359 0.013 28907 115853 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
4 28907 222.540 0.008 0 86721 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
5 7095 152.786 0.022 358486 111488 0 SELECT id, chat_id, sender_id, text, created_at FROM messages WHERE chat_id = $1 ORDER BY created_at, id LIMIT $2
6 7095 95.988 0.014 7095 35475 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 =
7 43286 64.877 0.001 0 0 0 RESET ALL
8 43286 42.540 0.001 43286 0 0 SELECT pg_advisory_unlock_all()
9 43286 5.756 0.000 0 0 0 CLOSE ALL
10 28957 4.641 0.000 0 0 0 COMMIT
11 43286 4.241 0.000 0 0 0 UNLISTEN *
12 28957 3.562 0.000 0 0 0 BEGIN
13 20 1.548 0.077 20 105 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
14 20 1.367 0.068 20 239 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)
15 10 0.713 0.071 20 228 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)
16 20 0.283 0.014 20 40 0 SELECT id, username, display_name, password_hash, created_at FROM users WHERE username = $1
17 20 0.154 0.008 20 40 0 SELECT token_hash, user_id, created_at, expires_at FROM sessions WHERE token_hash = $1 AND expires_at > $2
18 10 0.122 0.012 10 26 0 INSERT INTO chats (id, title, created_at) VALUES ($1, $2, $3)
19 99 0.104 0.001 99 0 0 SELECT 1