168 lines
18 KiB
Markdown
168 lines
18 KiB
Markdown
# Нагрузочный замер: метка `unit-of-work-aa`
|
||
|
||
- Статус: **complete**
|
||
- Commit: `b2fb88f`
|
||
- Профиль `quick`: размеры 1k, 5k, 10k; клиенты 1, 4, 16; повторов 1; чтение 5 с после 2 с прогрева; запись 1000 после 100
|
||
- Лимиты без swap: API 1 CPU / 2g × 1 реплик за HAProxy 1 CPU / 256m, PostgreSQL 4 CPU / 3g, Valkey 2 CPU / 512m; CPU и RSS API — сумма по репликам; значения — медиана (min–max) по повторам
|
||
- Посторонние контейнеры в VM во время замера: domains-api-1, domains-bot-1, domains-postgres-1
|
||
|
||
## Сценарий `read`
|
||
|
||
| Размер | Клиенты | RPS | p50, мс | p95, мс | p99, мс | max, мс | CPU API, ядер | CPU БД, ядер | RSS конец, МиБ | Сообщений в начале | Пометки |
|
||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||
| 1k | 1 | 529 | 1.78 | 2.16 | 2.55 | 5.3 | 0.82 | 0.14 | 125.0 | 4500 | — |
|
||
| 1k | 4 | 704 | 5.33 | 6.67 | 8.57 | 48.6 | 1.00 | 0.18 | 125.0 | 4500 | — |
|
||
| 1k | 16 | 662 | 22.05 | 43.02 | 63.12 | 81.4 | 1.00 | 0.18 | 125.0 | 4500 | — |
|
||
| 5k | 1 | 523 | 1.79 | 2.24 | 2.74 | 5.2 | 0.82 | 0.14 | 125.2 | 8500 | — |
|
||
| 5k | 4 | 711 | 5.32 | 6.48 | 8.05 | 47.2 | 1.00 | 0.18 | 125.2 | 8500 | — |
|
||
| 5k | 16 | 603 | 23.04 | 54.77 | 88.00 | 120.3 | 1.00 | 0.18 | 125.2 | 8500 | — |
|
||
| 10k | 1 | 490 | 1.83 | 2.57 | 3.48 | 85.0 | 0.82 | 0.14 | 125.2 | 13500 | — |
|
||
| 10k | 4 | 694 | 5.34 | 7.04 | 9.82 | 45.5 | 1.00 | 0.18 | 125.2 | 13500 | — |
|
||
| 10k | 16 | 646 | 21.96 | 46.24 | 71.63 | 114.6 | 1.00 | 0.18 | 125.2 | 13500 | — |
|
||
|
||
## Сценарий `write`
|
||
|
||
| Размер | Клиенты | RPS | p50, мс | p95, мс | p99, мс | max, мс | CPU API, ядер | CPU БД, ядер | RSS конец, МиБ | Сообщений в начале | Пометки |
|
||
|---|---|---|---|---|---|---|---|---|---|---|---|
|
||
| 1k | 1 | 462 | 2.01 | 2.70 | 3.51 | 5.3 | 0.78 | 0.13 | 125.0 | 4600 | — |
|
||
| 1k | 4 | 598 | 5.93 | 9.04 | 20.01 | 59.0 | 0.99 | 0.21 | 125.1 | 5700 | — |
|
||
| 1k | 16 | 610 | 24.93 | 40.01 | 69.13 | 78.8 | 1.01 | 0.22 | 125.3 | 6800 | — |
|
||
| 5k | 1 | 430 | 2.06 | 3.27 | 4.83 | 18.3 | 0.77 | 0.14 | 125.2 | 8600 | — |
|
||
| 5k | 4 | 669 | 5.80 | 6.97 | 8.44 | 9.2 | 1.00 | 0.19 | 125.2 | 9700 | — |
|
||
| 5k | 16 | 588 | 25.58 | 40.35 | 73.69 | 90.1 | 1.01 | 0.21 | 125.4 | 10800 | — |
|
||
| 10k | 1 | 433 | 2.06 | 3.15 | 5.44 | 15.5 | 0.76 | 0.13 | 125.2 | 13600 | — |
|
||
| 10k | 4 | 617 | 5.94 | 8.14 | 11.29 | 56.6 | 1.00 | 0.21 | 125.3 | 14700 | — |
|
||
| 10k | 16 | 609 | 25.02 | 37.35 | 68.04 | 78.8 | 1.01 | 0.21 | 125.4 | 15800 | — |
|
||
|
||
## Память и наполнение по размерам
|
||
|
||
Объём `messages` — после `VACUUM (ANALYZE)`, до прогонов: в таблице N сообщений читаемого чата и сообщения фоновых чатов (`Сообщений`).
|
||
|
||
| Размер | Сообщений | RSS API до, МиБ | RSS API после, МиБ | Байт RSS на сообщение | Таблица, МиБ | Индексы, МиБ | Байт в БД на сообщение | Наполнение, сообщ/с | Курсоров в пуле | Пик RSS за размер, МиБ |
|
||
|---|---|---|---|---|---|---|---|---|---|---|
|
||
| 1k | 4500 | 121.0 | 125.0 | 928 | 0.8 | 0.6 | 331 | 577 | 9 | 184.6 |
|
||
| 5k | 8500 | 121.0 | 125.2 | 511 | 1.5 | 1.1 | 322 | 580 | 49 | 184.7 |
|
||
| 10k | 13500 | 121.1 | 125.1 | 317 | 2.3 | 1.9 | 328 | 586 | 99 | 184.7 |
|
||
|
||
## Планы запроса истории
|
||
|
||
Страница (`limit` профиля) читаемого чата и первого чата каждого фонового уровня. `app` — план запроса приложения (auto_explain). Остальное — тот же запрос с теми же параметрами в psql, в откатываемой транзакции: `psql` — индекс приложения, `generic` — он же с generic plan, `or-cursor` — условие курсора через OR, `no-index` — без индекса, дальше — варианты индекса профиля. Буферы — верхнего узла плана, файлы — `explain-<размер>.txt`.
|
||
|
||
| Размер | Чат | Страница | После сообщений | Вариант | Узел | shared hit | read | Строк | Время, мс | План |
|
||
|---|---|---|---|---|---|---|---|---|---|---|
|
||
| 1k | read 1k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 32 | 0 | 51 | 0.147 | custom |
|
||
| 1k | read 1k | middle | 500 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 51 | 0 | 51 | 0.121 | custom |
|
||
| 1k | read 1k | middle | 500 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 51 | 0 | 51 | 0.065 | custom |
|
||
| 1k | read 1k | middle | 500 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 51 | 0 | 51 | 0.072 | generic |
|
||
| 1k | read 1k | middle | 500 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 525 | 0 | 51 | 0.136 | custom |
|
||
| 1k | read 1k | middle | 500 | no-index | Seq Scan on messages | 101 | 0 | 51 | 0.560 | custom |
|
||
| 1k | read 1k | middle | 500 | chat_only | Bitmap Heap Scan on messages | 103 | 0 | 51 | 0.519 | custom |
|
||
| 1k | read 1k | middle | 500 | covering | Index Only Scan using bench_variant on messages | 4 | 0 | 51 | 0.055 | custom |
|
||
| 1k | read 1k | last | 900 | app | Bitmap Heap Scan on messages | 28 | 0 | 51 | 0.240 | custom |
|
||
| 1k | bg 1k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 37 | 0 | 51 | 0.106 | custom |
|
||
| 1k | bg 1k | middle | 500 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.105 | custom |
|
||
| 1k | bg 1k | middle | 500 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.084 | custom |
|
||
| 1k | bg 1k | middle | 500 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.069 | generic |
|
||
| 1k | bg 1k | middle | 500 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 528 | 0 | 51 | 0.146 | custom |
|
||
| 1k | bg 1k | middle | 500 | no-index | Seq Scan on messages | 101 | 0 | 51 | 0.612 | custom |
|
||
| 1k | bg 1k | middle | 500 | chat_only | Bitmap Heap Scan on messages | 101 | 0 | 51 | 0.453 | custom |
|
||
| 1k | bg 1k | middle | 500 | covering | Index Only Scan using bench_variant on messages | 4 | 0 | 51 | 0.051 | custom |
|
||
| 1k | bg 1k | last | 900 | app | Bitmap Heap Scan on messages | 18 | 0 | 51 | 0.156 | custom |
|
||
| 1k | bg 100 | first | 0 | app | Bitmap Heap Scan on messages | 64 | 0 | 51 | 0.231 | custom |
|
||
| 1k | bg 100 | first | 0 | psql | Bitmap Heap Scan on messages | 64 | 0 | 51 | 0.127 | custom |
|
||
| 1k | bg 100 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 50 | 0 | 51 | 0.063 | generic |
|
||
| 1k | bg 100 | first | 0 | no-index | Seq Scan on messages | 101 | 0 | 51 | 0.207 | custom |
|
||
| 1k | bg 100 | first | 0 | chat_only | Bitmap Heap Scan on messages | 64 | 0 | 51 | 0.127 | custom |
|
||
| 1k | bg 100 | first | 0 | covering | Index Only Scan using bench_variant on messages | 4 | 0 | 51 | 0.052 | custom |
|
||
| 1k | bg 10 | first | 0 | app | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.041 | custom |
|
||
| 1k | bg 10 | first | 0 | psql | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.032 | custom |
|
||
| 1k | bg 10 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 12 | 0 | 10 | 0.023 | generic |
|
||
| 1k | bg 10 | first | 0 | no-index | Seq Scan on messages | 101 | 0 | 10 | 0.130 | custom |
|
||
| 1k | bg 10 | first | 0 | chat_only | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.026 | custom |
|
||
| 1k | bg 10 | first | 0 | covering | Index Only Scan using bench_variant on messages | 3 | 0 | 10 | 0.017 | custom |
|
||
| 5k | read 5k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 25 | 0 | 51 | 0.100 | custom |
|
||
| 5k | read 5k | middle | 2500 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51 | 0.113 | generic |
|
||
| 5k | read 5k | middle | 2500 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51 | 0.070 | custom |
|
||
| 5k | read 5k | middle | 2500 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51 | 0.081 | generic |
|
||
| 5k | read 5k | middle | 2500 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 2541 | 0 | 51 | 0.431 | custom |
|
||
| 5k | read 5k | middle | 2500 | no-index | Seq Scan on messages | 186 | 0 | 51 | 2.186 | custom |
|
||
| 5k | read 5k | middle | 2500 | chat_only | Seq Scan on messages | 186 | 0 | 51 | 2.057 | custom |
|
||
| 5k | read 5k | middle | 2500 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.108 | custom |
|
||
| 5k | read 5k | last | 4900 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.112 | generic |
|
||
| 5k | bg 1k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 45 | 0 | 51 | 0.253 | custom |
|
||
| 5k | bg 1k | middle | 500 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.109 | generic |
|
||
| 5k | bg 1k | middle | 500 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.076 | custom |
|
||
| 5k | bg 1k | middle | 500 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.076 | generic |
|
||
| 5k | bg 1k | middle | 500 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 530 | 0 | 51 | 0.143 | custom |
|
||
| 5k | bg 1k | middle | 500 | no-index | Seq Scan on messages | 186 | 0 | 51 | 0.643 | custom |
|
||
| 5k | bg 1k | middle | 500 | chat_only | Bitmap Heap Scan on messages | 186 | 0 | 51 | 0.483 | custom |
|
||
| 5k | bg 1k | middle | 500 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.058 | custom |
|
||
| 5k | bg 1k | last | 900 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 51 | 0 | 51 | 0.114 | generic |
|
||
| 5k | bg 100 | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 47 | 0 | 51 | 0.124 | custom |
|
||
| 5k | bg 100 | first | 0 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 47 | 0 | 51 | 0.072 | custom |
|
||
| 5k | bg 100 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 47 | 0 | 51 | 0.067 | generic |
|
||
| 5k | bg 100 | first | 0 | no-index | Seq Scan on messages | 186 | 0 | 51 | 0.290 | custom |
|
||
| 5k | bg 100 | first | 0 | chat_only | Bitmap Heap Scan on messages | 79 | 0 | 51 | 0.143 | custom |
|
||
| 5k | bg 100 | first | 0 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.062 | custom |
|
||
| 5k | bg 10 | first | 0 | app | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.042 | custom |
|
||
| 5k | bg 10 | first | 0 | psql | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.040 | custom |
|
||
| 5k | bg 10 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 12 | 0 | 10 | 0.032 | generic |
|
||
| 5k | bg 10 | first | 0 | no-index | Seq Scan on messages | 186 | 0 | 10 | 0.220 | custom |
|
||
| 5k | bg 10 | first | 0 | chat_only | Bitmap Heap Scan on messages | 12 | 0 | 10 | 0.033 | custom |
|
||
| 5k | bg 10 | first | 0 | covering | Index Only Scan using bench_variant on messages | 4 | 0 | 10 | 0.021 | custom |
|
||
| 10k | read 10k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 17 | 0 | 51 | 0.184 | custom |
|
||
| 10k | read 10k | middle | 5000 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.146 | generic |
|
||
| 10k | read 10k | middle | 5000 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.065 | custom |
|
||
| 10k | read 10k | middle | 5000 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 53 | 0 | 51 | 0.077 | generic |
|
||
| 10k | read 10k | middle | 5000 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 5063 | 0 | 51 | 0.779 | custom |
|
||
| 10k | read 10k | middle | 5000 | no-index | Seq Scan on messages | 293 | 0 | 51 | 3.995 | custom |
|
||
| 10k | read 10k | middle | 5000 | chat_only | Seq Scan on messages | 293 | 0 | 51 | 3.719 | custom |
|
||
| 10k | read 10k | middle | 5000 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.052 | custom |
|
||
| 10k | read 10k | last | 9900 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 54 | 0 | 51 | 0.144 | generic |
|
||
| 10k | bg 1k | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 46 | 0 | 51 | 0.150 | custom |
|
||
| 10k | bg 1k | middle | 500 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.185 | generic |
|
||
| 10k | bg 1k | middle | 500 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.057 | custom |
|
||
| 10k | bg 1k | middle | 500 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 52 | 0 | 51 | 0.072 | generic |
|
||
| 10k | bg 1k | middle | 500 | or-cursor | Index Scan using ix_messages_chat_id_created_at_id on messages | 502 | 0 | 51 | 0.129 | custom |
|
||
| 10k | bg 1k | middle | 500 | no-index | Seq Scan on messages | 293 | 0 | 51 | 0.676 | custom |
|
||
| 10k | bg 1k | middle | 500 | chat_only | Bitmap Heap Scan on messages | 281 | 0 | 51 | 0.517 | custom |
|
||
| 10k | bg 1k | middle | 500 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.054 | custom |
|
||
| 10k | bg 1k | last | 900 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 47 | 0 | 51 | 0.126 | generic |
|
||
| 10k | bg 100 | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 48 | 0 | 51 | 0.165 | custom |
|
||
| 10k | bg 100 | first | 0 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 48 | 0 | 51 | 0.055 | custom |
|
||
| 10k | bg 100 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 48 | 0 | 51 | 0.069 | generic |
|
||
| 10k | bg 100 | first | 0 | no-index | Seq Scan on messages | 293 | 0 | 51 | 0.402 | custom |
|
||
| 10k | bg 100 | first | 0 | chat_only | Bitmap Heap Scan on messages | 91 | 0 | 51 | 0.120 | custom |
|
||
| 10k | bg 100 | first | 0 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 51 | 0.049 | custom |
|
||
| 10k | bg 10 | first | 0 | app | Index Scan using ix_messages_chat_id_created_at_id on messages | 12 | 0 | 10 | 0.073 | custom |
|
||
| 10k | bg 10 | first | 0 | psql | Index Scan using ix_messages_chat_id_created_at_id on messages | 12 | 0 | 10 | 0.026 | custom |
|
||
| 10k | bg 10 | first | 0 | generic | Index Scan using ix_messages_chat_id_created_at_id on messages | 12 | 0 | 10 | 0.035 | generic |
|
||
| 10k | bg 10 | first | 0 | no-index | Seq Scan on messages | 293 | 0 | 10 | 0.313 | custom |
|
||
| 10k | bg 10 | first | 0 | chat_only | Index Scan using bench_variant on messages | 12 | 0 | 10 | 0.030 | custom |
|
||
| 10k | bg 10 | first | 0 | covering | Index Only Scan using bench_variant on messages | 5 | 0 | 10 | 0.017 | custom |
|
||
|
||
## Стоимость записи по вариантам индекса
|
||
|
||
Вставка порции сообщений во все чаты в пропорции наполнения одной командой, в транзакции, которая откатывается; индекс истории построен заново, перед вставкой `CHECKPOINT`. Значения — медиана (min–max) повторов. «4000 символов» — вставка сообщения максимальной длины из несжимаемого текста.
|
||
|
||
| Размер | Вариант | Строк вставки | Индекс, МиБ | Байт индекса на сообщение | мкс на сообщение | WAL байт на сообщение | FPI на 1000 | 4000 символов |
|
||
|---|---|---|---|---|---|---|---|---|
|
||
| 1k | app | 5000 | 0.5 | 60.9 | 5.24 (5.07–6.19) | 488 (488–501) | 20.8 (12.0–20.8) | ok |
|
||
| 1k | chat_only | 5000 | 0.1 | 9.5 | 4.97 (4.91–4.97) | 398 (398–399) | 18.2 (18.2–18.2) | ok |
|
||
| 1k | covering | 5000 | 1.2 | 159.6 | 5.71 (5.46–6.67) | 689 (689–689) | 24.2 (24.2–24.2) | index row requires 12072 bytes, maximum size is 8191 |
|
||
| 1k | none | 5000 | 0.0 | 0.0 | 4.62 (4.47–6.41) | 311 (311–311) | 16.8 (16.8–16.8) | ok |
|
||
| 5k | app | 5000 | 0.7 | 60.4 | 5.20 (5.04–5.34) | 512 (510–512) | 22.8 (17.2–22.8) | ok |
|
||
| 5k | chat_only | 5000 | 0.1 | 9.0 | 4.92 (4.77–5.05) | 425 (424–425) | 20.2 (19.8–20.6) | ok |
|
||
| 5k | covering | 5000 | 1.8 | 160.4 | 5.73 (5.70–8.37) | 719 (718–719) | 26.6 (26.2–26.6) | index row requires 12072 bytes, maximum size is 8191 |
|
||
| 5k | none | 5000 | 0.0 | 0.0 | 4.39 (4.28–4.39) | 336 (336–337) | 18.6 (18.4–18.6) | ok |
|
||
| 10k | app | 5000 | 1.0 | 59.5 | 5.16 (5.14–5.58) | 536 (536–550) | 30.2 (19.2–30.6) | ok |
|
||
| 10k | chat_only | 5000 | 0.1 | 8.3 | 4.93 (4.83–4.96) | 450 (448–452) | 28.0 (26.2–28.6) | ok |
|
||
| 10k | covering | 5000 | 2.6 | 160.4 | 5.63 (5.56–8.60) | 748 (747–749) | 34.2 (33.2–34.4) | index row requires 12072 bytes, maximum size is 8191 |
|
||
| 10k | none | 5000 | 0.0 | 0.0 | 4.39 (4.36–4.59) | 365 (363–365) | 26.8 (26.2–27.2) | ok |
|
||
|
||
## Кривая наполнения 10k: запись при росте хранилища, 32 клиента
|
||
|
||
| Порция | Сообщений после | RPS | p50, мс | p95, мс | p99, мс | max, мс | CPU API, ядер | CPU БД, ядер | RSS, МиБ | Пометки |
|
||
|---|---|---|---|---|---|---|---|---|---|---|
|
||
| 1 | 13500 | 586 | 51.517 | 104.946 | 144.711 | 250.139 | 0.999 | 0.202 | 125.1 | — |
|