Performance white paper (Nexmark benchmark)

更新时间:
复制 MD 格式

This white paper describes how to use the Nexmark benchmark test tool to evaluate the stream processing performance of Realtime Compute for Apache Flink.

Performance at a glance

Nexmark is an industry-standard performance benchmark for stream processing engines. It includes 19 standard queries that cover typical scenarios such as filtering, aggregation, joins, and windows. This paper uses the Nexmark test tool to conduct a full performance evaluation of Realtime Compute for Apache Flink with an 8 CU configuration and a baseline of 100 million input records for each query. The test results show that:

  • Simple queries, such as q0, q1, and q2, achieve an RPS of 4 million to 6.5 million records per second.

  • Complex aggregation and window queries, such as q4, q5, and q16, achieve an RPS from 150,000 to 630,000 records per second.

Overall, Realtime Compute for Apache Flink delivers 3.24 times the Nexmark performance of open source Flink.

Test tool

Nexmark is a standard performance benchmark test suite for stream processing engines. The test model is as follows:

  • Nexmark source table: Generates test data (Person, Auction, and Bid events) at a specified TPS.

  • Transformations: 19 standard Nexmark queries that cover typical scenarios such as filtering, transformation, aggregation, joins, and windows.

  • Blackhole sink table: Data is written to a blackhole sink to eliminate performance interference from external storage, allowing the evaluation to focus on the processing capability of the Flink engine itself.

The Nexmark test tool used in this paper is implemented based on the OpenAPI of Realtime Compute for Apache Flink. It automates the entire workflow, including job creation, deployment, monitoring, and result collection. You do not need to manually write SQL or create jobs in the console.

Test environment

The Flink jobs in this test used the following optimization configurations:

Parameter

Value

Description

table.exec.mini-batch.enabled

true

Enables Mini-Batch aggregation.

table.exec.mini-batch.allow-latency

2s

Mini-Batch buffering interval.

table.optimizer.distinct-agg.split.enabled

true

Enables split optimization for Distinct aggregation.

execution.checkpointing.interval

3min

Checkpoint interval.

Prerequisites

  • Java Development Kit (JDK) 1.8.x or later is installed.

  • You have activated Realtime Compute for Apache Flink and created a workspace. For more information, see Activate Realtime Compute for Apache Flink.

  • You have obtained the AccessKey ID and AccessKey Secret of your Alibaba Cloud account.

Procedure

Step 1: Download the test tool

Download and extract the Nexmark test tool package nexmark-flink.tar.gz.

The directory structure after extraction is as follows:

nexmark-flink/
├── run_nexmark.sh          # Test entry script
├── nexmark_env.sh          # Environment variable configuration file (requires editing)
├── bin/                    # Runtime scripts
├── conf/                   # Flink job configurations
├── lib/                    # JAR files (to be uploaded to the console)
└── queries-vvp/            # Nexmark Query SQL files

Step 2: Upload the Nexmark JAR

  1. Log in to the Realtime Compute for Apache Flink console.

  2. Click the target project space. In the left navigation bar, select File Management > Upload Resource.

  3. Select and upload the nexmark-flink-0.2-SNAPSHOT.jar file. The file is located in the nexmark-flink/lib directory of the test tool.

  4. After the upload is complete, click the file name to copy its OSS address. You will need this address for a later configuration step. The file path format varies by storage type:

    • OSS Bucket storage: oss://<OSS Bucket name>/artifacts/namespaces/<project space name>/<file name>

      Example: oss://oss-test/artifacts/namespaces/flink-default/nexmark-flink-0.2-SNAPSHOT.jar
    • Fully managed storage: oss://flink-fullymanaged-<workspace ID>/artifacts/namespaces/<project space name>/<file name>

      Example: oss://flink-fullymanaged-e6a123456789/artifacts/namespaces/flink-default/nexmark-flink-0.2-SNAPSHOT.jar

    To view the storage type of your workspace, go to the Realtime Compute for Apache Flink management console, find the target workspace, and click Details in the Actions column.

Step 3: Configure runtime parameters

Edit the nexmark-flink/nexmark_env.sh file and set the following parameters.

Parameter

Description

Example

END_POINT

The endpoint for Realtime Compute for Apache Flink. Select the endpoint for your region. For more information, see Endpoints.

ververica.cn-hangzhou.aliyuncs.com

AK

The AccessKey ID of your Alibaba Cloud account.

