V2 ingestion: limited multi-worker throughput scaling and session buffer backlog
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- clickhouse, kafka, redis, typescript
- Lĩnh vực
- backend, data-engineering, performance
Hướng nghiên cứu
Start by reading the buffer implementations in packages/core/src/buffers, especially event and session flush behavior, locking, and batching; then compare their scheduling and metrics. The issue presents performance observations and possible sharding as discussion options, but does not settle on a change or define acceptance criteria. Done would require maintainers to agree on a scaling direction and its ordering, consistency, and migration requirements.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Thanks for the recent ingestion and buffering improvements.
We tested the updated main branch with one million events per run, using the Kafka ingestion path. We observed limited throughput scaling when increasing the number of workers. In some configurations, the event buffer drained while a substantial session buffer backlog remained.
Increasing the session batch size and adjusting cron concurrency improved backlog clearance. We would like to understand the intended scaling strategy and whether further buffer-level parallelism is planned.
This is a performance investigation and design discussion, not a claim about OpenPanel's maximum throughput.
Version
Benchmark source revision:
a887576a (main snapshot taken on 2026-10-18)
We also reviewed the buffer implementation at:
1e5bfa6a53e0d595a9f1c1026e0d03f7ee6afbeb
The buffer implementation was unchanged between these two snapshots.
Environment
All services ran in a shared local VM:
- VM: 6 vCPU, 24 GiB RAM
- API: 2 instances, each limited to 2 CPU / 4 GiB RAM
- Workers: 1–3 instances, each limited to 2 CPU / 4 GiB RAM
- ClickHouse: limited to 2 CPU / 8 GiB RAM
- Kafka-compatible broker: Redpanda
- Topic partitions: 25
- Shared Redis for buffering and application state
- ClickHouse client compression disabled for these comparison runs
Pipeline:
API → Kafka/Redpanda → Workers → Redis buffers → ClickHouse
The container CPU limits were not dedicated CPU reservations. Because all services shared the VM, resource contention may have affected the scaling results.
Test workload and measurement
Each run processed 1,000,000 synthetic events, including session processing.
The rates below describe the measured event-processing/drain phase. They should not be interpreted as HTTP request throughput or as proof of sustained production capacity.
We also inspected Kafka lag, Redis buffer backlogs, and ClickHouse event counts.
This was a finite-load test, not a multi-hour steady-state benchmark. The results may depend on device/session distribution and the workload's derived-state update rate.
Results
Configuration Approx. event throughput Approx. event completion time
1 worker 2,159 events/s 463 s
2 workers 3,038 events/s 329 s
3 workers 2,853 events/s 350 s
2 workers, larger event batches 3,010 events/s 332 s
2 workers, larger event and session batches, cron concurrency adjusted 2,969 events/s 337 s
For the larger-event-batch configuration:
EVENT_BUFFER_BATCH_SIZE=50000
EVENT_BUFFER_CHUNK_SIZE=10000
BUFFER_CH_INSERT_CONCURRENCY=5
For the final configuration, we additionally used:
SESSION_BUFFER_BATCH_SIZE=50000
SESSION_BUFFER_CHUNK_SIZE=10000
CRON_CONCURRENCY=2
Backlog observations
With the larger event batches alone:
- The session buffer still contained approximately 726,150 entries when event processing completed.
- Peak observed session buffer length was approximately 1,253,700.
- Observed Redis memory peaked at approximately 967 MiB.
With the additional session and cron tuning:
- Kafka lag and all checked buffer backlogs were zero at the completion checkpoint.
- ClickHouse event count and unique event count both matched the 1,000,000-event input.
- No errors were observed in that run.
- Peak observed session buffer length was approximately 87,550.
- Observed Redis memory peaked at approximately 204 MiB.
Session buffer entries represent state/version records, not distinct sessions or business events.
The main improvement was more balanced end-to-end drainage and lower backlog/memory usage, rather than higher event throughput.
Relevant implementation observations
From reviewing packages/core/src/buffers:
-
Shared queue and lock per buffer type
Event writes converge on event_buffer:queue, coordinated by the event buffer lock.
Multiple workers can process upstream work, but they do not create independent event-buffer flush lanes.
Different buffer types have separate locks; this is not one global lock for all buffers.
-
Concurrency within a flush already exists
Event buffer chunks use bounded concurrent ClickHouse inserts.
Therefore, the current implementation is not strictly single-request-at-a-time. The question is whether the shared flush boundary limits further scaling.
-
Drain behavior differs by buffer type
EventBuffer.processBuffer() processes one batch per invocation.
Several other buffers use a time-budgeted loop to process multiple batches.
-
Session writes have different processing characteristics
Session updates produce version/sign records, and the buffer squashes intermediate versions before insertion.
Session chunks are currently inserted sequentially, rather than through the base buffer's bounded-concurrency helper.
-
Session phase-level visibility is limited
Session flushing reports processed rows, but does not currently expose the same detailed read/insert/trim timings as some other buffers.
These observations are possible contributors, not a confirmed root-cause diagnosis. Shared VM contention, Redis, ClickHouse, scheduling, and workload characteristics may also explain part of the results.
Questions
- What is the recommended configuration and deployment strategy for scaling sustained ingestion throughput across multiple workers?
- Is the shared per-type buffer/lock an intentional coordination boundary? Are there ordering or consistency requirements that would make sharding unsafe?
- Are there plans to improve event/session flush scheduling, add optional buffer sharding, or provide a documented multi-worker benchmark?
- Would additional session flush phase metrics be useful for distinguishing parsing/squashing overhead from ClickHouse insert latency?
Possible direction for discussion
Would an opt-in, fixed-shard buffer design be compatible with the current architecture?
For example:
- Keep the current behavior as the default.
- Introduce independent Redis lists and locks per shard.
- Route records deterministically, preserving the required entity/session ordering.
- Allow workers to process different shards concurrently.
- Bound total ClickHouse insert concurrency per worker, rather than multiplying concurrency independently across every shard.
- Provide an explicit transition/drain procedure for existing queues.
This is only a proposal for discussion. We are not assuming sharding is the only solution, or that it would remove Redis/ClickHouse resource limits.
Our goal is to understand how to scale the existing ingestion architecture while preserving its current event and session semantics.
- Ngôn ngữ chính
- TypeScript
- Star
- 7.1k
- Fork
- 516
- Merge trung bình
- 21 giờ 36 phút
- Pull request đã merge (30 ngày)
- 22
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Không có hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Openpanel-dev/openpanel
-
ClickHouse retry logs print CLICKHOUSE_URL with its passwordCó thể đã có người làm @ppjsw đã nhận 1 ngày trước. Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 92/100
Openpanel-dev/openpanel#551 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Self-hosted missing op1-replay.jsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Openpanel-dev/openpanel#512 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
login page needs refinementCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Openpanel-dev/openpanel#495 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Session-grouped queries treat every sessionless event as one session (wrong results, ClickHouse OOM)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
Openpanel-dev/openpanel#575 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Openpanel-dev/openpanel#563 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của Openpanel-dev/openpanel
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
endora-commerce/endora-commerce#397 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
level/task
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
wazuh/wazuh-dashboard-plugins#9472 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ready-for-agent
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
xavxyz/bei-shan-lin-shui#57 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
opennextjs/opennextjs-cloudflare#1461 ·
Maintainer thường phản hồi trong vòng 1 ngày