Azure Functions fails in load testing in combination with Azure CosmosDB or SQL Database

DBLJoey 51 Reputation points
2021-10-08T21:41:45.823+00:00

I got a large dataset of all the addresses in my country (3.8GB). I am creating an API which will query the database for one specific address and respond with basic JSON data (300bytes). The API is running in Python on Azure Functions.

So far everything works great. When i do a single request i get a response time of +/- 100-150ms. Great! But...

If i try to load test the API with, let's say, 200 requests in 1 minute. The average response time is around 4-6 seconds.

This is what i tried so far;

  • Connect the API to a SQL database
  • Connect the API to a Cosmos DB database
  • Smaller tables (less columns)

Is there some limit on the number of connections per database? The SQL Database or Cosmos DB doesn't seem to be the issue (% of CPU/Mem are good).

I created a simple '/status' endpoint without the DB connection on the API which can handle 200 requests in 1 minute easily.

Hopefully someone can push me in the right direction.

Azure SQL Database
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,299 questions
Azure Cosmos DB
Azure Cosmos DB
An Azure NoSQL database service for app development.
1,448 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,591 Reputation points Microsoft Employee
    2021-10-12T17:02:43.583+00:00

    @DBLJoey Sharing your code would help to be sure but here are some things you could check for

    1. Using static clients to reduce on establishing connections for each request
    2. Ensure you are using async calls instead of synchronous ones
    3. Tweak the host.json settings for HTTP triggers based on your scenario. If you just have an async call, you could handle more concurrent requests.
    0 comments No comments