You can use the performance profiling feature to detect the performance ceiling, specifically the maximum queries per second (QPS), of a single instance. During performance profiling, stress tests are performed to generate performance profiles, based on which you can obtain the optimal instance specifications and concurrency settings that meet your end-to-end latency requirements. This topic describes how to perform performance profiling in the Function Compute console and view profiling results.
Limits
You can perform a stress test only on one instance at a time.
Stress tests are not supported for GPU functions.
Billing
You are not charged for the performance profiling feature. However, you are charged for function invocation requests generated during stress tests in the same way as regular function invocation requests. Each time you create a stress test task, the estimated fees are displayed on the page. For information about the billing of requests, see Billing overview.
Prerequisites
The function to be tested is created. For more information, see Create a function.
Alibaba Cloud Performance Testing (PTS) is activated and the service-linked role AliyunServiceRoleForPts is created. For more information, see Performance testing.
Procedure
Log on to the Function Compute console. In the left-side navigation pane, click Functions.
In the top navigation bar, select a region. On the Functions page, click the function that you want to manage.
On the Performance Profiling tab of the function details page, click Create Stress Test Task.
In the Single-instance Stress Test step, enter the required information about the stress test API before you click Perform Stress Test.
ImportantBefore you click Perform Stress Test, click Test API to test whether the function can be executed as expected. If the function execution test fails, the stress test cannot run as expected. Therefore, make sure that the function code is correct and the HTTP request parameters of the stress test API are correctly configured before you start the stress test.
The following table describes the parameters.
Parameter
Description
Stress Test Function
The function on which you want to perform the stress test. By default, the current function is selected. You cannot change the value of this parameter.
Test Domain
The test domain name that is used to perform the stress test. Make sure that you have created an HTTP trigger for the function. Otherwise, you cannot test the API.
If no HTTP trigger is created for any version of the function, click Create HTTP Trigger. In the Create HTTP Trigger panel, retain the default values for the parameters and click OK.
Function Specifications
The function specifications. The duration of the stress test increases in accordance with the number of specifications you specify. You can specify custom vCPU and memory specifications.
Estimated Cost
The estimated fee for function invocations generated during the stress test. The fee is automatically calculated by the system.
NoteThis estimated fee includes only the fee of function invocations. If your functions use other services such as databases, extra charges may incur.
Stress Test Method
The method to trigger the function. Options: GET, POST, PUT, and DELETE.
Stress Test Path
The path of HTTP requests.
Maximum Tolerable End-to-end Latency
The maximum tolerable end-to-end latency. After the test, Function Compute recommends optimal instance specifications and concurrency settings based on the values of Maximum Tolerable End-to-end Latency and Expected QPS. Optimal concurrency settings are recommended only for functions that run in custom runtimes.
You must specify at least one of the Maximum Tolerable End-to-End Latency and Expected QPS parameters.
Expected QPS
The single-instance throughput of the function. After the test, Function Compute recommends optimal instance specifications and concurrency settings based on the values of Maximum Tolerable End-to-end Latency and Expected QPS. Optimal concurrency settings are recommended only for functions that run in custom runtimes.
You must specify at least one of the Maximum Tolerable End-to-End Latency and Expected QPS parameters.
In the Result Analysis of Single-instance Stress Test step, view the stress test results.
During the stress test, the estimated completion time of the stress test is displayed. The duration and costs of the stress test increase in accordance with the number of specifications you specify.
After the stress test is complete, information including the start time, end time, duration, status, end-to-end latency, and single-instance throughput are displayed.
The stress test results include the recommended instance specifications and concurrency settings. Optimal concurrency settings are recommended only for functions that run in custom runtimes. You can also view the analysis process in the charts below the stress test results. The following figure shows the variations in QPS and response time (RT) across different instance specifications, as well as shifts incurred by increasing concurrency based on a recommended instance specification.
NoteYou can perform a stress test only on one instance at a time in Function Compute. If you want to perform a stress test on multiple instances, click Stress Test of Multi-instance Elasticity on the right side of the Result Analysis of Single-instance Stress Test page to go to the PTS console.
Click View Details of Single-instance Stress Test to go to the Detailed Data of Single-instance Stress Test step to view the stress test details of each specification. In the stress test details of each specification, you can observe the changes in latency and maximum QPS as the concurrency increases.
NoteFor functions that run in non-custom runtimes, details are displayed in text instead of charts because the concurrency values cannot be adjusted.
FAQ
Are the recommended optimal specifications and concurrency in the stress test results absolutely accurate?
The recommended concurrency and specification values of each stress test can serve as a reference for evaluating the performance of the function with different specifications. However, these values may not be absolutely accurate. You can choose the optimal specifications and concurrency settings based on your business requirements.
If you want to obtain results of higher accuracy, you can submit multiple stress test tasks and use the average recommended values.
What do I do if a stress test fails or request errors frequently occur?
If an error message that indicates the stress test fails is returned, check the configurations of the stress test API based on the cause of the error.