Load testing a Python chat app by using RAG with Locust
This article provides the process to perform load testing on a Python chat application by using the Retrieval Augmented Generation (RAG) pattern with Locust, a popular open-source load testing tool. The primary objective of load testing is to ensure that the expected load on your chat application doesn't exceed the current Azure OpenAI Service transactions per minute (TPM) quota. By simulating user behavior under heavy load, you can identify potential bottlenecks and scalability issues in your application. This process is crucial for ensuring that your chat application remains responsive and reliable, even when faced with a high volume of user requests.
Note
This article uses one or more AI app templates as the basis for the examples and guidance in the article. AI app templates provide you with well-maintained reference implementations that are easy to deploy. They help to ensure a high-quality starting point for your AI apps.
Prerequisites
An Azure subscription. Create one for free.
Dev containers are available for both samples with all the dependencies that are required to complete this article. You can run the dev containers in GitHub Codespaces (in a browser) or locally by using Visual Studio Code.
- You need only a GitHub account.
Python chat app with RAG. If you configured your chat app to use one of the load balancing solutions, this article helps you test the load balancing. The load balancing solutions include Azure Container Apps.
Open the load test sample app
The load test is in the Python chat app solution as a Locust test. Return to that article, deploy the solution, and then use that dev container development environment to complete the following steps.
Run the test
Install the dependencies for the load test:
python3 -m pip install -r requirements-dev.txt
Start Locust, which uses the Locust test file locustfile.py. You can find it at the root of the repository.
locust
Open the running Locust website, such as
http://localhost:8089
.Enter the following values in the Locust website.
Property Value Number of users 20 Ramp up 1 Host https://<YOUR-CHAT-APP-URL>.azurewebsites.net
Select Start Swarm to start the test.
Select Charts to watch the test progress.
Clean up resources
When you're finished with load testing, clean up the resources. The Azure resources created in this article are billed to your Azure subscription. If you don't expect to need these resources in the future, delete them to avoid incurring more charges. After you delete resources specific to this article, remember to return to the other chat app tutorial and follow the clean-up steps.
Return to the chat app article to clean up those resources.
Get help
If you have trouble using this load tester, add your issue to the repository's Issues webpage.