-

SK

The AccessKey Secret of your Alibaba Cloud account.

-

WORK_SPACE

The ID of your workspace.

e6a123456789

NAMESPACE

The name of your project space.

flink-default

NEXMARK_JAR

The OSS address of the JAR file that you uploaded in Step 2.

oss://flink-fullymanaged-e6a123456789/artifacts/namespaces/flink-default/nexmark-flink-0.2-SNAPSHOT.jar

FLINK_VERSION

The version of the Flink engine to be tested.

vvr-11.5-jdk11-flink-1.20

QUERIES

Specify the queries to run. Separate multiple queries with commas, for example, q0 or q1,q2,q3. To run all queries, set the value to all.

all

Note

Running all queries is time-consuming. Each query must go through stages such as job creation, data generation, and computation execution. We recommend that you first run a single query (for example, set QUERIES to q0) to verify that the environment configuration and parameter settings are correct before you run a full-scale test.

Step 4: Run the test

  1. In the nexmark-flink directory, run the following command.

    ./run_nexmark.sh
  2. The test tool automatically creates and runs the Nexmark jobs using OpenAPI.

  3. After the test is complete, the duration for each query is displayed in milliseconds. The following example shows a sample output:

    INFO  com.github.nexmark.flink.vvp.Nexmark - q0 13078
    ============================================================================
    ✓ Benchmark execution completed successfully
    ============================================================================

Performance results

The following table compares the Nexmark performance between open source Flink (1.20.4) and Realtime Compute for Apache Flink (vvr-11.5-jdk11-flink-1.20) on a configuration with 8 CUs. Each query processes an input of 100 million records. RPS = Number of input records ÷ Duration.

Note

The following test data was collected in a specific hardware environment and with specific engine versions. Actual performance may vary due to hardware upgrades and engine updates. These results are for reference only.

Query

Open source Flink on ECS

Version: 1.20.4

Realtime Compute for Apache Flink

Version: vvr-11.5-jdk11-flink-1.20

Duration (ms)

RPS

Duration (ms)

RPS

RPS vs. open source (×)

q0

58848

1,699,293

23450

4,264,392

2.51

q1

57045

1,753,002

22824

4,381,353

2.50

q2

51890

1,927,154

15224

6,568,576

3.41

q3

84986

1,176,664

21558

4,638,649

3.94

q4

553426

180,693

157117

636,468

3.52

q5

365636

273,496

357547

279,684

1.02

q7

1257452

79,526

333837

299,547

3.77

q8

79788

1,253,321

29939

3,340,125

2.67

q9

2324518

43,020

266563

375,146

8.72

q10

189985

526,357

51202

1,953,049

3.71

q11

408384

244,868

145983

685,011

2.80

q12

121554

822,680

36991

2,703,360

3.29

q14

68903

1,451,316

20012

4,997,002

3.44

q15

183709

544,339

42734

2,340,057

4.30

q16

917597

108,980

337293

296,478

2.72

q17

102847

972,318

27076

3,693,308

3.80

q18

574949

173,928

96335

1,038,044

5.97

q19

586287

170,565

95121

1,051,293

6.16

q20

1340638

74,591

231482

431,999

5.79

q21

127089

786,850

39693

2,519,336

3.20

q22

94830

1,054,519

31228

3,202,254

3.04

Total

2383209

49,695,131

9550361

15,317,480

3.24

Open source Flink test procedure

To reproduce the results on open source Flink on ECS, follow this procedure.

Environment preparation

Create a Flink cluster using EMR on ECS with the following configuration:

  • EMR version: EMR-5.21.0

  • Hardware specification: Three ecs.g6a.xlarge instances (4 vCPU / 16 GiB), including one master node and two core nodes.

  • Enable the Hadoop and HDFS services.

  • Configure passwordless login between all nodes. For example, upload your private key file (such as key.pem) to the master node. Then, add the following configuration to the ~/.ssh/config file on the master node. Replace the IP addresses and file path with your actual values.

    Host 192.168.0.0
        HostName 192.168.0.0
        User root
        IdentityFile /path/to/key.pem
        StrictHostKeyChecking no
    Host 192.168.0.1
        HostName 192.168.0.1
        User root
        IdentityFile /path/to/key.pem
        StrictHostKeyChecking no
    Host 192.168.0.2
        HostName 192.168.0.2
        User root
        IdentityFile /path/to/key.pem
        StrictHostKeyChecking no
    Use ssh to verify that passwordless login between the nodes is working correctly. If a "bad permissions" error occurs, run chmod 600 /path/to/key.pem to correct the permissions.

