Updated on 2024-05-24 GMT+08:00

Kafka Instance TPS

Scenarios

TPS tests can be performed in the following scenarios:

  • Scenario 1 (whether SASL is enabled): same topic, different SASL settings
  • Scenario 2 (synchronous or asynchronous replication): same instance, topics with different replication settings
  • Scenario 3 (synchronous or asynchronous flushing): same instance, topics with different flushing settings
  • Scenario 4 (disk type): same topic, instances with different disk types
  • Scenario 5 (number of partitions): same instance, topics with different number of partitions

Environment

Perform the following steps to set up the test environment.

  1. Purchase Kafka instances with parameters specified in Table 1. For more information, see Buying a Kafka Instance.
    Table 1 Instance parameters

    Instance Name

    Brokers

    Broker Flavor

    SASL

    Storage space per broker

    kafka-01

    3

    kafka.2u4g.cluster

    Yes

    Ultra-high I/O

    kafka-02

    3

    kafka.4u8g.cluster

    Yes

    Ultra-high I/O

    kafka-03

    3

    kafka.8u16g.cluster

    Yes

    Ultra-high I/O

    kafka-04

    3

    kafka.12u24g.cluster

    Yes

    Ultra-high I/O

    kafka-05

    3

    kafka.16u32g.cluster

    Yes

    Ultra-high I/O

    kafka-06

    3

    kafka.2u4g.cluster

    No

    Ultra-high I/O

    kafka-07

    3

    kafka.4u8g.cluster

    No

    Ultra-high I/O

    kafka-08

    3

    kafka.8u16g.cluster

    No

    Ultra-high I/O

    kafka-09

    3

    kafka.12u24g.cluster

    No

    Ultra-high I/O

    kafka-10

    3

    kafka.16u32g.cluster

    No

    Ultra-high I/O

    kafka-11

    3

    kafka.2u4g.cluster

    No

    High I/O

    kafka-12

    3

    kafka.4u8g.cluster

    No

    High I/O

    kafka-13

    3

    kafka.8u16g.cluster

    No

    High I/O

    kafka-14

    3

    kafka.12u24g.cluster

    No

    High I/O

    kafka-15

    3

    kafka.16u32g.cluster

    No

    High I/O

  2. Create topics with parameters specified in Table 2 for each instance purchased above. For details about how to create topics, see Creating a Kafka Topic.
    Table 2 Topic parameters

    Topic Name

    Synchronous Replication

    Synchronous Flushing

    Replicas

    Partitions

    topic-01

    No

    No

    3

    30

    topic-02

    Yes

    No

    3

    30

    topic-03

    No

    Yes

    3

    30

    topic-04

    No

    No

    3

    3

    topic-05

    No

    No

    3

    12

    topic-06

    No

    No

    3

    100

  3. Obtain the test tool.

    Obtain Kafka CLI v2.7.2.

  4. Purchase a server for the client.

    Buy a Linux ECS (with the same region, AZ, VPC, subnet, and security group as the Kafka instance). For details about how to purchase an ECS, see Purchasing an ECS.

    Perform the following operations on the ECSs:

    • Install Java JDK and configure the environment variables JAVA_HOME and PATH.
      export JAVA_HOME=/root/jdk1.8.0_231 
      export PATH=$JAVA_HOME/bin:$PATH
    • Download Kafka CLI v2.7.2 and decompress it.
      tar -zxf kafka_2.12-2.7.2.tgz

Script

./kafka-producer-perf-test.sh --producer-props bootstrap.servers=${connection address} acks=1 batch.size=16384 linger.ms=10 --topic ${topic name} --num-records 10000000 --record-size 1024 --throughput -1 --producer.config ../config/producer.properties
  • bootstrap.servers: address of the Kafka instance obtained in 1.
  • acks: 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 2.
  • num-records: total number of messages to be sent.
  • record-size: size of each message.
  • throughput: number of messages sent per second.

Result

Scenario 1 (whether SASL is enabled): same topic (30 partitions, 3 replicas, asynchronous replication, and asynchronous flushing), instances with SASL enabled or disabled. The test result is as follows.

Table 3 Test results

Instance Flavor

Storage space per broker

Brokers

TPS (SASL Enabled)

TPS (SASL Disabled)

kafka.2u4g.cluster

Ultra-high I/O

3

100,000

280,000

kafka.4u8g.cluster

Ultra-high I/O

3

170,000

500,000

kafka.8u16g.cluster

Ultra-high I/O

3

200,000

730,000

kafka.12u24g.cluster

Ultra-high I/O

3

320,000

790,000

kafka.16u32g.cluster

Ultra-high I/O

3

360,000

1,000,000

Scenario 2 (synchronous/asynchronous replication): same instance (ultra-high I/O, three brokers, SASL disabled), topics with different replication settings, and number of producer processes is three. The test result is as follows.

Table 4 Test results

Instance Flavor

Synchronous Flushing

Replicas

Partitions

TPS (Synchronous Replication)

TPS (Asynchronous Replication)

kafka.2u4g.cluster

No

3

30

100,000

292,000

kafka.4u8g.cluster

No

3

30

230,000

496,000

kafka.8u16g.cluster

No

3

30

342,000

766,000

kafka.12u24g.cluster

No

3

30

383,000

802,000

kafka.16u32g.cluster

No

3

30

485,000

1,080,000

Scenario 3 (synchronous/asynchronous replication flushing): same instance (ultra-high I/O, three brokers, SASL disabled), topics with different flushing settings. The test result is as follows.

Table 5 Test results

Instance Flavor

Synchronous Replication

Replicas

Partitions

TPS (Synchronous Flushing)

TPS (Asynchronous Flushing)

kafka.2u4g.cluster

No

3

30

30,000

280,000

kafka.4u8g.cluster

No

3

30

32,500

500,000

kafka.8u16g.cluster

No

3

30

36,100

730,000

kafka.12u24g.cluster

No

3

30

37,400

790,000

kafka.16u32g.cluster

No

3

30

40,400

1,000,000

Scenario 4 (different disk types): same topic (30 partitions, 3 replicas, asynchronous replication, and asynchronous flushing) with different disk types. The test result is as follows.

Table 6 Test results

Instance Flavor

Brokers

SASL

TPS (High I/O)

TPS (Ultra-High I/O)

kafka.2u4g.cluster

3

No

110,000

250,000

kafka.4u8g.cluster

3

No

135,000

380,000

kafka.8u16g.cluster

3

No

213,000

480,000

kafka.12u24g.cluster

3

No

240,000

577,000

kafka.16u32g.cluster

3

No

280,000

840,000

Scenario 5 (different numbers of partitions): same instance (ultra-high I/O, three brokers, SASL disabled), topics with different number of partitions. The test result is as follows.

Table 7 Test results

Instance Flavor

Synchronous Flushing

Synchronous Replication

Replicas

TPS (3 Partitions)

TPS (12 Partitions)

TPS (100 Partitions)

kafka.2u4g.cluster

No

No

3

250,000

260,000

250,000

kafka.4u8g.cluster

No

No

3

330,000

280,000

260,000

kafka.8u16g.cluster

No

No

3

480,000

410,000

340,000

kafka.12u24g.cluster

No

No

3

570,000

750,000

520,000

kafka.16u32g.cluster

No

No

3

840,000

1,000,000

630,000