|
| 1 | +--- |
| 2 | +title: Benchmarking with Official Kafka Tools |
| 3 | +weight: 6 |
| 4 | + |
| 5 | +### FIXED, DO NOT MODIFY |
| 6 | +layout: learningpathall |
| 7 | +--- |
| 8 | + |
| 9 | +## Benchmark Kafka on Azure Cobalt 100 Arm-based instances and x86_64 instances |
| 10 | + |
| 11 | +Kafka’s official performance tools (**kafka-producer-perf-test.sh** and **kafka-consumer-perf-test.sh**) let you generate test workloads, measure message throughput, and record end-to-end latency. |
| 12 | + |
| 13 | +## Steps for Kafka Benchmarking |
| 14 | + |
| 15 | +Before starting the benchmark, ensure that the **Kafka broker** are already running in separate terminals. |
| 16 | + |
| 17 | +Now, open two new terminals—one for the **producer benchmark** and another for the **consumer benchmark**. |
| 18 | + |
| 19 | +### Terminal A - Producer Benchmark |
| 20 | + |
| 21 | +The producer benchmark measures how fast Kafka can send messages, reporting throughput and latency percentiles. |
| 22 | + |
| 23 | +```console |
| 24 | +cd /opt/kafka |
| 25 | +bin/kafka-producer-perf-test.sh \ |
| 26 | + --topic test-topic-kafka \ |
| 27 | + --num-records 1000000 \ |
| 28 | + --record-size 100 \ |
| 29 | + --throughput -1 \ |
| 30 | + --producer-props bootstrap.servers=localhost:9092 |
| 31 | +``` |
| 32 | +You should see output similar to: |
| 33 | + |
| 34 | +```output |
| 35 | +1000000 records sent, 252589.0 records/sec (24.09 MB/sec), 850.85 ms avg latency, 1219.00 ms max latency, 851 ms 50th, 1184 ms 95th, 1210 ms 99th, 1218 ms 99.9th. |
| 36 | +``` |
| 37 | +### Terminal B - Consumer benchmark |
| 38 | + |
| 39 | +The consumer benchmark measures how fast Kafka can read messages from the topic, reporting throughput and total messages consumed. |
| 40 | + |
| 41 | +```console |
| 42 | +cd /opt/kafka |
| 43 | +bin/kafka-consumer-perf-test.sh \ |
| 44 | + --topic test-topic-kafka \ |
| 45 | + --bootstrap-server localhost:9092 \ |
| 46 | + --messages 1000000 \ |
| 47 | + --timeout 30000 \ |
| 48 | + --threads 1 |
| 49 | +``` |
| 50 | +You should see output similar to: |
| 51 | + |
| 52 | +```output |
| 53 | +start.time, end.time, data.consumed.in.MB, MB.sec, data.consumed.in.nMsg, nMsg.sec, rebalance.time.ms, fetch.time.ms, fetch.MB.sec, fetch.nMsg.sec |
| 54 | +2025-09-03 06:07:13:616, 2025-09-03 06:07:17:545, 95.3674, 24.2727, 1000001, 254517.9435, 3354, 575, 165.8564, 1739132.1739 |
| 55 | +``` |
| 56 | + |
| 57 | +## Benchmark Results Table Explained: |
| 58 | + |
| 59 | +- **Messages Processed** – Total number of messages handled during the test. |
| 60 | +- **Records/sec** – Rate of messages sent or consumed per second. |
| 61 | +- **MB/sec** – Data throughput in megabytes per second. |
| 62 | +- **Avg Latency (ms)** – Average delay in sending messages (producer only). |
| 63 | +- **Max Latency (ms)** – Longest observed delay in sending messages (producer only). |
| 64 | +- **50th (ms)** – Median latency (half the messages were faster, half slower). |
| 65 | +- **95th (ms)** – Latency below which 95% of messages were delivered. |
| 66 | +- **99th (ms)** – Latency below which 99% of messages were delivered. |
| 67 | +- **99.9th (ms)** – Latency below which 99.9% of messages were delivered. |
| 68 | + |
| 69 | +## Benchmark summary on Arm64: |
| 70 | + |
| 71 | +Here is a summary of benchmark results collected on an Arm64 **D4ps_v6 Ubuntu virtual machine**. |
| 72 | + |
| 73 | +### Consumer Performance Test |
| 74 | + |
| 75 | +| Metric | Value | Unit | |
| 76 | +|-----------------------------|-------------|---------------| |
| 77 | +| Total Time Taken | 3.929 | Seconds | |
| 78 | +| Data Consumed | 95.3674 | MB | |
| 79 | +| Throughput (Data) | 24.2727 | MB/sec | |
| 80 | +| Messages Consumed | 1,000,001 | Messages | |
| 81 | +| Throughput (Messages) | 254,517.94 | Messages/sec | |
| 82 | +| Rebalance Time | 3354 | Milliseconds | |
| 83 | +| Fetch Time | 575 | Milliseconds | |
| 84 | +| Fetch Throughput (Data) | 165.8564 | MB/sec | |
| 85 | +| Fetch Throughput (Messages)| 1,739,132.17| Messages/sec | |
| 86 | + |
| 87 | +### Producer Performance Test |
| 88 | + |
| 89 | +| Metric | Records Sent | Records/sec | Throughput | Average Latency | Maximum Latency | 50th Percentile Latency | 95th Percentile Latency | 99th Percentile Latency | 99.9th Percentile Latency | |
| 90 | +|--------|--------------|-------------|------------|-----------------|-----------------|-------------------------|-------------------------|-------------------------|---------------------------| |
| 91 | +| Value | 1,000,000 | 252,589.0 | 24.09 | 850.85 | 1219.00 | 851 | 1184 | 1210 | 1218 | |
| 92 | +| Unit | Records | Records/sec | MB/sec | ms | ms | ms | ms | ms | ms | |
| 93 | + |
| 94 | +## Benchmark summary on x86_64: |
| 95 | +Here is a summary of the benchmark results collected on x86_64 **D4s_v6 Ubuntu virtual machine**. |
| 96 | + |
| 97 | +### Consumer Performance Test |
| 98 | + |
| 99 | +| Metric | Value | Unit | |
| 100 | +|-----------------------------|-------------|---------------| |
| 101 | +| Total Time Taken | 3.828 | Seconds | |
| 102 | +| Data Consumed | 95.3674 | MB | |
| 103 | +| Throughput (Data) | 24.9131 | MB/sec | |
| 104 | +| Messages Consumed | 1,000,001 | Messages | |
| 105 | +| Throughput (Messages) | 261,233.28 | Messages/sec | |
| 106 | +| Rebalance Time | 3244 | Milliseconds | |
| 107 | +| Fetch Time | 584 | Milliseconds | |
| 108 | +| Fetch Throughput (Data) | 163.3004 | MB/sec | |
| 109 | +| Fetch Throughput (Messages) | 1,712,330.48| Messages/sec | |
| 110 | + |
| 111 | +### Producer Performance Test |
| 112 | + |
| 113 | +| Metric | Records Sent | Records/sec | Throughput | Average Latency | Maximum Latency | 50th Percentile Latency | 95th Percentile Latency | 99th Percentile Latency | 99.9th Percentile Latency | |
| 114 | +|--------|--------------|-------------|------------|-----------------|-----------------|-------------------------|-------------------------|-------------------------|---------------------------| |
| 115 | +| Value | 1,000,000 | 244,200.2 | 23.29 | 857.17 | 1162.00 | 907 | 1131 | 1152 | 1160 | |
| 116 | +| Unit | Records | Records/sec | MB/sec | ms | ms | ms | ms | ms | ms | |
| 117 | + |
| 118 | +## Benchmark comparison insights |
| 119 | + |
| 120 | +When comparing the results on Arm64 vs x86_64 virtual machines: |
| 121 | + |
| 122 | +- The Kafka **consumer** achieved ~24.27 MB/sec throughput, processing ~254K messages per second. |
| 123 | +- The Kafka **producer** sustained ~24.09 MB/sec throughput, with an average latency of ~851 ms and a peak latency of ~1219 ms. |
| 124 | +- These results confirm stable Kafka performance on the Azure Ubuntu Arm64 Virtula machine, suitable for baseline validation and benchmarking. |
| 125 | + |
| 126 | +You have now benchmarked Kafka on an Azure Cobalt 100 Arm64 virtual machine and compared results with x86_64. |
0 commit comments