facebook

Blog

Stay updated

How to run load tests of your Azure websites with minimum effort
Load tests with Azure
Monday, January 07, 2019

Some days ago, one of our clients asked us to make some load tests on an application we developed. Since we had recently returned from WPC, where I followed several sessions on Azure and the like, I said to myself: why not put the portal on Azure and take advantage of the tools that the platform makes available to us, to carry out the required tests? Furthermore, with my limited system knowledge, it would have been difficult for me to set up an environment that would allow me to do the same.

The test application is a Web portal created with our CMS WebRight, which in the latest version uses MongoDB for data storage. Given that WebRight is designed to take advantage of cloud solutions, it was quite simple.

First, create a new subscription on Azure, if you don’t already have one. I used the free one, which still offers all the tools you need, but remember that you still need a credit card to proceed. Then we add the necessary resources to the subscription, in particular:

  1. A Web App
  2. An Azure Cosmos DB with MongoDB API
  3. An archiving account

In the Azure dashboard, we have a situation similar to the following one:

Let’s start configuring the resources and our application for deploying to Azure. First, I was in charge of transferring data from MongoDB to CosmosDB. Once in the Azure Cosmos DB resource, the info you need to connect to the resources are all contained here:

All that remains is to transfer data from our MongoDB to Cosmos. With a simple mongodump , we create the data copy, and with a simple mongorestore , we bring all the collections to Cosmos.

mongorestore.exe –host cosmosdb-mongodb-account.documents.azure.com:10255 -u cosmosdb-mongodb-account -p –ssl –sslAllowInvalidCertificates ./dumps/dump-2016-12-07

In order to avoid losing your mind, make sure you have installed a version of MongoDB with active SSL. In the version that I had installed in Windows (3.4) was not present, so I downloaded the new version for OSX from here and I solved the problem. If you use the Mongo aggregation pipeline (as in our case), to complete the configuration you need to enable from the menu “Preview Features” the option “MongoDB Aggregation Pipeline”.

After that, we need to publish the application code in the Web App. To do this, we need a publication profile, which we can easily download from the portal:

We import the profile you just downloaded into Visual Studio and publish! The last step is that of moving all the static files of portal users to the interior of an Azure storage BLOB, so that they are available to all instances of the app. This operation is very simple too: just enter the storage resource created, select BLOB and create a new container, which will be the folder where we are going to put the static files.

Selecting the storage account from the web portal you will have an interface to upload files inside the container, one at a time. Since I am lazy and wanted something that loads everything at once, I used the AZCOPY tool, which provides commands that allow you to load a folder and all its subfolders with a simple command:

AzCopy /Source:https://myaccount.blob.core.windows.net/mycontainer /Dest:C:\myfolder /SourceKey:key /S

To do this, however, you need storage access keys, that you can find here:

After that, we’re ready for our tests! Let’s go to the Web App resource and from the menu choose “Performance Test”, in the screen that opens select “New”, and we will have this mask:

We can choose the number of users that we intend to use for the test, the duration and from what location get requests. Once you have chosen everything, we click on Run Test. At this point the system does all the rest of the work, collecting the necessary resources within 15 minutes (often much less) and starting the tests. Back in the screen where the tests are listed, we have the possibility to see the current status or the detail by selecting the test of our interest:

If the test results are not satisfactory, in addition to optimizations to be made to the code, Azure provides the possibility to increase the power of our machines with a simple click, always from the Web App resource:

In addition, it gives us the opportunity to increase the nodes at our disposal, so that we can scale our infrastructure based on the load we want to support:

I hope I have intrigued you about the possibilities made available by the Azure platform! See you next time.