Test Procedure
Test the message production rate on the client side and the CPU usage on the server side in the following scenarios:
- Test scenario 1 (batch size): same Kafka instance, same topics, different batch.size settings
- Test scenario 2 (cross-AZ or intra-AZ production): same Kafka instance, same topics, different AZ settings for the client and server
- Test scenario 3 (number of replicas): same Kafka instance, different numbers of replicas
- Test scenario 4 (synchronous or asynchronous replication): same Kafka instance, topics with different replication settings
| Partitions | Replicas | Synchronous Replication Enabled | batch.size | Cross-AZ Production |
|---|---|---|---|---|
| 3 | 1 | No | 1 KB | No |
| 3 | 1 | No | 16 KB | No |
| 3 | 1 | No | 1 KB | Yes |
| 3 | 3 | Yes | 1 KB | No |
| 3 | 3 | No | 1 KB | No |
Test script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=${connection address} acks=1 batch.size=${batch.size} linger.ms=0 --topic ${topic name} --num-records ${num-records} --record-size 1024 --throughput -102400 - bootstrap.servers: address of the Kafka instance obtained in Step 1: Buy a Kafka Instance.
- acks: the message synchronization policy. acks=1 indicates asynchronous replication, and acks=-1 indicates synchronous replication.
- batch.size: size of messages sent in each batch, in bytes.
- linger.ms: interval between two batches.
- topic: topic name set in Step 2: Create Topics.
- num-records: total number of messages to be sent.
- record-size: size of each message.
- throughput: number of messages sent per second.
Test Scenario 1: Varied Batch Sizes
- Log in to the client server, go to the kafka_2.11-2.3.0/bin directory, and run the following scripts. Set batch.size to 1 KB, and run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-01 --num-records 8000000 --record-size 1024 --throughput 102400
The result is as follows:
8000000 records sent, 34128.673632 records/sec (33.33 MB/sec), 879.91 ms avg latency, 4102.00 ms max latency, 697 ms 50th, 2524 ms 95th, 2888 ms 99th, 4012 ms 99.9th.
Message production rate: 34,128 records/second
Set batch.size to 16 KB, and run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=16384 linger.ms=0 --topic Topic-01 --num-records 100000000 --record-size 1024 --throughput 102400
The result is as follows:
100000000 records sent, 102399.318430 records/sec (100.00 MB/sec), 4.72 ms avg latency, 914.00 ms max latency, 1 ms 50th, 5 ms 95th, 162 ms 99th, 398 ms 99.9th.
Message production rate: 102,399 records/second
- Log in to the Kafka console, locate the row that contains the test instance, and click
to go to the Cloud Eye console. - On the Brokers tab page, view the CPU usage of the server nodes. Figure 1 broker-0 CPU usage (batch.size = 1 KB)
CPU usage: 58.10%
Figure 2 broker-0 CPU usage (batch.size = 16 KB)
CPU usage: 24.10%
Figure 3 broker-1 CPU usage (batch.size = 1 KB)
CPU usage: 56.70%
Figure 4 broker-1 CPU usage (batch.size = 16 KB)
CPU usage: 25%
Figure 5 broker-2 CPU usage (batch.size = 1 KB)
CPU usage: 53.30%
Figure 6 broker-2 CPU usage (batch.size = 16 KB)
CPU usage: 23.30%
Test Scenario 2: Cross-AZ or Intra-AZ Production
- Log in to the client server, go to the kafka_2.11-2.3.0/bin directory, and run the following scripts.
Configure the same AZ for the client and the instance, and run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-01 --num-records 8000000 --record-size 1024 --throughput 102400
The result is as follows:
8000000 records sent, 34128.673632 records/sec (33.33 MB/sec), 879.91 ms avg latency, 4102.00 ms max latency, 697 ms 50th, 2524 ms 95th, 2888 ms 99th, 4012 ms 99.9th.
Message production rate: 34,128 records/second
Configure different AZs for the client and the instance, and run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-01 --num-records 4000000 --record-size 1024 --throughput 102400
The result is as follows:
4000000 records sent, 8523.042044 records/sec (8.32 MB/sec), 3506.20 ms avg latency, 11883.00 ms max latency, 1817 ms 50th, 10621 ms 95th, 11177 ms 99th, 11860 ms 99.9th.
Message production rate: 8523 records/second
- Log in to the Kafka console, locate the row that contains the test instance, and click
to go to the Cloud Eye console. - On the Brokers tab page, view the CPU usage of the server nodes. Figure 7 broker-0 CPU usage (same AZ)
CPU usage: 58.10%
Figure 8 broker-0 CPU usage (different AZs)
CPU usage: 17.20%
Figure 9 broker-1 CPU usage (same AZ)
CPU usage: 56.70%
Figure 10 broker-1 CPU usage (different AZs)
CPU usage: 16.70%
Figure 11 broker-2 CPU usage (same AZ)
CPU usage: 53.30%
Figure 12 broker-2 CPU usage (different AZs)
CPU usage: 18.80%
Test Scenario 3: Varied Numbers of Replicas
- Log in to the client server, go to the kafka_2.11-2.3.0/bin directory, and run the following scripts.
For the one-replica topic, run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-01 --num-records 8000000 --record-size 1024 --throughput 102400
The result is as follows:
8000000 records sent, 34128.673632 records/sec (33.33 MB/sec), 879.91 ms avg latency, 4102.00 ms max latency, 697 ms 50th, 2524 ms 95th, 2888 ms 99th, 4012 ms 99.9th.
Message production rate: 34,128 records/second
For the three-replica topic, run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-02 --num-records 4000000 --record-size 1024 --throughput 102400
The result is as follows:
4000000 records sent, 14468.325219 records/sec (14.13 MB/sec), 2069.99 ms avg latency, 7911.00 ms max latency, 846 ms 50th, 6190 ms 95th, 6935 ms 99th, 7879 ms 99.9th.
Message production rate: 14,468 records/second
- Log in to the Kafka console, locate the row that contains the test instance, and click
to go to the Cloud Eye console. - On the Brokers tab page, view the CPU usage of the server nodes. Figure 13 broker-0 CPU usage (one replica)
CPU usage: 58.10%
Figure 14 broker-0 CPU usage (three replicas)
CPU usage: 86.70%
Figure 15 broker-1 CPU usage (one replica)
CPU usage: 56.70%
Figure 16 broker-1 CPU usage (three replicas)
CPU usage: 80.60%
Figure 17 broker-2 CPU usage (one replica)
CPU usage: 53.30%
Figure 18 broker-2 CPU usage (three replicas)
CPU usage: 86.20%
Test Scenario 4: Synchronous/Asynchronous Replication
- Log in to the client server, go to the kafka_2.11-2.3.0/bin directory, and run the following scripts.
For asynchronous replication, run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=1 batch.size=1024 linger.ms=0 --topic Topic-02 --num-records 4000000 --record-size 1024 --throughput 102400
The result is as follows:
4000000 records sent, 14468.325219 records/sec (14.13 MB/sec), 2069.99 ms avg latency, 7911.00 ms max latency, 846 ms 50th, 6190 ms 95th, 6935 ms 99th, 7879 ms 99.9th.
Message production rate: 14,468 records/second
For synchronous replication, run the following script:
./kafka-producer-perf-test.sh --producer-props bootstrap.servers=192.168.0.69:9092,192.168.0.42:9092,192.168.0.66:9092 acks=-1 batch.size=1024 linger.ms=0 --topic Topic-03 --num-records 1000000 --record-size 1024 --throughput 102400
The result is as follows:
1000000 records sent, 3981.937930 records/sec (3.89 MB/sec), 7356.98 ms avg latency, 19013.00 ms max latency, 6423 ms 50th, 14381 ms 95th, 18460 ms 99th, 18975 ms 99.9th.
Message production rate: 3981 records/second
- Log in to the Kafka console, locate the row that contains the test instance, and click
to go to the Cloud Eye console. - On the Brokers tab page, view the CPU usage of the server nodes. Figure 19 broker-0 CPU usage (asynchronous replication)
CPU usage: 86.70%
Figure 20 broker-0 CPU usage (synchronous replication)
CPU usage: 60%
Figure 21 broker-1 CPU usage (asynchronous replication)
CPU usage: 80.60%
Figure 22 broker-1 CPU usage (synchronous replication)
CPU usage: 55.20%
Figure 23 broker-2 CPU usage (asynchronous replication)
CPU usage: 86.20%
Figure 24 broker-2 CPU usage (synchronous replication)
CPU usage: 50%
Last Article: Test Environment
Next Article: Test Results
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.