The microservices performance testing feature of Performance Testing Service (PTS) allows you to conduct performance testing on microservices deployed in a virtual private cloud (VPC). You can quickly conduct performance testing on microservices by performing simple configurations in the PTS console. This topic describes how to conduct performance testing on Spring Cloud microservices.
Background information
In a classic microservices architecture, each microservice is accessed by using an API gateway and is securely isolated within its own network. In most cases, cloud-based microservices are deployed in a virtual private cloud (VPC) to enhance security and ensure controlled access. However, testing the performance of a microservice in isolated environments can be difficult due to network isolation. The traditional solution is to create a performance testing tool such as JMeter within the VPC. However, setting up JMeter can be time-consuming and requires significant technical expertise, and JMeter is not user-friendly for microservices testing.
To address the preceding issues, PTS provides the microservice performance testing feature. By using simple configurations in the PTS console, you can quickly and effectively conduct performance testing on microservices.
Start the configuration
Log on to the PTS console, choose , and then click Spring Cloud.
On the Microservice Scenario page, specify the scenario name and then select the source of the tested applications, the region, and the microservices namespace.
On the Scenario Settings tab, click + Add Spring Cloud Node to add a test node to the session.
Configure the scenario
Click the icon on the right side of the business session to expand the business session and configure the basic settings, output parameter settings, and checkpoint settings.
Parameter | Description | Example |
Application Name | The name of the application. For SpringBoot applications, specify the name in the | demo-pts-service-provider |
Service name | The name of the Spring Cloud microservices. | demo-service |
Registry type | Valid values: Eureka, Direct-Connect, and Nacos. | Direct-Connect |
Node | The IP address of the registry, in the Important For Microservice Engine (MSE) users, the address of the registry depends on whether a namespace is configured.
| http://172.16.0.0:8080 |
Access Path | The request URL. | /demo |
Request Method | Valid values: GET, POST, PUT, and DELETE. You must also define headers on the Header Definition tab. If you select the POST or PUT request method, you must configure the request body. | GET |
Timeout (ms) | The maximum amount of time that a virtual user waits for a response after a request is sent. Unit: milliseconds. The default value is 1000, which is 1 second. For online business, we recommend that you specify a timeout period less than 5000 milliseconds. | 1000 |
Header settings
Configure the key-value pairs on the Header Definition tab of the business session. For more information, see Header definition.
Body settings
Configure the key-value pairs on the Body Definition tab of the business session. For more information, see Body definition.
If you select the POST or PUT request method, you must configure the request body.
Configure output parameters
On the Output Parameter Definition tab of a session, configure output parameters for the session. For more information, see Output parameters.
Configure check points
On the Check Point (Assertion) tab of a session, configure check points for the session. For more information, see Check point (assertion).
(Optional) Controllers and timers
You can add controllers and timers based on the requirements of different stress testing scenarios.
On the Scenario Settings tab, click Add Controller to select the required controller.
Loop controller: controls the number of times that a test node is executed in a loop.
Select a loop controller and click the icon next to the controller. Then, select the node to be executed in a loop and specify the number of loops. During stress testing, the specified test node in the loop controller is sequentially executed for the specified number of times.
Transaction controller: All test nodes in the transaction controller are counted as one transaction. The Generate parent sample and Include duration of timer and pre-post processors in the sample switches are displayed.
Generate parent sample:
If this switch is turned on, the stress testing results of each node in the transaction controller are not independently recorded in a stress testing report, but are aggregated as the results of the transaction controller.
If this switch is turned off, the transaction controller and the stress testing results of test nodes in the controller are displayed in the report.
Include duration of timer and pre-post processors in the sample: If this switch is turn on, the average response time of the transaction controller in the stress test report is the sum of the average response times of all test nodes, timers, and pre- and post- processors. If this switch is turn off, the average response time of the transaction controller is only the sum of the average response times of all test nodes.
Only once controller: The nodes that are added to the controller are executed only once.
On the Scenario Settings tab, click Add Timer to select the required timer.
Constant timer: specifies the pause duration, which indicates the pause duration during stress testing. Unit: milliseconds.
Synchronous timer: specifies the values of Timeout and Number of Simulated Users, which indicates that the stress testing is triggered after a specific number of users is reached within a specified time range. However, if the specific number of users is not reached within the specified time range, the testing is triggered without continuous waiting.
Unified random timer: specifies the pause duration. You can configure Constant Delay Offset and Random Delay. The Constant Delay Offset indicates a fixed pause time, and the Random Delay indicates the maximum random pause time. The pause duration of the unified random timer is the sum of the fixed pause time specified by Constant Delay Offset and the random value within the time range specified by Random Delay. Each random value has equal occurrence probability.
Gaussian timer: specifies the pause duration. The Gaussian timer is similar to the unified random timer. You can configure Constant Delay Offset and Random Delay. If the random pause time is required to conform to the normal distribution, the Gaussian timer can be used.
Fixed throughput timer: specifies the throughput so that test nodes are executed based on the throughput. You can configure conditions and specify the corresponding throughput. The conditions that you can configure include Only the current thread, All active threads, Active threads in the current link, Globally active thread, and Globally active threads in the current link.
Create a PTS scenario
Parameter | Description |
Source of Stress |
|
Stress Mode |
|
Auto Incremental Mode |
|
Max VUs | The Max VUs of the whole scenario in virtual user mode. |
Increment Percentage | In tiered increment mode, you must specify the increment percentage. |
Single Load Level Duration | In tiered increment mode, you must set the Single Load Level Duration to at least 1 minute to ensure that business issues can be found within the Single Load Level Duration. |
Total Test Duration | If the stress testing duration is incremented, the duration is greater than or equal to the value that is calculated by using the following formula: Single Load Level Duration/Incremental magnitude × 1.1 (rounded up). However, the duration cannot exceed 24 hours. |
Number of Specified IP Addresses | The number of IP addresses that apply stress. For more information, see Specify the number of IP addresses applying stress. |
Region-specific Traffic | Specifies whether to set the regions in which stress testers are located. You can turn on this switch to simulate the local user traffic. After you turn on this switch, you can configure the region distribution of stress testers. This implements the customization of the region distribution of stress traffic. For more information, see Custom traffic. |
Start a stress testing task
Click Save and Start. On the Note page, select Execute Now and The test is permitted and complies with the applicable laws and regulations. and then click Start.
To debug a scenario, click Debug. For more information, see Debug scenarios.
Analyze the stress testing results
After the stress test is complete, the system automatically obtains the stress testing data, such as the stress testing scenario metrics, business details, monitoring details, and API sampling logs, and generates a stress testing report. For more information, see View PTS stress testing reports.