Deployment and Maintenance / Benchmark Performance Testing
This Guide mainly introduces how to perform benchmark performance testing on DataFlux Func.
1. Preface
All example results in this Guide were tested in the following hardware environment:
Description | |
---|---|
Computer | HP ProBook Laptop |
CPU | AMD Ryzen 5 7530U with Radeon Graphics / 4.5 GHz |
Memory | 32 GB / 3200 MHz (0.3 ns) |
Operating System | Ubuntu 22.04.5 LTS |
2. Benchmark Testing Package
Download Benchmark.zip and import it into DataFlux Func.
The Benchmark testing package contains the following:
Content | Description |
---|---|
Script Set benchmark |
|
Function benchmark__main.hello_world |
A function that directly returns "ok" , used for concurrency testing |
Function benchmark__main.json_dump |
Performs JSON serialization / deserialization, used for performance testing |
Function benchmark__main.calc_pi |
Calculates pi, used for performance testing |
Sync API benchmark-hello-world |
Used for concurrency testing |
Cron Job benchmark-hello-world |
Used to test task scheduling performance |
Cron Job benchmark-compute-pi |
Used to test computational performance (calculating pi) |
Cron Job benchmark-json-dump-and-load |
Used to test computational performance (JSON serialization / deserialization) |
3. Executing Tests
After importing the Benchmark testing package, since Cron Jobs run automatically, you can view the results in the task records after a few minutes.
However, concurrency performance testing for DataFlux Func requires the use of other tools.
3.1 Testing Task Scheduling Performance
After importing the Benchmark testing package, wait a few minutes and then view the results in the "Hello, World" task record under "Cron Jobs".
Generally, each task should take less than 10 milliseconds.
3.2 Testing Computational Performance
After importing the Benchmark testing package, wait a few minutes and then view the results in the "Compute pi" and "JSON dump and load" task records under "Cron Jobs".
In the test environment mentioned in the "Preface", each task takes around 1 second:
- Calculating pi "Compute pi"
- JSON serialization / deserialization "JSON dump and load"
3.3 Testing Func API Concurrency Performance
For concurrency performance testing, you can use the ab (ApacheBench) tool.
If ab is not installed, you can install it using the following commands:
Bash | |
---|---|
1 |
|
Bash | |
---|---|
1 |
|
Use ab to test the "Hello, World" function in the testing package with the following command:
Bash | |
---|---|
1 |
|
Bash | |
---|---|
1 |
|
In the test environment mentioned in the "Preface", the concurrency of the empty function is around 1000 (Requests per second):
ab test output | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
4. Factors Affecting Performance
Since the actual execution content of tasks is determined by the scripts being called, if tasks take a long time to execute, you can check if the following issues exist in the code:
4.1 Excessive print(...)
For debugging convenience, some may directly output data from the DB or API responses using print(...)
.
Since DataFlux Func automatically records print(...)
content during task execution, this can lead to significant performance degradation.
It is recommended to keep only necessary print(...)
outputs in production code and avoid large text outputs.
4.2 Slow External System Responses
When querying external databases or calling API interfaces (including executing DQL queries) in scripts, network delays or slow responses from the external system can also cause tasks to take a long time to execute.
This is not related to DataFlux Func, and you should contact the responsible parties of these external systems to improve response speed.
Here is a simple example code to test processing time:
Python | |
---|---|
1 2 3 4 5 6 7 |
|