Software preparation

  1. Download the target Flink package (Apache Flink Downloads) and the Nexmark test package (nexmark-flink.tgz). Upload the packages to the master node and extract them.

    tar -zxvf flink-1.20.4-bin-scala_2.12.tgz
    tar -zxvf nexmark-flink.tgz
    mv flink-1.20.4 flink
    mv nexmark-flink nexmark
  1. Copy the JAR files in the nexmark/lib directory to flink/lib. These JARs contain the Nexmark data generator.

    cp nexmark/lib/* flink/lib/
  1. Set the environment variables. Edit ~/.bashrc, add the following configuration, and then run source ~/.bashrc for the changes to take effect.

    Configure the paths based on your actual environment.
    export JAVA_HOME=/etc/alternatives/java_sdk_11
    export PATH=$JAVA_HOME/bin:$PATHexport FLINK_HOME=/mnt/disk1/flink
    export HADOOP_CLASSPATH=$(/opt/apps/HADOOP-COMMON/hadoop-common-current/bin/hadoop classpath)
  1. Configure Flink workers. This test uses eight TaskManagers, deployed as follows: two on the master node and three on each core node.

    Edit flink/conf/workers, making sure to replace the IP address with the actual value.

    192.168.0.0
    192.168.0.0
    192.168.0.1
    192.168.0.1
    192.168.0.1
    192.168.0.2
    192.168.0.2
    192.168.0.2
  1. Replace flink/conf/config.yaml with nexmark/conf/config.yaml, and update the following configuration items:

    • jobmanager.rpc.address: The IP address of the master node, such as 192.168.0.0.

    • state.checkpoints.dir: The HDFS path, such as hdfs:///checkpoints

    • taskmanager.memory.process.size: 4G

  1. Edit nexmark/conf/nexmark.yaml and set nexmark.metric.reporter.host to the IP address of the master node.

  2. Distribute the flink and nexmark directories and environment variable configurations to each core node.

    Replace the IP addresses with your actual values.
    scp -r flink 192.168.0.1:/mnt/disk1/
    scp -r flink 192.168.0.2:/mnt/disk1/
    scp -r nexmark 192.168.0.1:/mnt/disk1/
    scp -r nexmark 192.168.0.2:/mnt/disk1/
    scp ~/.bashrc 192.168.0.1:~/
    scp ~/.bashrc 192.168.0.2:~/

    After the distribution is complete, run source ~/.bashrc on each core node to make the environment variables take effect.

  1. On the master node, start the Flink cluster.

    flink/bin/start-cluster.sh
  1. Initialize the Nexmark test environment. This script configures the required Metric Reporter on each node.

    nexmark/bin/setup_cluster.sh

Set resource limits

After the Flink cluster starts, you must use cgroups to limit the CPU usage of each TaskManager process to 75%. This prevents TaskManagers from losing connection due to heartbeat timeouts caused by resource contention.

Run the following commands on all nodes where TaskManagers are running, including the master node:

yum install -y libcgroup libcgroup-tools
cgcreate -t root:root -a root:root -g cpu,memory:mygroup
echo 100000 > /sys/fs/cgroup/cpu/mygroup/cpu.cfs_period_us
echo 300000 > /sys/fs/cgroup/cpu/mygroup/cpu.cfs_quota_us
echo $((12 * 1024 * 1024 * 1024)) > /sys/fs/cgroup/memory/mygroup/memory.limit_in_bytes
jps | grep TaskManagerRunner | awk '{print $1}' | xargs cgclassify -g cpu,memory:mygroup

Here, cpu.cfs_quota_us / cpu.cfs_period_us = 300000 / 100000 = 3, which means the cgroup can use a maximum of 3 CPU cores (75% of 4 vCPUs).

Note

In the fully managed environment of Realtime Compute for Apache Flink, you do not need to manually set a resource usage limit. The service fully utilizes your purchased compute resources.

Run Nexmark

On the master node, run the following command and wait for it to complete to view the results:

nexmark/bin/run_query.sh q0,q1,q2,q3,q4,q5,q7,q8,q9,q10,q11,q12,q14,q15,q16,q17,q18,q19,q20,q21,q22