Skip to content

Commit 01eb64e

Browse files
authored
Merge pull request #277964 from ninallam/ninallam-optimizer
Performance optimizer
2 parents ee42c53 + 8bf2cdb commit 01eb64e

File tree

5 files changed

+126
-0
lines changed

5 files changed

+126
-0
lines changed
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
---
2+
title: Optimize Azure Functions for performance and cost
3+
titleSuffix: Azure Load Testing
4+
description: Learn how to optimize Azure Functions for Performance and Costs using Azure Load Testing
5+
services: load-testing
6+
ms.service: load-testing
7+
ms.author: ninallam
8+
author: ninallam
9+
ms.date: 06/12/2024
10+
ms.topic: how-to
11+
---
12+
13+
# Optimize Azure Functions for Performance and Costs using Azure Load Testing
14+
15+
In this article, you learn how to optimize Azure Functions for performance and costs using Azure Load Testing. The Azure Functions Flex Consumption plan gives you flexibility and custom features that include private networking, fast and large scale-out features, and instance memory size selection based on a serverless model.
16+
17+
The Azure Load Testing performance optimizer tool helps you decide which configuration is right your app by running load tests among different Functions configurations. The tool helps you to understand the performance and cost implications of different configurations to help you make more informed decisions.
18+
19+
The performance optimizer enables the following capabilities:
20+
21+
- **Concurrent tests**: In-context experience where you can quickly create and run tests by specifying different memory and HTTP concurrency configurations with expected loads.
22+
- **Side-by-side comparison**: Evaluate performance metrics from load test results across scale & concurrency configs helping you choose the right configuration.
23+
- **Metrics**: Right-sizing based on performance metrics to optimize costs.
24+
25+
## Prerequisites
26+
* An Azure account with an active subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
27+
28+
* A function app in the Flex Consumption plan with at least one function with an HTTP trigger. If you need to create a function app, see [Create and manage function apps in the Flex Consumption plan](/azure/azure-functions/flex-consumption-how-to).
29+
30+
* To run a test profile, your Azure account must have the following permissions on the app:
31+
* Microsoft.Web/sites/read
32+
* Microsoft.Web/sites/write
33+
* Microsoft.Web/sites/slots/read
34+
* Microsoft.Web/sites/slots/write
35+
By default, the [Website Contributor](/azure/role-based-access-control/built-in-roles/web-and-mobile#website-contributor) role has these permissions already.
36+
37+
## Running Performance Optimizer on your Azure Functions
38+
39+
Performance optimizer allows you to test different configurations to help you find the right balance of performance vs. cost. For instance, you can test metrics like instance size and HTTP concurrency amounts for your Functions app. The performance optimizer uses Azure Load Testing to help you identify your app's optimal configuration for performance and scalability. You can run the performance optimizer on your functions with HTTP triggers. Once you deploy your code to Azure Functions, use the following steps to run the optimizer.
40+
41+
1. Sign in to the [Azure portal](https://portal.azure.com).
42+
43+
1. Go to your Functions app hosted on Flex Consumption plan.
44+
45+
1. From the *Performance* section of your app, select **Performance Optimizer**.
46+
47+
1. If you don’t have an Azure Load Testing resource in the subscription, create one by selecting **Create Load Testing resource**.
48+
49+
:::image type="content" source="media/how-to-optimize-azure-functions/performance-optimizer-open.png" alt-text="Screenshot that the performance optimizer page in the Azure portal." lightbox="media/how-to-optimize-azure-functions/performance-optimizer-open.png":::
50+
51+
52+
### Create a test profile
53+
54+
A test profile describes your function app configuration, request details, and load configuration. For each Functions app configuration, a load test is run with the specified load. You can create a test profile by following these steps:
55+
56+
1. Select **Create test profile** to create a new test profile.
57+
58+
1. On the *Profile Configuration* tab, first enter the test details:
59+
60+
|Field |Description |
61+
|-|-|
62+
| **Load Testing Resource** | Select your load testing resource. |
63+
| **Test profile name** | Enter a unique test profile name. |
64+
| **Test profile description** | (Optional) Enter a test profile description. |
65+
| **Run test after creation** | When selected, the test profile starts automatically after creating the test. |
66+
67+
1. In the **Functions configuration** section, select the Functions app configuration you want to test. You can select the instance memory size and the HTTP concurrency. You can select up to ten combinations of memory and concurrency.
68+
69+
> [!NOTE]
70+
> Once the test profile run initiates, configuration changes are made directly to your app. Your Function app will restart for every combination specified and a load test is run against your app.
71+
72+
:::image type="content" source="media/how-to-optimize-azure-functions/create-test-profile.png" alt-text="Screenshot that the create test profile page in the Azure portal." lightbox="media/how-to-optimize-azure-functions/create-test-profile.png":::
73+
74+
1. In the *Request details* section, enter the request details for your function app. You can specify the request method, URL, and headers.
75+
76+
77+
1. Select **Add request** to add HTTP requests to the load test.
78+
79+
On the *Add request* page, enter the details for the request:
80+
81+
|Field |Description |
82+
|-|-|
83+
| **Request name** | Unique name within the load test to identify the request. You can use this request name when [defining test criteria](./how-to-define-test-criteria.md). |
84+
| **Function name** | Select the function that you want to test |
85+
| **Key** | Select the key required for accessing the function |
86+
| **HTTP method** | Select an HTTP method from the list. Azure Load Testing supports GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS. |
87+
| **Query parameters** | (Optional) Enter query string parameters to append to the URL. |
88+
| **Headers** | (Optional) Enter HTTP headers to include in the HTTP request. |
89+
| **Body** | (Optional) Depending on the HTTP method, you can specify the HTTP body content. Azure Load Testing supports the following formats: raw data, JSON view, JavaScript, HTML, and XML. |
90+
91+
1. Select the *Load configuration* tab to configure the load parameters for the load test.
92+
93+
|Field |Description |
94+
|-|-|
95+
| **Engine instances** | Enter the number of load test engine instances. The load test runs in parallel across all the engine instances. |
96+
| **Load pattern** | Select the load pattern (linear, step, spike) for ramping up to the target number of virtual users. |
97+
| **Concurrent users per engine** | Enter the number of *virtual users* to simulate on each of the test engines. The total number of virtual users for the load test is: #test engines * #users per engine. |
98+
| **Test duration (minutes)** | Enter the duration of the load test in minutes. |
99+
| **Ramp-up time (minutes)** | Enter the ramp-up time of the load test in minutes. The ramp-up time is the time it takes to reach the target number of virtual users. |
100+
101+
1. Optionally, configure the network settings if the Functions app isn't publicly accessible.
102+
103+
Learn more about [load testing privately hosted endpoints](./how-to-test-private-endpoint.md).
104+
105+
106+
1. Select **Review + create** to review the test profile configuration.
107+
108+
1. Select **Create** to create the test profile. Azure Load Testing now creates the test profile.
109+
110+
If you previously selected *Run test after creation*, the test profile starts automatically.
111+
112+
The Functions app is reverted to the original configuration after the test profile run completes.
113+
114+
115+
## View results
116+
117+
After the test profile run completes, you can view the results in the Azure portal. The test profile run contains the load test runs for each Functions app configuration. The results include performance metrics such as response time, throughput, and error rate for each function app configuration. You can compare the performance metrics across different configurations and choose the right configuration for your app. Once you’ve decided the optimal configuration, select **Apply** to apply the scale and concurrency settings to your Functions app.
118+
119+
:::image type="content" source="media/how-to-optimize-azure-functions/test-profile-run-results.png" alt-text="Screenshot that the create test profile run results in the Azure portal." lightbox="media/how-to-optimize-azure-functions/test-profile-run-results.png":::
120+
121+
## Next steps
122+
123+
- Learn more about [load testing Azure Functions](./how-to-create-load-test-function-app.md).
124+
- Learn how to [Monitor server-side application metrics](./how-to-monitor-server-side-metrics.md).
222 KB
Loading
379 KB
Loading
343 KB
Loading

articles/load-testing/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ items:
6161
href: how-to-create-load-test-app-service.md
6262
- name: Test Azure Functions
6363
href: how-to-create-load-test-function-app.md
64+
- name: Optimize Azure Functions
65+
href: how-to-optimize-azure-functions.md
6466
- name: Test private endpoints
6567
displayName: virtual network, vnet, hybrid, on-premises, onprem, private link, subnet
6668
href: how-to-test-private-endpoint.md

0 commit comments

Comments
 (0)