docs: record baseline benchmark results and conclusions

This commit is contained in:
2026-10-02 04:09:53 +03:00
parent c7d36bcaa5
commit 4fc1ee7c58
10 changed files with 991 additions and 22 deletions
+99
View File
@@ -0,0 +1,99 @@
# План запроса истории: размер 100k
Код: src_sha256 8a7e256c540af433, commit c7d36bcaa592; вариант индекса: keyset
Страница истории читаемого чата (limit 50); позиция — сколько
сообщений истории до страницы:
- first: после 0
- middle: после 50000
- last: после 99950
## Планы приложения
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
с которыми его выполнило приложение (prepared statement asyncpg).
### first
duration: 0.047 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
LIMIT $2::INTEGER
Query Parameters: $1 = '94606631-1f58-492d-89ed-8b7394e004cd', $2 = '51'
Limit (cost=0.42..6.27 rows=51 width=204) (actual time=0.013..0.024 rows=51.00 loops=1)
Buffers: shared hit=21
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..11471.23 rows=100000 width=204) (actual time=0.012..0.021 rows=51.00 loops=1)
Index Cond: (chat_id = '94606631-1f58-492d-89ed-8b7394e004cd'::uuid)
Index Searches: 1
Buffers: shared hit=21
### middle
duration: 0.043 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '94606631-1f58-492d-89ed-8b7394e004cd', $2 = '2026-10-02 00:50:46.584919+00', $3 = '7fd4336a-20db-42e3-8a0b-4fd51165b113', $4 = '51'
Limit (cost=0.42..9.03 rows=51 width=204) (actual time=0.008..0.023 rows=51.00 loops=1)
Buffers: shared hit=54
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..8451.48 rows=50025 width=204) (actual time=0.008..0.021 rows=51.00 loops=1)
Index Cond: ((chat_id = '94606631-1f58-492d-89ed-8b7394e004cd'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:50:46.584919+00'::timestamp with time zone, '7fd4336a-20db-42e3-8a0b-4fd51165b113'::uuid)))
Index Searches: 1
Buffers: shared hit=54
### last
duration: 0.042 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '94606631-1f58-492d-89ed-8b7394e004cd', $2 = '2026-10-02 00:51:32.155581+00', $3 = 'b15ddf86-aa17-4fda-b60e-e4cb4a467a12', $4 = '51'
Limit (cost=0.42..97.37 rows=51 width=204) (actual time=0.006..0.023 rows=50.00 loops=1)
Buffers: shared hit=54
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..99.27 rows=52 width=204) (actual time=0.006..0.021 rows=50.00 loops=1)
Index Cond: ((chat_id = '94606631-1f58-492d-89ed-8b7394e004cd'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:51:32.155581+00'::timestamp with time zone, 'b15ddf86-aa17-4fda-b60e-e4cb4a467a12'::uuid)))
Index Searches: 1
Buffers: shared hit=54
## Страница middle в psql: с индексом и без
Тот же текст запроса и те же параметры, что у плана middle.
psql планирует их заново (custom plan). DROP INDEX — внутри
транзакции, затем ROLLBACK: индекс остаётся в базе.
### С индексом ix_messages_chat_id_created_at_id
Limit (cost=0.42..9.03 rows=51 width=204) (actual time=0.042..0.086 rows=51.00 loops=1)
Buffers: shared hit=54
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..8451.48 rows=50025 width=204) (actual time=0.041..0.081 rows=51.00 loops=1)
Index Cond: ((chat_id = '94606631-1f58-492d-89ed-8b7394e004cd'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:50:46.584919+00'::timestamp with time zone, '7fd4336a-20db-42e3-8a0b-4fd51165b113'::uuid)))
Index Searches: 1
Buffers: shared hit=54
Planning:
Buffers: shared hit=111
Planning Time: 0.293 ms
Execution Time: 0.118 ms
### Без индекса ix_messages_chat_id_created_at_id
Limit (cost=5965.14..5970.95 rows=51 width=204) (actual time=6.599..7.445 rows=51.00 loops=1)
Buffers: shared hit=2969
-> Gather Merge (cost=5965.14..11666.40 rows=50024 width=204) (actual time=6.599..7.434 rows=51.00 loops=1)
Workers Planned: 1
Workers Launched: 1
Buffers: shared hit=2969
-> Sort (cost=4965.13..5038.69 rows=29426 width=204) (actual time=5.629..5.631 rows=39.00 loops=2)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 46kB
Buffers: shared hit=2969
Worker 0: Sort Method: top-N heapsort Memory: 41kB
-> Parallel Seq Scan on messages (cost=0.00..3983.41 rows=29426 width=204) (actual time=1.295..4.113 rows=25000.00 loops=2)
Filter: ((chat_id = '94606631-1f58-492d-89ed-8b7394e004cd'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:50:46.584919+00'::timestamp with time zone, '7fd4336a-20db-42e3-8a0b-4fd51165b113'::uuid)))
Rows Removed by Filter: 25000
Buffers: shared hit=2954
Planning:
Buffers: shared hit=17
Planning Time: 0.083 ms
Execution Time: 7.468 ms
+94
View File
@@ -0,0 +1,94 @@
# План запроса истории: размер 10k
Код: src_sha256 8a7e256c540af433, commit c7d36bcaa592; вариант индекса: keyset
Страница истории читаемого чата (limit 50); позиция — сколько
сообщений истории до страницы:
- first: после 0
- middle: после 5000
- last: после 9950
## Планы приложения
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
с которыми его выполнило приложение (prepared statement asyncpg).
### first
duration: 0.040 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
LIMIT $2::INTEGER
Query Parameters: $1 = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4', $2 = '51'
Limit (cost=0.29..6.60 rows=51 width=204) (actual time=0.012..0.020 rows=51.00 loops=1)
Buffers: shared hit=13
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..1238.41 rows=10000 width=204) (actual time=0.011..0.018 rows=51.00 loops=1)
Index Cond: (chat_id = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4'::uuid)
Index Searches: 1
Buffers: shared hit=13
### middle
duration: 0.046 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4', $2 = '2026-10-02 00:47:43.137147+00', $3 = '052a5d48-4cd9-4aa5-91d7-4ceed4002bcf', $4 = '51'
Limit (cost=0.29..9.69 rows=51 width=204) (actual time=0.006..0.025 rows=51.00 loops=1)
Buffers: shared hit=54
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..922.60 rows=5000 width=204) (actual time=0.006..0.023 rows=51.00 loops=1)
Index Cond: ((chat_id = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:47:43.137147+00'::timestamp with time zone, '052a5d48-4cd9-4aa5-91d7-4ceed4002bcf'::uuid)))
Index Searches: 1
Buffers: shared hit=54
### last
duration: 0.041 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4', $2 = '2026-10-02 00:47:50.05267+00', $3 = '3ae3ceb9-d3cb-4373-bbda-5cbb4b805f4b', $4 = '51'
Limit (cost=0.29..92.09 rows=51 width=204) (actual time=0.007..0.022 rows=50.00 loops=1)
Buffers: shared hit=52
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..93.89 rows=52 width=204) (actual time=0.006..0.020 rows=50.00 loops=1)
Index Cond: ((chat_id = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:47:50.05267+00'::timestamp with time zone, '3ae3ceb9-d3cb-4373-bbda-5cbb4b805f4b'::uuid)))
Index Searches: 1
Buffers: shared hit=52
## Страница middle в psql: с индексом и без
Тот же текст запроса и те же параметры, что у плана middle.
psql планирует их заново (custom plan). DROP INDEX — внутри
транзакции, затем ROLLBACK: индекс остаётся в базе.
### С индексом ix_messages_chat_id_created_at_id
Limit (cost=0.29..9.69 rows=51 width=204) (actual time=0.019..0.055 rows=51.00 loops=1)
Buffers: shared hit=54
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.29..922.60 rows=5000 width=204) (actual time=0.018..0.050 rows=51.00 loops=1)
Index Cond: ((chat_id = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:47:43.137147+00'::timestamp with time zone, '052a5d48-4cd9-4aa5-91d7-4ceed4002bcf'::uuid)))
Index Searches: 1
Buffers: shared hit=54
Planning:
Buffers: shared hit=111
Planning Time: 0.255 ms
Execution Time: 0.083 ms
### Без индекса ix_messages_chat_id_created_at_id
Limit (cost=672.81..672.94 rows=51 width=204) (actual time=1.256..1.261 rows=51.00 loops=1)
Buffers: shared hit=337
-> Sort (cost=672.81..685.31 rows=5000 width=204) (actual time=1.255..1.258 rows=51.00 loops=1)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 46kB
Buffers: shared hit=337
-> Seq Scan on messages (cost=0.00..506.00 rows=5000 width=204) (actual time=0.389..0.892 rows=5000.00 loops=1)
Filter: ((chat_id = '4dea5917-2a87-4eed-bad1-cd3f129dd4f4'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:47:43.137147+00'::timestamp with time zone, '052a5d48-4cd9-4aa5-91d7-4ceed4002bcf'::uuid)))
Rows Removed by Filter: 5000
Buffers: shared hit=331
Planning:
Buffers: shared hit=17
Planning Time: 0.090 ms
Execution Time: 1.274 ms
+100
View File
@@ -0,0 +1,100 @@
# План запроса истории: размер 500k
Код: src_sha256 8a7e256c540af433, commit c7d36bcaa592; вариант индекса: keyset
Страница истории читаемого чата (limit 50); позиция — сколько
сообщений истории до страницы:
- first: после 0
- middle: после 250000
- last: после 499950
## Планы приложения
auto_explain (ANALYZE, BUFFERS, TIMING): запрос, параметры и план,
с которыми его выполнило приложение (prepared statement asyncpg).
### first
duration: 0.073 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID ORDER BY messages.created_at, messages.id
LIMIT $2::INTEGER
Query Parameters: $1 = '8afbc24c-dc06-43de-b26d-f4ee83fa3394', $2 = '51'
Limit (cost=0.42..6.30 rows=51 width=204) (actual time=0.021..0.052 rows=51.00 loops=1)
Buffers: shared hit=9 read=12
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..57668.05 rows=500000 width=204) (actual time=0.020..0.049 rows=51.00 loops=1)
Index Cond: (chat_id = '8afbc24c-dc06-43de-b26d-f4ee83fa3394'::uuid)
Index Searches: 1
Buffers: shared hit=9 read=12
### middle
duration: 0.046 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '8afbc24c-dc06-43de-b26d-f4ee83fa3394', $2 = '2026-10-02 00:57:24.488453+00', $3 = 'e3e93472-e7ee-4ee7-b411-cd40e33181b0', $4 = '51'
Limit (cost=0.42..9.13 rows=51 width=204) (actual time=0.009..0.027 rows=51.00 loops=1)
Buffers: shared hit=44
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..42433.74 rows=248547 width=204) (actual time=0.009..0.024 rows=51.00 loops=1)
Index Cond: ((chat_id = '8afbc24c-dc06-43de-b26d-f4ee83fa3394'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:57:24.488453+00'::timestamp with time zone, 'e3e93472-e7ee-4ee7-b411-cd40e33181b0'::uuid)))
Index Searches: 1
Buffers: shared hit=44
### last
duration: 0.041 ms plan:
Query Text: SELECT messages.id, messages.chat_id, messages.sender_id, messages.text, messages.created_at
FROM messages
WHERE messages.chat_id = $1::UUID AND (messages.created_at, messages.id) > ($2::TIMESTAMP WITH TIME ZONE, $3::UUID) ORDER BY messages.created_at, messages.id
LIMIT $4::INTEGER
Query Parameters: $1 = '8afbc24c-dc06-43de-b26d-f4ee83fa3394', $2 = '2026-10-02 01:01:05.284566+00', $3 = 'ac2b0ed6-066a-4abd-8fb3-13b491266931', $4 = '51'
Limit (cost=0.42..95.73 rows=50 width=204) (actual time=0.007..0.023 rows=50.00 loops=1)
Buffers: shared hit=53
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..95.73 rows=50 width=204) (actual time=0.007..0.020 rows=50.00 loops=1)
Index Cond: ((chat_id = '8afbc24c-dc06-43de-b26d-f4ee83fa3394'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 01:01:05.284566+00'::timestamp with time zone, 'ac2b0ed6-066a-4abd-8fb3-13b491266931'::uuid)))
Index Searches: 1
Buffers: shared hit=53
## Страница middle в psql: с индексом и без
Тот же текст запроса и те же параметры, что у плана middle.
psql планирует их заново (custom plan). DROP INDEX — внутри
транзакции, затем ROLLBACK: индекс остаётся в базе.
### С индексом ix_messages_chat_id_created_at_id
Limit (cost=0.42..9.13 rows=51 width=204) (actual time=0.047..0.120 rows=51.00 loops=1)
Buffers: shared hit=44
-> Index Scan using ix_messages_chat_id_created_at_id on messages (cost=0.42..42433.74 rows=248547 width=204) (actual time=0.046..0.114 rows=51.00 loops=1)
Index Cond: ((chat_id = '8afbc24c-dc06-43de-b26d-f4ee83fa3394'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:57:24.488453+00'::timestamp with time zone, 'e3e93472-e7ee-4ee7-b411-cd40e33181b0'::uuid)))
Index Searches: 1
Buffers: shared hit=44
Planning:
Buffers: shared hit=98 read=13
Planning Time: 0.407 ms
Execution Time: 0.169 ms
### Без индекса ix_messages_chat_id_created_at_id
Limit (cost=23031.87..23037.81 rows=51 width=204) (actual time=21.081..22.512 rows=51.00 loops=1)
Buffers: shared hit=14129 read=832
-> Gather Merge (cost=23031.87..51979.15 rows=248546 width=204) (actual time=21.081..22.507 rows=51.00 loops=1)
Workers Planned: 2
Workers Launched: 2
Buffers: shared hit=14129 read=832
-> Sort (cost=22031.85..22290.75 rows=103561 width=204) (actual time=19.551..19.553 rows=36.00 loops=3)
Sort Key: created_at, id
Sort Method: top-N heapsort Memory: 44kB
Buffers: shared hit=14129 read=832
Worker 0: Sort Method: top-N heapsort Memory: 42kB
Worker 1: Sort Method: top-N heapsort Memory: 47kB
-> Parallel Seq Scan on messages (cost=0.00..18576.83 rows=103561 width=204) (actual time=7.596..15.077 rows=83333.33 loops=3)
Filter: ((chat_id = '8afbc24c-dc06-43de-b26d-f4ee83fa3394'::uuid) AND (ROW(created_at, id) > ROW('2026-10-02 00:57:24.488453+00'::timestamp with time zone, 'e3e93472-e7ee-4ee7-b411-cd40e33181b0'::uuid)))
Rows Removed by Filter: 83333
Buffers: shared hit=14099 read=832
Planning:
Buffers: shared hit=17
Planning Time: 0.084 ms
Execution Time: 22.545 ms
+21
View File
@@ -0,0 +1,21 @@
size,messages_total,rps,p50_ms,p99_ms,max_ms,rss_mib,app_cpu_cores,db_cpu_cores
10000,2000,1022.55,13.0872,41.229,211.0381,85.0,1.002,0.284
10000,4000,1099.37,13.0722,33.4588,94.3755,85.9,1.0,0.276
10000,6000,1121.89,13.0832,32.399,83.3035,86.5,1.004,0.297
10000,8000,1061.13,13.1249,44.3073,96.3347,87.5,1.003,0.28
10000,10000,1047.14,13.6088,38.2766,93.3525,88.5,0.995,0.262
100000,20000,1153.8,13.0141,27.0076,217.0377,90.0,1.0,0.278
100000,40000,1146.22,13.0541,30.7415,97.2253,94.0,1.0,0.28
100000,60000,1194.23,12.7666,23.7516,92.5925,96.5,1.0,0.286
100000,80000,1135.17,12.9504,31.684,92.8576,97.0,1.0,0.289
100000,100000,1156.08,12.8953,28.4576,97.4844,98.9,1.001,0.288
500000,50000,1158.22,12.9921,25.6103,217.2491,92.0,1.0,0.281
500000,100000,1170.56,12.9103,25.2983,102.8773,96.6,1.0,0.286
500000,150000,1160.23,13.0338,25.7906,93.7542,100.3,0.999,0.282
500000,200000,1170.92,12.9414,26.2184,82.7793,100.3,1.0,0.286
500000,250000,1157.06,12.9521,28.1228,93.39,101.4,0.998,0.287
500000,300000,1119.73,13.3878,30.1092,90.6409,103.0,0.989,0.277
500000,350000,1177.67,12.8844,25.4103,89.9147,103.0,1.0,0.294
500000,400000,1169.2,12.9268,25.8692,102.5712,104.0,1.0,0.29
500000,450000,1162.37,12.8882,31.6154,101.9874,104.0,0.999,0.292
500000,500000,1185.82,12.8579,24.7555,93.8819,105.3,1.0,0.292
1 size messages_total rps p50_ms p99_ms max_ms rss_mib app_cpu_cores db_cpu_cores
2 10000 2000 1022.55 13.0872 41.229 211.0381 85.0 1.002 0.284
3 10000 4000 1099.37 13.0722 33.4588 94.3755 85.9 1.0 0.276
4 10000 6000 1121.89 13.0832 32.399 83.3035 86.5 1.004 0.297
5 10000 8000 1061.13 13.1249 44.3073 96.3347 87.5 1.003 0.28
6 10000 10000 1047.14 13.6088 38.2766 93.3525 88.5 0.995 0.262
7 100000 20000 1153.8 13.0141 27.0076 217.0377 90.0 1.0 0.278
8 100000 40000 1146.22 13.0541 30.7415 97.2253 94.0 1.0 0.28
9 100000 60000 1194.23 12.7666 23.7516 92.5925 96.5 1.0 0.286
10 100000 80000 1135.17 12.9504 31.684 92.8576 97.0 1.0 0.289
11 100000 100000 1156.08 12.8953 28.4576 97.4844 98.9 1.001 0.288
12 500000 50000 1158.22 12.9921 25.6103 217.2491 92.0 1.0 0.281
13 500000 100000 1170.56 12.9103 25.2983 102.8773 96.6 1.0 0.286
14 500000 150000 1160.23 13.0338 25.7906 93.7542 100.3 0.999 0.282
15 500000 200000 1170.92 12.9414 26.2184 82.7793 100.3 1.0 0.286
16 500000 250000 1157.06 12.9521 28.1228 93.39 101.4 0.998 0.287
17 500000 300000 1119.73 13.3878 30.1092 90.6409 103.0 0.989 0.277
18 500000 350000 1177.67 12.8844 25.4103 89.9147 103.0 1.0 0.294
19 500000 400000 1169.2 12.9268 25.8692 102.5712 104.0 1.0 0.29
20 500000 450000 1162.37 12.8882 31.6154 101.9874 104.0 0.999 0.292
21 500000 500000 1185.82 12.8579 24.7555 93.8819 105.3 1.0 0.292
+4
View File
@@ -0,0 +1,4 @@
size,rss_empty_mib,rss_filled_mib,rss_peak_mib,oom_killed,messages_rows,table_bytes,indexes_bytes,db_bytes_per_message
10000,80.4,88.5,144.1,False,10000,2752512,1015808,377
100000,80.4,98.9,144.1,False,100000,24240128,10297344,345
500000,80.4,105.3,144.1,False,500000,122380288,49119232,343
1 size rss_empty_mib rss_filled_mib rss_peak_mib oom_killed messages_rows table_bytes indexes_bytes db_bytes_per_message
2 10000 80.4 88.5 144.1 False 10000 2752512 1015808 377
3 100000 80.4 98.9 144.1 False 100000 24240128 10297344 345
4 500000 80.4 105.3 144.1 False 500000 122380288 49119232 343
+349
View File
@@ -0,0 +1,349 @@
{
"label": "baseline",
"started_utc": "2026-10-02T00:47:30Z",
"profile": {
"name": "full",
"sizes": [
10000,
100000,
500000
],
"clients": [
1,
8,
32
],
"repeats": 3,
"read_warmup_s": 2.0,
"read_duration_s": 6.0,
"write_warmup_requests": 300,
"write_requests": 3000,
"fill_clients": 16,
"fill_batch_max": 50000,
"fill_batches_min": 5,
"cursor_pool": 200,
"gen_procs": 4,
"seed": 20261002,
"app_cpus": "1",
"app_memory": "1g",
"db_cpus": "2",
"db_memory": "2g",
"cache_cpus": "1",
"cache_memory": "256m",
"session_ttl": 21600,
"gen_cpu_flag": 0.8,
"classes": [],
"explain_cursor_version": 2
},
"host": {
"platform": "macOS-26.6.2-arm64-arm-64bit-Mach-O",
"machine": "arm64",
"cpu_model": "Apple M4",
"cpu_count": 10,
"ram_gb": 16.0,
"swap_used_mib": 0.0,
"power": "AC Power",
"loadavg_1m": 1.91
},
"docker": {
"ServerVersion": "28.0.4",
"OperatingSystem": "Docker Desktop",
"KernelVersion": "6.10.14-linuxkit",
"Architecture": "aarch64",
"NCPU": 10,
"MemTotal": 8218034176,
"CgroupVersion": "2",
"LoggingDriver": "json-file",
"other_running_containers": 0
},
"image": {
"tag": "mtusi-messenger-vladimirceva:bench-baseline",
"id": "sha256:e670ace82a784e82a5fe617e6c60e3a651cea6c446be8c42bc586d2f359881d0",
"created": "2026-10-02T00:39:00.104485709Z",
"versions": {
"python": "3.13.15",
"fastapi": "0.142.1",
"starlette": "1.7.0",
"uvicorn": "0.54.0",
"pydantic": "2.13.5",
"sqlalchemy": "2.1.1",
"asyncpg": "0.31.0",
"alembic": "1.20.0",
"redis": "8.1.0",
"argon2-cffi": "25.1.0"
},
"src_sha256": "8a7e256c540af433de47704437294adafd98dcfecf2f3200354454ee717cd2a3"
},
"image_reused": false,
"code": {
"src_sha256": "8a7e256c540af433de47704437294adafd98dcfecf2f3200354454ee717cd2a3",
"git_commit": "c7d36bcaa592d8fd8b42d9d4a65a2d908ec1021d",
"git_dirty": false
},
"generator_image": "python:3.13.15-slim-trixie@sha256:7c61056e61ac89e852de05f3dc6fa51a6dd2181797bceed46aa725dd7cb2cd3b",
"variant": "keyset",
"variant_sql": [],
"host_warnings": [],
"stand": {
"postgres": {
"image": "postgres:18.6-trixie@sha256:5a5a84b19854a9ffaa54082c166ff4ec27473a361e496e5ea167f298f2da9722",
"version": "18.6 (Debian 18.6-1.pgdg13+2)",
"settings": {
"autovacuum": "on",
"checkpoint_timeout": "5min",
"effective_cache_size": "4GB",
"fsync": "on",
"jit": "on",
"maintenance_work_mem": "64MB",
"max_connections": "100",
"max_wal_size": "1GB",
"plan_cache_mode": "auto",
"random_page_cost": "4",
"shared_buffers": "128MB",
"shared_preload_libraries": "auto_explain",
"synchronous_commit": "on",
"wal_level": "replica",
"work_mem": "4MB"
}
},
"valkey": {
"image": "valkey/valkey:9.1.2-trixie@sha256:418652cfb58ef879d4978c33553735d7147016032d5aefaa14c828e611eb9dfd",
"version": "9.1.2",
"maxmemory": "67108864",
"maxmemory-clients": "0",
"maxmemory-eviction-tenacity": "10",
"maxmemory-policy": "allkeys-lru",
"maxmemory-samples": "5"
},
"limits": {
"api": {
"nano_cpus": 1000000000,
"memory": 1073741824,
"memory_swap": 1073741824,
"published_ports": {}
},
"postgres": {
"nano_cpus": 2000000000,
"memory": 2147483648,
"memory_swap": 2147483648,
"published_ports": {}
},
"valkey": {
"nano_cpus": 1000000000,
"memory": 268435456,
"memory_swap": 268435456,
"published_ports": {}
}
},
"app_env": {
"CACHE_HOST": "valkey",
"CACHE_PORT": "6379",
"DB_HOST": "postgres",
"DB_NAME": "bench",
"DB_PORT": "5432",
"DB_USER": "bench",
"LOG_LEVEL": "INFO",
"SESSION_TTL_SECONDS": "21600",
"SHUTDOWN_TIMEOUT": "5"
}
},
"finished_utc": "2026-10-02T01:03:21Z",
"duration_s": 951,
"plans": [
{
"size": 10000,
"chat_class": "",
"page": "first",
"after": 0,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 13,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.04,
"kind": "custom"
},
{
"size": 10000,
"chat_class": "",
"page": "middle",
"after": 5000,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 54,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.046,
"kind": "custom"
},
{
"size": 10000,
"chat_class": "",
"page": "last",
"after": 9950,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 52,
"shared_read": 0,
"rows": 50.0,
"time_ms": 0.041,
"kind": "custom"
},
{
"size": 10000,
"chat_class": "",
"page": "middle",
"after": 5000,
"source": "psql",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 54,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.083,
"kind": "custom"
},
{
"size": 10000,
"chat_class": "",
"page": "middle",
"after": 5000,
"source": "psql, no index",
"node": "Seq Scan on messages",
"shared_hit": 337,
"shared_read": 0,
"rows": 51.0,
"time_ms": 1.274,
"kind": "custom"
},
{
"size": 100000,
"chat_class": "",
"page": "first",
"after": 0,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 21,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.047,
"kind": "custom"
},
{
"size": 100000,
"chat_class": "",
"page": "middle",
"after": 50000,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 54,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.043,
"kind": "custom"
},
{
"size": 100000,
"chat_class": "",
"page": "last",
"after": 99950,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 54,
"shared_read": 0,
"rows": 50.0,
"time_ms": 0.042,
"kind": "custom"
},
{
"size": 100000,
"chat_class": "",
"page": "middle",
"after": 50000,
"source": "psql",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 54,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.118,
"kind": "custom"
},
{
"size": 100000,
"chat_class": "",
"page": "middle",
"after": 50000,
"source": "psql, no index",
"node": "Parallel Seq Scan on messages",
"shared_hit": 2969,
"shared_read": 0,
"rows": 51.0,
"time_ms": 7.468,
"kind": "custom"
},
{
"size": 500000,
"chat_class": "",
"page": "first",
"after": 0,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 9,
"shared_read": 12,
"rows": 51.0,
"time_ms": 0.073,
"kind": "custom"
},
{
"size": 500000,
"chat_class": "",
"page": "middle",
"after": 250000,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 44,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.046,
"kind": "custom"
},
{
"size": 500000,
"chat_class": "",
"page": "last",
"after": 499950,
"source": "app",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 53,
"shared_read": 0,
"rows": 50.0,
"time_ms": 0.041,
"kind": "custom"
},
{
"size": 500000,
"chat_class": "",
"page": "middle",
"after": 250000,
"source": "psql",
"node": "Index Scan using ix_messages_chat_id_created_at_id on messages",
"shared_hit": 44,
"shared_read": 0,
"rows": 51.0,
"time_ms": 0.169,
"kind": "custom"
},
{
"size": 500000,
"chat_class": "",
"page": "middle",
"after": 250000,
"source": "psql, no index",
"node": "Parallel Seq Scan on messages",
"shared_hit": 14129,
"shared_read": 832,
"rows": 51.0,
"time_ms": 22.545,
"kind": "custom"
}
]
}
+55
View File
@@ -0,0 +1,55 @@
scenario,size,clients,repeat,requests,errors,rps,p50_ms,p90_ms,p95_ms,p99_ms,max_ms,mean_ms,cpu_us_per_req,app_cpu_cores,rss_mib,store_messages_start,gen_cpu_cores,window_s,flags,db_cpu_cores,db_cpu_us_per_req,chat_class
read,10000,1,1,3739,0,623.2,1.5855,1.6823,1.7337,2.0232,5.84,1.6032,1270.3,0.792,88.5,10000,0.023,5.9996,,0.147,235.4,
read,10000,8,1,5416,0,902.56,8.7157,9.141,9.3278,10.7343,26.4694,8.8577,1112.3,1.0,88.7,10000,0.037,6.0007,,0.216,239.7,
read,10000,32,1,5259,0,873.74,33.9779,45.5658,49.0908,56.3528,81.9195,36.4574,1149.5,1.0,92.7,10000,0.037,6.019,,0.246,282.4,
read,10000,1,2,3678,0,613.01,1.6181,1.7222,1.766,1.8955,2.8222,1.63,1293.8,0.79,92.7,10000,0.022,5.9999,,0.148,242.3,
read,10000,8,2,5420,0,902.62,8.7957,9.1837,9.3597,10.3061,25.8148,8.8538,1112.0,1.0,92.9,10000,0.037,6.0047,,0.218,242.8,
read,10000,32,2,5310,0,881.58,33.8564,43.3689,48.5774,57.4719,75.8625,36.1346,1143.1,1.0,94.2,10000,0.038,6.0233,,0.241,275.8,
read,10000,1,3,3636,0,605.98,1.6344,1.7347,1.7817,1.9725,5.0656,1.6486,1308.0,0.79,94.2,10000,0.024,6.0002,,0.147,243.5,
read,10000,8,3,5418,0,902.4,8.7532,9.1766,9.3856,10.7377,25.2873,8.8388,1107.6,1.0,94.2,10000,0.037,6.004,,0.215,238.4,
read,10000,32,3,5213,0,863.87,34.1722,46.371,50.2488,59.9196,82.1216,36.8385,1153.6,0.999,94.7,10000,0.037,6.0345,,0.242,279.0,
write,10000,1,1,3000,0,814.6,1.2179,1.2769,1.3234,1.5142,2.5483,1.2268,942.4,0.759,94.7,10000,0.027,3.6828,,0.165,204.9,
write,10000,8,1,3000,0,1274.24,6.209,6.5672,6.7257,7.6192,13.4175,6.262,797.0,1.003,94.7,13300,0.048,2.3544,,0.287,228.0,
write,10000,32,1,3000,0,1229.38,25.0452,30.436,33.4102,40.9187,68.6154,25.7478,830.3,1.0,94.9,16600,0.045,2.4403,,0.289,239.9,
write,10000,1,2,3000,0,805.39,1.2241,1.2878,1.329,1.5705,4.8057,1.2408,945.5,0.757,94.9,19900,0.028,3.7249,,0.166,206.8,
write,10000,8,2,3000,0,1278.42,6.2262,6.5492,6.6559,6.9352,9.5558,6.242,790.9,1.0,94.9,23200,0.046,2.3466,,0.278,219.9,
write,10000,32,2,3000,0,1238.94,24.8136,29.7928,32.1975,39.3499,78.8243,25.5767,824.2,1.003,94.9,26500,0.045,2.4214,,0.29,238.3,
write,10000,1,3,3000,0,821.86,1.2051,1.2683,1.3008,1.4232,5.7627,1.2159,936.4,0.758,94.9,29800,0.028,3.6503,,0.164,202.9,
write,10000,8,3,3000,0,1253.24,6.3916,6.6699,6.7444,7.0077,7.3982,6.3675,809.1,1.003,94.9,33100,0.045,2.3938,,0.272,219.6,
write,10000,32,3,3000,0,1205.78,25.1683,31.5866,35.7352,43.865,73.0079,26.2803,845.5,0.997,95.0,36400,0.047,2.488,,0.295,250.0,
read,100000,1,1,3462,0,577.0,1.7165,1.8497,1.9118,2.083,3.0996,1.7314,1371.4,0.78,98.9,100000,0.024,6.0,,0.158,278.1,
read,100000,8,1,5491,0,914.34,8.7076,9.0901,9.2378,9.7174,25.4382,8.7386,1097.4,0.999,99.1,100000,0.038,6.0054,,0.226,248.5,
read,100000,32,1,5334,0,888.03,33.5711,43.4483,49.4619,58.7357,80.3615,35.8984,1137.7,1.001,100.4,100000,0.039,6.0065,,0.258,293.5,
read,100000,1,2,3533,0,588.94,1.6887,1.7703,1.8044,2.01,3.2835,1.6963,1335.5,0.784,100.4,100000,0.023,5.9989,,0.151,257.8,
read,100000,8,2,5502,0,916.36,8.6609,9.0245,9.1888,9.8441,24.2777,8.7186,1092.6,0.998,100.4,100000,0.038,6.0042,,0.221,241.4,
read,100000,32,2,5343,0,887.61,33.7485,43.9767,47.9927,54.13,64.8773,35.8929,1133.2,1.0,100.5,100000,0.039,6.0195,,0.258,292.1,
read,100000,1,3,3532,0,588.71,1.6909,1.7671,1.7925,2.0081,6.1157,1.6969,1335.7,0.784,100.4,100000,0.023,5.9996,,0.151,257.9,
read,100000,8,3,5463,0,909.99,8.6713,9.1226,9.295,10.7288,25.0279,8.7821,1104.8,1.0,100.4,100000,0.038,6.0034,,0.222,245.0,
read,100000,32,3,5197,0,863.25,34.4619,45.3447,48.6307,60.4818,76.1502,36.9125,1157.5,0.991,100.4,100000,0.037,6.0202,,0.253,295.4,
write,100000,1,1,3000,0,795.54,1.2371,1.3125,1.3654,1.4876,6.3744,1.2562,948.5,0.743,100.4,100000,0.027,3.771,,0.165,210.2,
write,100000,8,1,3000,0,1229.43,6.4736,6.84,6.9688,7.7069,13.7324,6.4923,809.1,0.99,100.4,103300,0.045,2.4402,,0.272,222.1,
write,100000,32,1,3000,0,1244.85,24.4565,29.363,32.0407,42.0886,59.1627,25.3698,821.2,1.003,100.5,106600,0.046,2.4099,,0.296,242.3,
write,100000,1,2,3000,0,814.99,1.2175,1.2691,1.2908,1.4019,5.4127,1.2262,945.5,0.762,100.5,109900,0.027,3.681,,0.168,208.1,
write,100000,8,2,3000,0,1296.56,6.1275,6.4771,6.6073,7.0015,8.2423,6.1546,772.7,1.003,100.5,113200,0.047,2.3138,,0.289,223.1,
write,100000,32,2,3000,0,1256.38,24.5682,29.7812,32.7144,39.7959,56.5727,25.1723,812.1,0.998,100.5,116500,0.046,2.3878,,0.299,243.3,
write,100000,1,3,3000,0,801.32,1.2357,1.2837,1.3084,1.5564,2.974,1.2471,948.5,0.753,100.5,119800,0.027,3.7438,,0.165,207.8,
write,100000,8,3,3000,0,1287.89,6.1985,6.4755,6.5912,7.1329,10.2608,6.198,784.8,0.999,100.4,123100,0.046,2.3294,,0.287,225.4,
write,100000,32,3,3000,0,1245.89,24.6233,29.5064,31.0049,40.8793,77.9941,25.3857,818.2,0.998,100.5,126400,0.046,2.4079,,0.31,253.8,
read,500000,1,1,3404,0,567.25,1.749,1.8211,1.8671,2.001,6.684,1.7612,1380.5,0.78,105.3,500000,0.023,6.0009,,0.154,271.8,
read,500000,8,1,5479,0,912.66,8.6917,9.1151,9.2988,9.9625,26.0894,8.7579,1106.3,1.0,105.6,500000,0.038,6.0033,,0.23,254.5,
read,500000,32,1,5347,0,887.95,33.7867,43.6108,48.4726,55.1958,70.0138,35.8784,1141.5,1.0,107.0,500000,0.039,6.0218,,0.27,308.5,
read,500000,1,2,3387,0,564.62,1.7502,1.8297,1.8848,2.1547,7.1975,1.7694,1382.0,0.779,107.0,500000,0.022,5.9987,,0.155,274.5,
read,500000,8,2,5419,0,902.77,8.777,9.2204,9.4002,10.2986,25.0162,8.8522,1102.4,0.99,107.0,500000,0.038,6.0027,,0.226,251.6,
read,500000,32,2,5353,0,889.0,33.7293,42.963,47.8505,56.0569,79.7348,35.8476,1126.4,1.0,107.1,500000,0.04,6.0214,,0.265,298.7,
read,500000,1,3,3417,0,569.5,1.7419,1.8089,1.8395,2.0008,17.8617,1.7542,1376.3,0.782,107.1,500000,0.023,6.0,,0.155,273.7,
read,500000,8,3,5529,0,920.82,8.6199,9.0655,9.2363,9.7287,24.6286,8.6772,1093.2,1.001,107.1,500000,0.038,6.0044,,0.23,251.1,
read,500000,32,3,5351,0,888.09,33.6868,43.0002,48.9036,58.275,74.7557,35.8687,1131.2,0.998,107.3,500000,0.04,6.0253,,0.268,303.6,
write,500000,1,1,3000,0,793.72,1.2378,1.3054,1.3628,1.731,6.3644,1.259,963.6,0.755,107.3,500000,0.028,3.7797,,0.17,216.9,
write,500000,8,1,3000,0,1289.42,6.1685,6.4925,6.6426,7.0372,7.7609,6.1895,784.8,1.001,107.3,503300,0.049,2.3266,,0.302,236.7,
write,500000,32,1,3000,0,1229.93,24.5466,30.3052,34.4651,42.7552,68.2582,25.7699,830.3,0.999,107.3,506600,0.048,2.4392,,0.299,248.8,
write,500000,1,2,3000,0,790.24,1.2586,1.3097,1.3282,1.3998,3.2976,1.2646,963.6,0.755,107.3,509900,0.028,3.7963,,0.169,215.2,
write,500000,8,2,3000,0,1271.47,6.2266,6.5456,6.6329,7.9715,18.0047,6.2776,787.9,0.996,107.3,513200,0.047,2.3595,,0.291,230.3,
write,500000,32,2,3000,0,1251.52,24.7119,29.3882,30.4726,38.9358,61.8811,25.3147,824.2,1.006,107.3,516500,0.047,2.3971,,0.302,247.3,
write,500000,1,3,3000,0,792.12,1.2415,1.3013,1.3393,1.6321,5.5728,1.2615,957.6,0.753,107.3,519800,0.029,3.7873,,0.166,211.2,
write,500000,8,3,3000,0,1273.36,6.2445,6.6058,6.7428,7.1467,9.1345,6.2693,793.9,1.004,107.3,523100,0.049,2.356,,0.29,229.3,
write,500000,32,3,3000,0,1264.03,24.3603,28.9151,29.9703,40.1502,62.3066,25.0332,809.1,1.0,107.3,526400,0.046,2.3734,,0.309,249.7,
1 scenario size clients repeat requests errors rps p50_ms p90_ms p95_ms p99_ms max_ms mean_ms cpu_us_per_req app_cpu_cores rss_mib store_messages_start gen_cpu_cores window_s flags db_cpu_cores db_cpu_us_per_req chat_class
2 read 10000 1 1 3739 0 623.2 1.5855 1.6823 1.7337 2.0232 5.84 1.6032 1270.3 0.792 88.5 10000 0.023 5.9996 0.147 235.4
3 read 10000 8 1 5416 0 902.56 8.7157 9.141 9.3278 10.7343 26.4694 8.8577 1112.3 1.0 88.7 10000 0.037 6.0007 0.216 239.7
4 read 10000 32 1 5259 0 873.74 33.9779 45.5658 49.0908 56.3528 81.9195 36.4574 1149.5 1.0 92.7 10000 0.037 6.019 0.246 282.4
5 read 10000 1 2 3678 0 613.01 1.6181 1.7222 1.766 1.8955 2.8222 1.63 1293.8 0.79 92.7 10000 0.022 5.9999 0.148 242.3
6 read 10000 8 2 5420 0 902.62 8.7957 9.1837 9.3597 10.3061 25.8148 8.8538 1112.0 1.0 92.9 10000 0.037 6.0047 0.218 242.8
7 read 10000 32 2 5310 0 881.58 33.8564 43.3689 48.5774 57.4719 75.8625 36.1346 1143.1 1.0 94.2 10000 0.038 6.0233 0.241 275.8
8 read 10000 1 3 3636 0 605.98 1.6344 1.7347 1.7817 1.9725 5.0656 1.6486 1308.0 0.79 94.2 10000 0.024 6.0002 0.147 243.5
9 read 10000 8 3 5418 0 902.4 8.7532 9.1766 9.3856 10.7377 25.2873 8.8388 1107.6 1.0 94.2 10000 0.037 6.004 0.215 238.4
10 read 10000 32 3 5213 0 863.87 34.1722 46.371 50.2488 59.9196 82.1216 36.8385 1153.6 0.999 94.7 10000 0.037 6.0345 0.242 279.0
11 write 10000 1 1 3000 0 814.6 1.2179 1.2769 1.3234 1.5142 2.5483 1.2268 942.4 0.759 94.7 10000 0.027 3.6828 0.165 204.9
12 write 10000 8 1 3000 0 1274.24 6.209 6.5672 6.7257 7.6192 13.4175 6.262 797.0 1.003 94.7 13300 0.048 2.3544 0.287 228.0
13 write 10000 32 1 3000 0 1229.38 25.0452 30.436 33.4102 40.9187 68.6154 25.7478 830.3 1.0 94.9 16600 0.045 2.4403 0.289 239.9
14 write 10000 1 2 3000 0 805.39 1.2241 1.2878 1.329 1.5705 4.8057 1.2408 945.5 0.757 94.9 19900 0.028 3.7249 0.166 206.8
15 write 10000 8 2 3000 0 1278.42 6.2262 6.5492 6.6559 6.9352 9.5558 6.242 790.9 1.0 94.9 23200 0.046 2.3466 0.278 219.9
16 write 10000 32 2 3000 0 1238.94 24.8136 29.7928 32.1975 39.3499 78.8243 25.5767 824.2 1.003 94.9 26500 0.045 2.4214 0.29 238.3
17 write 10000 1 3 3000 0 821.86 1.2051 1.2683 1.3008 1.4232 5.7627 1.2159 936.4 0.758 94.9 29800 0.028 3.6503 0.164 202.9
18 write 10000 8 3 3000 0 1253.24 6.3916 6.6699 6.7444 7.0077 7.3982 6.3675 809.1 1.003 94.9 33100 0.045 2.3938 0.272 219.6
19 write 10000 32 3 3000 0 1205.78 25.1683 31.5866 35.7352 43.865 73.0079 26.2803 845.5 0.997 95.0 36400 0.047 2.488 0.295 250.0
20 read 100000 1 1 3462 0 577.0 1.7165 1.8497 1.9118 2.083 3.0996 1.7314 1371.4 0.78 98.9 100000 0.024 6.0 0.158 278.1
21 read 100000 8 1 5491 0 914.34 8.7076 9.0901 9.2378 9.7174 25.4382 8.7386 1097.4 0.999 99.1 100000 0.038 6.0054 0.226 248.5
22 read 100000 32 1 5334 0 888.03 33.5711 43.4483 49.4619 58.7357 80.3615 35.8984 1137.7 1.001 100.4 100000 0.039 6.0065 0.258 293.5
23 read 100000 1 2 3533 0 588.94 1.6887 1.7703 1.8044 2.01 3.2835 1.6963 1335.5 0.784 100.4 100000 0.023 5.9989 0.151 257.8
24 read 100000 8 2 5502 0 916.36 8.6609 9.0245 9.1888 9.8441 24.2777 8.7186 1092.6 0.998 100.4 100000 0.038 6.0042 0.221 241.4
25 read 100000 32 2 5343 0 887.61 33.7485 43.9767 47.9927 54.13 64.8773 35.8929 1133.2 1.0 100.5 100000 0.039 6.0195 0.258 292.1
26 read 100000 1 3 3532 0 588.71 1.6909 1.7671 1.7925 2.0081 6.1157 1.6969 1335.7 0.784 100.4 100000 0.023 5.9996 0.151 257.9
27 read 100000 8 3 5463 0 909.99 8.6713 9.1226 9.295 10.7288 25.0279 8.7821 1104.8 1.0 100.4 100000 0.038 6.0034 0.222 245.0
28 read 100000 32 3 5197 0 863.25 34.4619 45.3447 48.6307 60.4818 76.1502 36.9125 1157.5 0.991 100.4 100000 0.037 6.0202 0.253 295.4
29 write 100000 1 1 3000 0 795.54 1.2371 1.3125 1.3654 1.4876 6.3744 1.2562 948.5 0.743 100.4 100000 0.027 3.771 0.165 210.2
30 write 100000 8 1 3000 0 1229.43 6.4736 6.84 6.9688 7.7069 13.7324 6.4923 809.1 0.99 100.4 103300 0.045 2.4402 0.272 222.1
31 write 100000 32 1 3000 0 1244.85 24.4565 29.363 32.0407 42.0886 59.1627 25.3698 821.2 1.003 100.5 106600 0.046 2.4099 0.296 242.3
32 write 100000 1 2 3000 0 814.99 1.2175 1.2691 1.2908 1.4019 5.4127 1.2262 945.5 0.762 100.5 109900 0.027 3.681 0.168 208.1
33 write 100000 8 2 3000 0 1296.56 6.1275 6.4771 6.6073 7.0015 8.2423 6.1546 772.7 1.003 100.5 113200 0.047 2.3138 0.289 223.1
34 write 100000 32 2 3000 0 1256.38 24.5682 29.7812 32.7144 39.7959 56.5727 25.1723 812.1 0.998 100.5 116500 0.046 2.3878 0.299 243.3
35 write 100000 1 3 3000 0 801.32 1.2357 1.2837 1.3084 1.5564 2.974 1.2471 948.5 0.753 100.5 119800 0.027 3.7438 0.165 207.8
36 write 100000 8 3 3000 0 1287.89 6.1985 6.4755 6.5912 7.1329 10.2608 6.198 784.8 0.999 100.4 123100 0.046 2.3294 0.287 225.4
37 write 100000 32 3 3000 0 1245.89 24.6233 29.5064 31.0049 40.8793 77.9941 25.3857 818.2 0.998 100.5 126400 0.046 2.4079 0.31 253.8
38 read 500000 1 1 3404 0 567.25 1.749 1.8211 1.8671 2.001 6.684 1.7612 1380.5 0.78 105.3 500000 0.023 6.0009 0.154 271.8
39 read 500000 8 1 5479 0 912.66 8.6917 9.1151 9.2988 9.9625 26.0894 8.7579 1106.3 1.0 105.6 500000 0.038 6.0033 0.23 254.5
40 read 500000 32 1 5347 0 887.95 33.7867 43.6108 48.4726 55.1958 70.0138 35.8784 1141.5 1.0 107.0 500000 0.039 6.0218 0.27 308.5
41 read 500000 1 2 3387 0 564.62 1.7502 1.8297 1.8848 2.1547 7.1975 1.7694 1382.0 0.779 107.0 500000 0.022 5.9987 0.155 274.5
42 read 500000 8 2 5419 0 902.77 8.777 9.2204 9.4002 10.2986 25.0162 8.8522 1102.4 0.99 107.0 500000 0.038 6.0027 0.226 251.6
43 read 500000 32 2 5353 0 889.0 33.7293 42.963 47.8505 56.0569 79.7348 35.8476 1126.4 1.0 107.1 500000 0.04 6.0214 0.265 298.7
44 read 500000 1 3 3417 0 569.5 1.7419 1.8089 1.8395 2.0008 17.8617 1.7542 1376.3 0.782 107.1 500000 0.023 6.0 0.155 273.7
45 read 500000 8 3 5529 0 920.82 8.6199 9.0655 9.2363 9.7287 24.6286 8.6772 1093.2 1.001 107.1 500000 0.038 6.0044 0.23 251.1
46 read 500000 32 3 5351 0 888.09 33.6868 43.0002 48.9036 58.275 74.7557 35.8687 1131.2 0.998 107.3 500000 0.04 6.0253 0.268 303.6
47 write 500000 1 1 3000 0 793.72 1.2378 1.3054 1.3628 1.731 6.3644 1.259 963.6 0.755 107.3 500000 0.028 3.7797 0.17 216.9
48 write 500000 8 1 3000 0 1289.42 6.1685 6.4925 6.6426 7.0372 7.7609 6.1895 784.8 1.001 107.3 503300 0.049 2.3266 0.302 236.7
49 write 500000 32 1 3000 0 1229.93 24.5466 30.3052 34.4651 42.7552 68.2582 25.7699 830.3 0.999 107.3 506600 0.048 2.4392 0.299 248.8
50 write 500000 1 2 3000 0 790.24 1.2586 1.3097 1.3282 1.3998 3.2976 1.2646 963.6 0.755 107.3 509900 0.028 3.7963 0.169 215.2
51 write 500000 8 2 3000 0 1271.47 6.2266 6.5456 6.6329 7.9715 18.0047 6.2776 787.9 0.996 107.3 513200 0.047 2.3595 0.291 230.3
52 write 500000 32 2 3000 0 1251.52 24.7119 29.3882 30.4726 38.9358 61.8811 25.3147 824.2 1.006 107.3 516500 0.047 2.3971 0.302 247.3
53 write 500000 1 3 3000 0 792.12 1.2415 1.3013 1.3393 1.6321 5.5728 1.2615 957.6 0.753 107.3 519800 0.029 3.7873 0.166 211.2
54 write 500000 8 3 3000 0 1273.36 6.2445 6.6058 6.7428 7.1467 9.1345 6.2693 793.9 1.004 107.3 523100 0.049 2.356 0.29 229.3
55 write 500000 32 3 3000 0 1264.03 24.3603 28.9151 29.9703 40.1502 62.3066 25.0332 809.1 1.0 107.3 526400 0.046 2.3734 0.309 249.7
+99
View File
@@ -0,0 +1,99 @@
# Стенд: метка `baseline`
- Снято: 2026-10-02T00:47:30Z — 2026-10-02T01:03:21Z (951 с), профиль `full`, вариант индекса `keyset`
- Хост: Apple M4, 10 CPU, 16.0 ГБ, macOS-26.6.2-arm64-arm-64bit-Mach-O; питание: AC Power, swap: 0.0 МиБ
- Docker: 28.0.4 (Docker Desktop), 10 CPU, 7.7 ГБ, cgroup v2; посторонних контейнеров: 0
- Образ: `mtusi-messenger-vladimirceva:bench-baseline` (e670ace82a78), python 3.13.15, fastapi 0.142.1, starlette 1.7.0, uvicorn 0.54.0, pydantic 2.13.5, sqlalchemy 2.1.1, asyncpg 0.31.0, alembic 1.20.0, redis 8.1.0, argon2-cffi 25.1.0
- Код: src_sha256 `8a7e256c540af433`, commit `c7d36bcaa592`
- Лимиты: API `--cpus=1 --memory=1g`, PostgreSQL `2 CPU / 2g`, Valkey `1 CPU / 256m`, без swap; API без healthcheck, порты не публикуются
- PostgreSQL: 18.6 (Debian 18.6-1.pgdg13+2), shared_buffers 128MB, настройки образа + auto_explain (выключен вне этапа плана); свежий volume на каждый размер; после наполнения VACUUM (ANALYZE) и CHECKPOINT
- Генератор: `bench/loadgen.py` в той же docker-сети, образ `python:3.13.15-slim-trixie`, до 4 процессов; вход по Basic, запросы с Bearer
- Чтение: 6.0 с после 2.0 с прогрева, страница limit=50 со случайным курсором пула; запись: 3000 запросов после 300 прогрева в отдельный чат; повторов: 3
Значения — медиана повторов, в скобках min–max.
## Чтение: `GET .../messages?limit=50&cursor=...`
| История | Клиенты | RPS | p50, мс | p95, мс | p99, мс | CPU API, мкс/запрос | CPU API, ядер | CPU БД, ядер | CPU БД, мкс/запрос | Пометки |
|---|---|---|---|---|---|---|---|---|---|---|
| 10k | 1 | 613 (606–623) | 1.62 (1.59–1.63) | 1.77 (1.73–1.78) | 1.97 (1.90–2.02) | 1294 (1270–1308) | 0.79 (0.79–0.79) | 0.15 (0.15–0.15) | 242 (235–244) | — |
| 10k | 8 | 903 (902–903) | 8.75 (8.72–8.80) | 9.36 (9.33–9.39) | 10.73 (10.31–10.74) | 1112 (1108–1112) | 1.00 (1.00–1.00) | 0.22 (0.21–0.22) | 240 (238–243) | — |
| 10k | 32 | 874 (864–882) | 33.98 (33.86–34.17) | 49.09 (48.58–50.25) | 57.47 (56.35–59.92) | 1150 (1143–1154) | 1.00 (1.00–1.00) | 0.24 (0.24–0.25) | 279 (276–282) | — |
| 100k | 1 | 589 (577–589) | 1.69 (1.69–1.72) | 1.80 (1.79–1.91) | 2.01 (2.01–2.08) | 1336 (1336–1371) | 0.78 (0.78–0.78) | 0.15 (0.15–0.16) | 258 (258–278) | — |
| 100k | 8 | 914 (910–916) | 8.67 (8.66–8.71) | 9.24 (9.19–9.29) | 9.84 (9.72–10.73) | 1097 (1093–1105) | 1.00 (1.00–1.00) | 0.22 (0.22–0.23) | 245 (241–248) | — |
| 100k | 32 | 888 (863–888) | 33.75 (33.57–34.46) | 48.63 (47.99–49.46) | 58.74 (54.13–60.48) | 1138 (1133–1158) | 1.00 (0.99–1.00) | 0.26 (0.25–0.26) | 294 (292–295) | — |
| 500k | 1 | 567 (565–570) | 1.75 (1.74–1.75) | 1.87 (1.84–1.88) | 2.00 (2.00–2.15) | 1380 (1376–1382) | 0.78 (0.78–0.78) | 0.15 (0.15–0.15) | 274 (272–274) | — |
| 500k | 8 | 913 (903–921) | 8.69 (8.62–8.78) | 9.30 (9.24–9.40) | 9.96 (9.73–10.30) | 1102 (1093–1106) | 1.00 (0.99–1.00) | 0.23 (0.23–0.23) | 252 (251–254) | — |
| 500k | 32 | 888 (888–889) | 33.73 (33.69–33.79) | 48.47 (47.85–48.90) | 56.06 (55.20–58.27) | 1131 (1126–1142) | 1.00 (1.00–1.00) | 0.27 (0.27–0.27) | 304 (299–308) | — |
## Запись: `POST .../messages` в отдельный чат
| История | Клиенты | RPS | p50, мс | p95, мс | p99, мс | CPU API, мкс/запрос | CPU API, ядер | CPU БД, ядер | CPU БД, мкс/запрос | Пометки |
|---|---|---|---|---|---|---|---|---|---|---|
| 10k | 1 | 815 (805–822) | 1.22 (1.21–1.22) | 1.32 (1.30–1.33) | 1.51 (1.42–1.57) | 942 (936–946) | 0.76 (0.76–0.76) | 0.17 (0.16–0.17) | 205 (203–207) | — |
| 10k | 8 | 1274 (1253–1278) | 6.23 (6.21–6.39) | 6.73 (6.66–6.74) | 7.01 (6.94–7.62) | 797 (791–809) | 1.00 (1.00–1.00) | 0.28 (0.27–0.29) | 220 (220–228) | — |
| 10k | 32 | 1229 (1206–1239) | 25.05 (24.81–25.17) | 33.41 (32.20–35.74) | 40.92 (39.35–43.87) | 830 (824–846) | 1.00 (1.00–1.00) | 0.29 (0.29–0.29) | 240 (238–250) | — |
| 100k | 1 | 801 (796–815) | 1.24 (1.22–1.24) | 1.31 (1.29–1.37) | 1.49 (1.40–1.56) | 948 (946–948) | 0.75 (0.74–0.76) | 0.17 (0.17–0.17) | 208 (208–210) | — |
| 100k | 8 | 1288 (1229–1297) | 6.20 (6.13–6.47) | 6.61 (6.59–6.97) | 7.13 (7.00–7.71) | 785 (773–809) | 1.00 (0.99–1.00) | 0.29 (0.27–0.29) | 223 (222–225) | — |
| 100k | 32 | 1246 (1245–1256) | 24.57 (24.46–24.62) | 32.04 (31.00–32.71) | 40.88 (39.80–42.09) | 818 (812–821) | 1.00 (1.00–1.00) | 0.30 (0.30–0.31) | 243 (242–254) | — |
| 500k | 1 | 792 (790–794) | 1.24 (1.24–1.26) | 1.34 (1.33–1.36) | 1.63 (1.40–1.73) | 964 (958–964) | 0.76 (0.75–0.76) | 0.17 (0.17–0.17) | 215 (211–217) | — |
| 500k | 8 | 1273 (1271–1289) | 6.23 (6.17–6.24) | 6.64 (6.63–6.74) | 7.15 (7.04–7.97) | 788 (785–794) | 1.00 (1.00–1.00) | 0.29 (0.29–0.30) | 230 (229–237) | — |
| 500k | 32 | 1252 (1230–1264) | 24.55 (24.36–24.71) | 30.47 (29.97–34.47) | 40.15 (38.94–42.76) | 824 (809–830) | 1.00 (1.00–1.01) | 0.30 (0.30–0.31) | 249 (247–250) | — |
## Планы запроса истории
Страница истории читаемого чата (limit 50). `app` — план, с которым запрос выполнило приложение (auto_explain); `psql` — тот же текст и параметры средней (у маленького чата — первой) страницы, с индексом и без него (DROP INDEX в откатываемой транзакции). Полностью — `explain-*.txt`.
| История | Страница | После | Источник | Узел | shared hit | read | Строк | Время, мс | План |
|---|---|---|---|---|---|---|---|---|---|
| 10k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 13 | 0 | 51.0 | 0.04 | custom |
| 10k | middle | 5000 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51.0 | 0.046 | custom |
| 10k | last | 9950 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 50.0 | 0.041 | custom |
| 10k | middle | 5000 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51.0 | 0.083 | custom |
| 10k | middle | 5000 | psql, no index | Seq Scan on messages | 337 | 0 | 51.0 | 1.274 | custom |
| 100k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 21 | 0 | 51.0 | 0.047 | custom |
| 100k | middle | 50000 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51.0 | 0.043 | custom |
| 100k | last | 99950 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 50.0 | 0.042 | custom |
| 100k | middle | 50000 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51.0 | 0.118 | custom |
| 100k | middle | 50000 | psql, no index | Parallel Seq Scan on messages | 2969 | 0 | 51.0 | 7.468 | custom |
| 500k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 9 | 12 | 51.0 | 0.073 | custom |
| 500k | middle | 250000 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 44 | 0 | 51.0 | 0.046 | custom |
| 500k | last | 499950 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 50.0 | 0.041 | custom |
| 500k | middle | 250000 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 44 | 0 | 51.0 | 0.169 | custom |
| 500k | middle | 250000 | psql, no index | Parallel Seq Scan on messages | 14129 | 832 | 51.0 | 22.545 | custom |
## Память и объём
| История | RSS API пустой, МиБ | RSS API после наполнения, МиБ | Пик RSS, МиБ | OOM | Строк messages | Таблица, МиБ | Индексы, МиБ | Байт на сообщение в БД |
|---|---|---|---|---|---|---|---|---|
| 10k | 80.4 | 88.5 | 144.1 | нет | 10000 | 2.6 | 1.0 | 377 |
| 100k | 80.4 | 98.9 | 144.1 | нет | 100000 | 23.1 | 9.8 | 345 |
| 500k | 80.4 | 105.3 | 144.1 | нет | 500000 | 116.7 | 46.8 | 343 |
## Наполнение истории (запись при росте таблицы)
| Цель | Сообщений | RPS | p50, мс | p99, мс | max, мс | RSS, МиБ | CPU API | CPU БД |
|---|---|---|---|---|---|---|---|---|
| 10k | 2000 | 1023 | 13.09 | 41.23 | 211.0 | 85.0 | 1.002 | 0.284 |
| 10k | 4000 | 1099 | 13.07 | 33.46 | 94.4 | 85.9 | 1.0 | 0.276 |
| 10k | 6000 | 1122 | 13.08 | 32.40 | 83.3 | 86.5 | 1.004 | 0.297 |
| 10k | 8000 | 1061 | 13.12 | 44.31 | 96.3 | 87.5 | 1.003 | 0.28 |
| 10k | 10000 | 1047 | 13.61 | 38.28 | 93.4 | 88.5 | 0.995 | 0.262 |
| 100k | 20000 | 1154 | 13.01 | 27.01 | 217.0 | 90.0 | 1.0 | 0.278 |
| 100k | 40000 | 1146 | 13.05 | 30.74 | 97.2 | 94.0 | 1.0 | 0.28 |
| 100k | 60000 | 1194 | 12.77 | 23.75 | 92.6 | 96.5 | 1.0 | 0.286 |
| 100k | 80000 | 1135 | 12.95 | 31.68 | 92.9 | 97.0 | 1.0 | 0.289 |
| 100k | 100000 | 1156 | 12.90 | 28.46 | 97.5 | 98.9 | 1.001 | 0.288 |
| 500k | 50000 | 1158 | 12.99 | 25.61 | 217.2 | 92.0 | 1.0 | 0.281 |
| 500k | 100000 | 1171 | 12.91 | 25.30 | 102.9 | 96.6 | 1.0 | 0.286 |
| 500k | 150000 | 1160 | 13.03 | 25.79 | 93.8 | 100.3 | 0.999 | 0.282 |
| 500k | 200000 | 1171 | 12.94 | 26.22 | 82.8 | 100.3 | 1.0 | 0.286 |
| 500k | 250000 | 1157 | 12.95 | 28.12 | 93.4 | 101.4 | 0.998 | 0.287 |
| 500k | 300000 | 1120 | 13.39 | 30.11 | 90.6 | 103.0 | 0.989 | 0.277 |
| 500k | 350000 | 1178 | 12.88 | 25.41 | 89.9 | 103.0 | 1.0 | 0.294 |
| 500k | 400000 | 1169 | 12.93 | 25.87 | 102.6 | 104.0 | 1.0 | 0.29 |
| 500k | 450000 | 1162 | 12.89 | 31.62 | 102.0 | 104.0 | 0.999 | 0.292 |
| 500k | 500000 | 1186 | 12.86 | 24.76 | 93.9 | 105.3 | 1.0 | 0.292 |
Пометки: `errors` — были неуспешные запросы; `generator` — генератор занял больше порога CPU на процесс, предел мог быть в нём; `short` — измерено меньше запросов, чем задано; `stand_down` — PostgreSQL или Valkey упали или перезапускались.