miztiik / azure-apim-latency

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Azure API Management Performance Latency Tests

A quick summary of throwing lot of traffic to Azure API Management and see how it performs.

We will use the below architecture. Miztiik Automation - Azure API Management Performance Latency Tests

  • 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..

Create the Resources.

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

🎯 Test the solution

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.

Miztiik Automation - Azure API Management Performance Latency Tests

πŸ§ͺ Analyze the results

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. Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests Azure Monitoring Community Github - Azure API Management Performance Latency Tests has lot of useful queries to analyze the results. Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests Miztiik Automation - Azure API Management Performance Latency Tests

  1. 🧹 CleanUp

    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

    # 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.

πŸ“Œ Who is using this

This repository aims to show how to Bicep to new developers, Solution Architects & Ops Engineers in Azure.

πŸ’‘ Help/Suggestions or πŸ› Bugs

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

ko-fi Buy me a coffee β˜•.

πŸ“š References

  1. Azure Docs - Validate client certificate in APIM
  2. Azure Docs - Secure APIs using client certificate authentication in APIM
  3. Azure Docs - Add a custom CA certificate in Azure APIM
  4. Azure Docs - Secure backend services using client certificate authentication in APIM
  5. Azure Docs - Using Certificates in Azure APIM

🏷️ Metadata

miztiik-success-green

Level: 300

About


Languages

Language:Bicep 53.3%Language:Python 38.0%Language:Shell 7.5%Language:Dockerfile 0.6%Language:HTML 0.4%Language:Makefile 0.3%