A quick summary of throwing lot of traffic to Azure API Management and see how it performs.
We will use the below architecture.
-
Load Generation: Locust will be used to generate the traffic at a rate of 1000 requests per second at peak. The load will be generated from a single host. The load will be generated for 40 minutes.
-
Producer - The request will be sent to the Azure API Management. The API Management will forward the request to the Azure Function App. The Azure Function App(Producer) will generate a store event and save it to a Service Bus Queue and returns response to APIM.
-
Producer - The consumer is triggered when a message is available in the Service Bus Queue. The Azure Function App(Consumer) will read the message from the queue and process it. The processed message is saved to a CosmosDB and Blob Storage..
The bicep template will create the following resources: Azure Function App, API Management, Backend Service and the APIM Policy for configuring the backend. We have not configured the APIM to use the client certificate yet.
make all
Install Locust
pip install locust
The locust file to drive the load test can be found under /locust/locust_script.py
.
# Set variables with desired values
username="miztiik"
soft_limit=10000
hard_limit=200000
ulimit -n
# Check if the limits.conf file already contains the entries
if grep -q "^$username" /etc/security/limits.conf; then
# If the entries exist, update the values
sudo sed -i "/^$username/ s/\(soft\|hard\) nofile [0-9]*/\1 nofile $soft_limit/" /etc/security/limits.conf
else
# If the entries don't exist, add them to the end of the file
echo -e "\n$username soft nofile $soft_limit\n$username hard nofile $hard_limit" | sudo tee -a /etc/security/limits.conf
fi
ulimit -n 20000
cd /home/miztiik
# Run the locust file
TARGET_HOST=https://latency-store-front-us-apim-006.azure-api.net/api/
locust -f locust_script.py --host=${TARGET_HOST} -u 10000 -r 10 -t 40m --logfile /var/log/miztiik-locust.log --csv-full-history --csv=latency_store_front_us_apim
If you had configure port 8089
you can check the progress of the test by opening the browser and navigating to http://<locust_host>:8089
. You can also download the csv
file and plot the graph using excel or any other tool of your choice.
The latency introduced by APIM is very minimal. The latency is less than 10ms. The latency is consistent throughout the test. Even at peak load, the blob put latency is less than 1ms. Azure Monitoring Community Github - Azure API Management Performance Latency Tests has lot of useful queries to analyze the results.
-
If you want to destroy all the resources created by the stack, Execute the below command to delete the stack, or you can delete the stack from console as well
- Resources created during Deploying The Solution
- Any other custom resources, you have created for this demo
# Delete from resource group az group delete --name Miztiik_Enterprises_xxx --yes # Follow any on-screen prompt
This is not an exhaustive list, please carry out other necessary steps as maybe applicable to your needs.
This repository aims to show how to Bicep to new developers, Solution Architects & Ops Engineers in Azure.
Thank you for your interest in contributing to our project. Whether it is a bug report, new feature, correction, or additional documentation or solutions, we greatly value feedback and contributions from our community. Start here
Buy me a coffee β.
- Azure Docs - Validate client certificate in APIM
- Azure Docs - Secure APIs using client certificate authentication in APIM
- Azure Docs - Add a custom CA certificate in Azure APIM
- Azure Docs - Secure backend services using client certificate authentication in APIM
- Azure Docs - Using Certificates in Azure APIM
Level: 300