Measure local Bytewax throughput
Compare a Bytewax pipeline and a direct Python loop that return the same sum. Run both in a terminal on your own machine.
Execute a real Python pipeline, preserve raw trial times, verify the answer, and separate observed service throughput from end-to-end streaming capacity. Start after operation effort and latency and batching.
1. Define the work
The source emits integers from zero through one less than count. Retain even values, double them and sum the retained values. The independently calculated answer checks that every run performed equivalent work. Imports are outside the timed region; source iteration, operator calls, accumulation and collecting one scalar are inside. The source and sink are in one process; there is no broker, serialization, network or disk.
2. Download and run
Download native-benchmark.py. Open a terminal in the file’s folder. Use Python 3.12. The page provides the script, and you run it in the terminal.
In Bash on Linux or macOS:
python3.12 -m venv .venv .venv/bin/python -m pip install bytewax==0.21.1 .venv/bin/python native-benchmark.py --count 100000 --trials 5 --backend bytewax > bytewax.json .venv/bin/python native-benchmark.py --count 100000 --trials 5 --backend direct > direct.json
Commands for Windows PowerShell
py -3.12 -m venv .venv .\.venv\Scripts\python.exe -m pip install bytewax==0.21.1 .\.venv\Scripts\python.exe native-benchmark.py --count 100000 --trials 5 --backend bytewax > bytewax.json .\.venv\Scripts\python.exe native-benchmark.py --count 100000 --trials 5 --backend direct > direct.json
Open bytewax.json and direct.json. For each trial in trials, check that actual matches the top-level expected. Compare seconds and input_events_per_second across trials to see how much the rate varies for the same work. Keep the command and machine conditions with the results.
3. Predict, measure, inspect
Predict what happens to trial seconds if you double --count and per-event work dominates. In both commands, try --count 200000. Save the output to new files, then compare trials and median_seconds with the original run. Repeat complete invocations to see how much timings vary. Five trials cannot establish a stable 99th percentile.
Report each population clearly. Sequential trials within one process are not independent machine deployments. The median can describe those trials, but does not erase systematic bias from CPU frequency, concurrent workloads or implementation choice. Add a CPU profiler if you need to identify where time is spent; validate the same answer when profiling.
4. Explain what is absent
| Measured here | Needs a different experiment |
|---|---|
| Verified in-process service work | Producer-to-queryable-sink latency |
| Actual Bytewax and direct-loop elapsed time | Flink task scheduling, checkpoints and state backends |
| Fixed scalar result | Payload serialization, output amplification and retained history |
| A source that emits when the pipeline can consume | Externally scheduled load, admission backlog and dropped work |
Here the source supplies more work as the pipeline consumes it. To assess backlog under sustained input, schedule arrivals independently of when processing completes. Dividing count by elapsed seconds yields input service throughput at this boundary. It does not establish sustainable distributed capacity, production availability or completed business events/s.
5. Design the real-framework investigation
For a Kafka/Flink deployment, preserve event IDs and a versioned fixture; record topic partition count and replication, client settings, operator parallelism, state storage and checkpoint settings. Schedule offered load independently of response completion, and record achieved admission. Verify IDs and values at the real sink, including unfinished work. Capture per-task skew, watermark progress, broker lag, checkpoint phase timings and external sink quotas.
Test a baseline, a controlled sink slowdown and a forced task failure. Record the last completed checkpoint, restoration time, replay, duplicate receipts, missing IDs and time to catch up. Keep the workload and correctness contract fixed when comparing changes. This plan requires a Kafka/Flink deployment, which the Python script does not create.
Independent task
A colleague claims a one-million-record native run proves the job can ingest the same rate forever. Write the missing evidence list. Then identify one case where doubling key cardinality affects retained state without changing event rate, and one case where a join changes output volume without changing input rate.
Compare your reasoning
The local run omits sustained offered load, transport/storage, state retention, output cardinality, failures and recovery. A constant-rate average hides bursts and hot keys. For the keyed-sum case, distinct keys grow state; for the join case, more matches per key grow output. A defensible result names these variables and does not extrapolate outside the measured boundary.