All Products
Search
Document Center

Performance Testing:Conduct performance testing on Spring Cloud microservices

Last Updated:Nov 01, 2024

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

  1. Log on to the PTS console, choose Performance Test > Create Scenario, and then click Spring Cloud.

  2. On the Microservice Scenario page, specify the scenario name and then select the source of the tested applications, the region, and the microservices namespace.

  3. On the Scenario Settings tab, click + Add Spring Cloud Node to add a test node to the session.

Configure the scenario

Click the ryi 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 spring.application.name format.

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 http://[ip]:[port] format or the [ip]:[port] format.

Important

For Microservice Engine (MSE) users, the address of the registry depends on whether a namespace is configured.

  • If no namespace is configured, the default namespace DEFAULT_GROUP is used. Directly enter the registry address. Example: XXX.nacos-ans.mse.aliyuncs.com:8848.

  • If a namespace is configured, the registry address is in the format of the registry address plus the ID of the namespace. For example, if the ID of the namespace is abc, the registry address is in the following format: XXX.nacos-ans.mse.aliyuncs.com:8848?namespaceId=abc.

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.

Note

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

  • Internet: Nodes that initiate the stress testing are located around the world. The corresponding node resources (IP addresses) are allocated based on the magnitude of the stress testing.

  • Alibaba Cloud virtual private clouds (VPCs): The stress testing in an Alibaba Cloud VPC is performed over the VPC. In the stress testing, the stress testers and the tested servers are located in the same region. For more information, see Stress testing in Alibaba Cloud VPCs.

Stress Mode

  • Virtual user mode: If you want to know the number of online users that can be hosted by each node in the business system from the client perspective, you can use this mode to configure the target virtual users.

  • Requests per second (RPS) mode: The RPS mode is the throughput mode. This mode allows you to specify RPS to measure the throughput capabilities of your system from the server perspective, eliminates the cumbersome conversion from the virtual user mode to the RPS mode, and quickly implements the stress testing.

Auto Incremental Mode

  • Manual Adjustment: The number of virtual users is fixed. The corresponding stress prediction chart is a flat line that indicates the number of virtual users. The stress testing is always performed based on the specific number of virtual users.

  • Tiered Increment: The number of virtual users is stepwise increased. This means that the number of virtual users that apply stress to a system has the tiered increment. The number of virtual users increases by a value within each period of time until an expected number of virtual users is reached. Then, the reached number of virtual users is maintained for a period of time. The corresponding stress prediction chart is a graph in the step form.

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.