Author

AUTHOR

Manju Sanjay

Choosing the best tool to conduct performance testing of different kinds of client-server applications is always a big concern. Here come the JMeter performance testing services to the rescue.

Consider a web application, which has several APIs for creating and requesting maps along with services like requesting map tiles and static images, uploading data to Mapbox account, querying data in a tileset, and more. Obviously, for these kinds of applications, a lot of API requests need to be handled while page loading happens and while a user makes a request to the page hundreds of APIs get invoked.

The web application performance testing using JMeter for these kinds of applications is really challenging, especially in transforming the JMeter to work as a browser and undertake testing operations.

It is observed that browsers limit the number of concurrent connections to a single domain, and it also limits the overall concurrent connections. Performance testing using JMeter can fully support multithreading, concurrent sampling by many threads, simultaneous sampling of different functions by separate thread groups. But our aim is to bring concurrent requests by each user using JMeter.

For example, while APIs requests for a group of map tiles are sent, this request needs to be executed concurrently as if a browser executes it with a limited number of concurrency sets.

Steps to Achieve Parallel Connections in JMeter

With our constant experiments and research, we found that the Parallel Controller plugin provided by BlazeMeter can serve the purpose. Following are the steps:

Step 1 

Install the Parallel Controller using JMeter Plugins Manager.

Step 2 

Create a test plan using a recorder.

Step 3 

Initialize the ThreadGroup with the required number of users, ramp-up time, and loop count. When the script run, the Mapbox samplers will look like this:

Step 4 

Add a parallel controller to the ThreadGroup. Also, add a group of samplers of a particular server or different servers inside the controller. The number of samplers can be set according to the maximum concurrency required for the APIs.

The ThreadGroup with the parallel controller with required samplers added will look like,

Step 5 

Run the script and see the samplers are started concurrently.

In this way, one can achieve concurrent API access from the user’s load simulation in JMeter.

Note: If there are several samplers that need to work in one thread, one needs to logically combine them, otherwise the parallel controller creates new threads for each of its child elements. In the above case, if one wants samples #51,52,53 to work in one thread, combine these under a SimpleController available in JMeter and add that controller to the ThreadGroup.

Generate Dynamic AWS Signature

Let’s see how to achieve the testing of an application where each request triggered needs to have an AWS signed header passed along with the request to validate the request at the IAM level in AWS.

In AWS Signature Version 4, don’t use the secret access key to sign the request. Instead, use the secret access key to create a signing key. The signing key is scoped to a specific region and service. To calculate a signature, first concatenate select request elements to form a string, referred to as the string to sign. Then use a signing key to calculate the hash-based message authentication code  (HMAC) of the string to sign. 

For JMeter load testing of such an application, follow the steps below: 

1. Add a JSR223 PreProcessor to your Thread Group. Then include the preprocessing logic for computing the signature, which should include the steps below in any of the languages supported such as Javascript, Groovy, Java. You can get a sample groovy script here that 

  •  Acquires values from the user-defined variables
  • Obtains the values from the HTTP Sampler that we will configure
  • Generates an AWS Date, which Amazon requires when calling the API
  • Creates a JMeter variable with the date stored in it
  • Calculates the AWS Signature
  • Creates a JMeter variable with an AWS authorization header

2. Supply the input variables for the preprocessor script to execute, using the User-defined variable element

3. Set the date and authorization values generated by the script in the HTTP header configuration of the API to achieve the goal.

4. Configure cookie and cache as per the application demands. Add a Listener and then run the test.

That’s it! This way one can accomplish the performance test of applications that has APIs with AWS signed header.

Need to know more about Testing solutions? Get consultation from our experts.