Home > Mobile >  Load testing an api locally, vs in a deployed testing environment
Load testing an api locally, vs in a deployed testing environment

Time:03-24

We have an expressJS API utilising mongoDB Atlas which will be deployed live to AWS. We want to stress and load test this API before users begin using it.

The question is whether to perform the load tests locally, or whether to deploy to AWS within a testing environment and load test the deployed API.

Could anyone provide any advice on this subject?

CodePudding user response:

Constructing an AWS test version of your API with as close to your request load and data as possible is the most accurate way to test.

The most sure way to determine whether your API will perform the way you expect it to in production is to mimic the production environment and load as closely as possible. If you have speedy Macbook Pro, that will probably run operations to a single instance of your API faster than an environment AWS. On the other hand, some AWS products might scale up/scale down your services to match demand. Any of that could detract from the accuracy of a local test.

Here's a much more in-depth article on setting up load testing. It goes through how to measure your data load, users, and queries in order to best simulate load: https://developers.redhat.com/blog/2015/04/30/how-to-load-test-and-tune-performance-on-your-api#preparation

All that being said, this is a new API. How many users are going to ramp up on your application in the first two weeks? How many requests per second? If you just want to make sure you're not leaving in any 4x nested queries in loops or something, testing locally could get you some of that info. If you're rolling out a test CRUD app to 100 friends and family, consider deferring building heavy testing infra for optimizing performance for a million users until you have more proven demand.

CodePudding user response:

If you're capable to kick off a local environment with the same specifications like the cloud - it should be no or little difference in the results.

But you need to ensure that the local is the exact replica including:

  • number and frequency of CPUs
  • RAM
  • Network and Disk IO
  • Network Latency (if you're in Europe and the cloud is in Australia you should be running tests geographically close to the server, otherwise you will see higher response times because packets need some time to travel around the globe)
  • etc.

If not - you still can do some testing of the aspects which are not directly connected with Mongo, i.e. using profiler tools to find potentially problematic code parts, etc.

The only approach you shouldn't touch with a ten-feet pole is running load tests against a scaled-down environment

  • Related