|
| 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 | +``` |
| 49 | +You should see output similar to: |
| 50 | + |
| 51 | +```output |
| 52 | +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 |
| 53 | +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 |
| 54 | +``` |
| 55 | + |
| 56 | +## Benchmark Results Table Explained: |
| 57 | + |
| 58 | +- **Messages Processed** – Total number of messages handled during the test. |
| 59 | +- **Records/sec** – Rate of messages sent or consumed per second. |
| 60 | +- **MB/sec** – Data throughput in megabytes per second. |
| 61 | +- **Avg Latency (ms)** – Average delay in sending messages (producer only). |
| 62 | +- **Max Latency (ms)** – Longest observed delay in sending messages (producer only). |
| 63 | +- **50th (ms)** – Median latency (half the messages were faster, half slower). |
| 64 | +- **95th (ms)** – Latency below which 95% of messages were delivered. |
| 65 | +- **99th (ms)** – Latency below which 99% of messages were delivered. |
| 66 | +- **99.9th (ms)** – Latency below which 99.9% of messages were delivered. |
| 67 | + |
| 68 | +## Benchmark summary on Arm64: |
| 69 | +Here is a summary of benchmark results collected on an Arm64 **D4ps_v6 Ubuntu Pro 24.04 LTS virtual machine**. |
| 70 | +### Consumer Performance Test |
| 71 | +| Metric | Value | Unit | |
| 72 | +|-----------------------------|-------------|---------------| |
| 73 | +| Total Time Taken | 3.875 | Seconds | |
| 74 | +| Data Consumed | 95.3674 | MB | |
| 75 | +| Throughput (Data) | 24.6110 | MB/sec | |
| 76 | +| Messages Consumed | 1,000,001 | Messages | |
| 77 | +| Throughput (Messages) | 258,064.77 | Messages/sec | |
| 78 | +| Rebalance Time | 3348 | Milliseconds | |
| 79 | +| Fetch Time | 527 | Milliseconds | |
| 80 | +| Fetch Throughput (Data) | 180.9629 | MB/sec | |
| 81 | +| Fetch Throughput (Messages)| 1,897,535.10| Messages/sec | |
| 82 | + |
| 83 | +### Producer Performance Test |
| 84 | +| Metric | Records Sent | Records/sec | Throughput | Average Latency | Maximum Latency | 50th Percentile Latency | 95th Percentile Latency | 99th Percentile Latency | 99.9th Percentile Latency | |
| 85 | +|--------|--------------|-------------|------------|-----------------|-----------------|-------------------------|-------------------------|-------------------------|---------------------------| |
| 86 | +| Value | 1,000,000 | 257,532.8 | 24.56 | 816.19 | 1237.00 | 799 | 1168 | 1220 | 1231 | |
| 87 | +| Unit | Records | Records/sec | MB/sec | ms | ms | ms | ms | ms | ms | |
| 88 | + |
| 89 | +## Benchmark summary on x86_64: |
| 90 | +Here is a summary of the benchmark results collected on x86_64 **D4s_v6 Ubuntu Pro 24.04 LTS virtual machine**. |
| 91 | +### Consumer Performance Test |
| 92 | +| Metric | Value | Unit | |
| 93 | +|--------------------|-------------|---------------| |
| 94 | +| Total Time Taken | 3.811 | Seconds | |
| 95 | +| Data Consumed | 95.3674 | MB | |
| 96 | +| Throughput (Data) | 25.0243 | MB/sec | |
| 97 | +| Messages Consumed | 1,000,001 | Messages | |
| 98 | +| Throughput (Messages) | 262,398.58 | Messages/sec | |
| 99 | +| Rebalance Time | 3271 | Milliseconds | |
| 100 | +| Fetch Time | 540 | Milliseconds | |
| 101 | +| Fetch Throughput (Data) | 176.6064 | MB/sec | |
| 102 | +| Fetch Throughput (Messages) | 1,851,853.70| Messages/sec | |
| 103 | + |
| 104 | +### Producer Performance Test |
| 105 | +| Metric | Records Sent | Records/sec | Throughput | Average Latency | Maximum Latency | 50th Percentile Latency | 95th Percentile Latency | 99th Percentile Latency | 99.9th Percentile Latency | |
| 106 | +|--------|--------------|-------------|------------|-----------------|-----------------|-------------------------|-------------------------|-------------------------|---------------------------| |
| 107 | +| Value | 1,000,000 | 242,013.6 | 23.08 | 840.69 | 1351.00 | 832 | 1283 | 1330 | 1350 | |
| 108 | +| Unit | Records | Records/sec | MB/sec | ms | ms | ms | ms | ms | ms | |
| 109 | + |
| 110 | +## Benchmark comparison insights |
| 111 | +When comparing the results on Arm64 vs x86_64 virtual machines: |
| 112 | + |
| 113 | + |
| 114 | +- The Kafka **consumer** achieved **25.02 MB/sec throughput**, processing ~**262K messages/sec** with fetch throughput exceeding **1.85M messages/sec**. |
| 115 | +- The Kafka **producer** sustained **23.08 MB/sec throughput**, with an average latency of ~**841 ms** and peak latency of ~**1351 ms**. |
| 116 | +- These results confirm stable Kafka performance on the **Azure Ubuntu Pro arm64 virtual machine**, validating its suitability for **baseline testing and benchmarking**. |
| 117 | + |
| 118 | +You have now benchmarked Kafka on an Azure Cobalt 100 Arm64 virtual machine and compared results with x86_64. |
0 commit comments