JMeter Recording

JMeter Recording

In this article you can find three different ways of recording an application user flow as part of JMeter script recording and enhancements. Either of this method can be followed in recording your application under test.

To download and install JMeter, read this article on JMeter installation – JMeter Installation – My Blog (vprad.com)

3 Ways of Recording Web Applications

  • JMeter recording using JMeter HTTP’s Test Script Recorder
  • Recording using Blazemeter extension
  • Recording using Fiddler

JMeter recording using JMeter HTTP’s Test Script Recorder

Recording an application using HTTP’s test script recorder is the most widely and preferable way of recording an application. Preferred browsers for most of the applications are chrome and firefox.

Prerequisite Steps

In Chrome Browser

Proxy settings

Navigate to proxy settings of your system and change proxy address to localhost and port to 8888 and save the changes.

Configure JMeter root certificate In Chrome

In chrome browser navigate to settings <<>> Privacy and Security<<>>Manage Device Certificate<<>>click on Import<<>>Browse and select ApacheJMeterTemporaryRootCA.crt from JMeter bin directory and get it added to your browser trusted certificate directory. ApacheJMeterTemporaryRootCA.crt is listed in certificate list after the successful import.

In Firefox Browser

Proxy settings

Navigate to Firefox settings <<>>options<<>>Connection settings<<>>Manual proxy configurations<<>>Change HTTP proxy to localhost and port to 8888. Click on the option “Also use this proxy for FTP and HTTPS“.

Configure JMeter root certificate In Firefox

In Firefox browser navigate to settings <<>> Search for certificate<<>>Click on view certificate<<>>click on Import<<>>Browse and select ApacheJMeterTemporaryRootCA.crt from JMeter bin directory and get it added to your browser trusted certificate directory.

After completing prerequisites open JMeter and get ready to record your application.

Adding Recording Controller And HTTP(s) Test Script Recorder

Follow below mentioned steps to add necessary controllers to begin recording your application workflow using JMeter.

  1. Right click Test plan<<>>Add<<>>thread groups
  2. Right click Test plan <<>>Add<<>>Non-Test Elements<<>>HTTP(s) Test Script Recorder.
  3. Right Thread group <<>>Add<<>>Logic controller<<>>Recording controller

Adding recording controller is an optional step but will help in naming and organizing different user flow of application recording accordingly. Rename the recording controllers based on the user flow of your recording.

Test script recorder(http(s)) setup

Mention the port in global setting as 8888 (note that this port number should be the same as mentioned in proxy setting) and select target controller as “Test plan>Http(s) Test Script Recorder”. Click on start in Http(s) Test Script Recorder. Click on “OK” while the Root CA certificate notification pops up. Open browser, launch the application and start recording the user flow.

Recorded User flow

Once the recording is completed, click on stop and the recorded Api’s will be available for further script enhancement.

Recording using Blazemeter extension

Recording an application user flow can be done using blaze meter extension. This method is useful if application is recorded using chrome browser

Add blaze Meter extension to chrome browser

Click on BlazeMeter Chrome Extension and install blaze meter extension in your chrome browser

Navigate to chrome extensions and enable blaze meter extension to start recording the application user flow

Signup & SignIn Blazemeter Account

Signup and create a blaze meter account. Login to blazemeter account and start recording the application by clicking on blazemeter extension available in chrome extensions. Signing up or creating an account in blaze meter is important because signing in is needed to save the recorded script.

Start Recording

Record application user flow by clicking record button in blazemeter extension

Save Recorded Script

Save the script by selecting JMeter script option and finally the downloaded jmx file can be used for further script development.

Recording using Fiddler

Download & Install Fiddler

Fiddler is a useful tool in capturing and debugging network traffics. Navigate to fiddler to download fiddler. Post downloading complete the installation of fiddler tool.

Recording Using Fiddler

Open fiddler and click on File and select capture traffic and start recording application user flow.

Exporting File

After completing the recording click on File<<>>Export Sessions<<>>All Sessions. Select the export format to HTTP Archive v1.1 Save the file with. HAR extension. Now open blazemeter converter and convert .HAR file to .JMX file .

Types Of Performance Testing

Types Of Performance Testing

Evaluating performance of an application is always a key factor particularly if the application is used by high number of users. In order to evaluate how good/bad application works, we need to conduct different kinds of performance test execution. If you like to read basics of performance testing and its importance, then go through this article about Performance Testing Introduction. In this blogpost Iam including different types of performance testing conducted to evaluate an application performance, stability, scalability, durability etc.

Below mentioned are the most common types of performance testing.

  • Load Testing
  • Endurance Testing/Soak Testing
  • Spike testing
  • Stress Testing
  • Volume Testing
  • Scalability Testing
  • Failover testing

load testing

Load testing is to evaluate how an application perform for a specific user load. Ideally in a load test, an identified number of virtual users performs a set of transactions (user flows) or Api’s requests and evaluates the application performance in terms of its response time, resource usages like CPU, memory and other performance criteria. User load decided based on the current production load. For a new application its calculated based on competitor business volume. A load test ideally runs for 1 or 2 hours.

endurance testing/soak testing

An applications performance for a longer duration evaluated in endurance testing. In a load test, an application performance evaluated for few hours. Here we are not getting an overview of its performance for a longer duration. Performance bottlenecks related to resource usage comes up while we do a testing for a longer duration. For example, out of memory errors due to high memory utilization mostly identified by running an endurance test. Ideally any execution running more than 5 hours can be an endurance test.

Spike testing

A spike testing is done by a sudden increase or spike in load and conducted to see the application performance due to sudden increase in the load. This type of testing is usually benefited if we need to keep our application ready for any kind of unexpected spike in load.

stress testing

In Stress testing , an application stressed by putting a higher load. It is conducted to identify application breakpoint. Applications reliability, stability and resilience are evaluated by running this test with higher load beyond the benchmarked limits of the application.

volume testing

In volume testing, a high volume of data pushed into system to evaluate its performance. High volume data generally pushed using a batch job for doing a volume testing.

scalability testing

An application scalability measured by conducting scalability testing. Its ability to scale up or down by an increase or decrease in load can be measured by conducting scalability testing. Scalability testing results used in capacity planning.

failover testing

Failover testing conducted to identify applications availability during any kind of region failovers or outages. The results used in taking steps in increasing application availability.

Database Sharding

Database Sharding

Table of Contents

Introduction

Organizing high volume data is always need of the hour. Database stores the data as records, and it is important to keep them efficiently. In this article, you will go through the definition of database sharding , advantages and disadvantages, methods of doing a sharding .

Database Sharding

An architecture or design pattern of partitioning the data or records available in database into multiple smaller blocks of data horizontally is known as database sharding . For example, in the below image instead of keeping all the records of data in one single database instance its distributed between into multiple shards.

Database sharding
Database sharding

Advantages

Improved query performance

Database query time is long if all records are in a single database instance. Queries are faster after sharding because it will search for records only search in specific shards.

High reliability

By maintaining the records in shards data reliability increases. It is a single point of failure if all records are in a single database instance. Application fails to fetch data if this single database instance goes down. Maintaining a copy of data across multiple shards an application can always fetch data from either of the shards in case of any database instance failing to operate.

Appropriate distribution of traffic

Managing all records in single database instances, distribution of traffic will not happen. By sharding, multiple shards will be getting traffic while writing and reading records. Hence there is a distribution in traffic by sharding .

Disadvantages

Higher infrastructure cost

Infrastructure cost in maintaining data in multiple shards is high in comparison to traditional way of database architecture.

Higher effort in maintanance

Operational and maintenance effort is higher in managing multiple shards rather than managing them into a single database instance.

Methods Of Sharding

Below listed are the different methods of sharding . It is very important to select a suitable method while sharding the data. Issues like loss of data, slow running queries, high resource usage among shards will happen if sharding is not proper.

  • Range Based Sharding
  • Hashed Sharding
  • Directory Sharding

Range based sharding

In range based sharding database records are arranged by range of values. A shard key is assigned for each set of range values. Database records written or read from database based on the shard key which is in turn assigned based on the range of values.

In the below image alphabets between range of A-M is having shard key as 1 and N-Z as 2 . Shard key allocated based on first letter of employee’s name and corresponding range of values.

Range Based Sharding

Hashed sharding

Database record arranged in rows are assigned with a shard key using a function named as hash function. Hash function collect information of records from each row and distributes data among multiple shards.In hashed sharding,records are evenly distributed.

Hashed Sharding
Hashed Sharding

Directory sharding

In directory sharding , a lookup table maintains information about all database records to physical shards. Records stored in a meaningful way but chances of failures are more in this architecture since it is always dependent on lookup table.

In the below image a look up table is arranging employee records based on their departments. Each department is having a shard ID. Records arranged in multiple shards based on the shard ID.

Directory Shard
Directory Sharding
JMeter correlation

JMeter correlation

Correlation is the method of capturing dynamic values which comes as a server response and sending the captured value to subsequent request. In this article on JMeter correlation, Iam mentioning about different types of extractors available in JMeter and how to use them in correlating dynamic values.

In JMeter, you can use extractors of different types to perform correlation. The extractor, as the name indicates, extracts the dynamic value and stores it in a variable if you need to pass the stored value in the next requests. Below mentioned are different types of extractors available in JMeter.

  • CSS Selector Extractor
  • JSON Extractor
  • Boundary Extractor
  • Regular Expression Extractor
  • XPath Extractor

How to add extractor?

Step1-Identify request wherein the extractor needs to be added.
Step2-Right click on the request select add, select Post processors, and click on the type of extractor whichever needs to be added.

when to do correlation?

Response for a request will have different values. For easiness let us categorize these values as static values and dynamic values. Since static value remains the same, you do not need to capture it using any extractor. Dynamic values change in every time. If a value is dynamic and it is coming in any subsequent request, you should correlate it.

Now let us go through the details on each extractor available in JMeter

Types of extractors

CSS Selector Extractor

You can plan to use CSS selectors or XPath extractors if you need to capture a dynamic value from an HTML or XML response. The CSS extractor in the example mentioned below extracts all headings of a webpage. Once you have tested the extraction using the CSS selector tester, apply the CSS selector extractor.

CSS Selector Tester
Extracting 5th heading content using CSS Selector Extractor.

JSON Extractor

You can use JSON extractors particularly when you need to capture a dynamic value from a JSON response. In the below example created data is a dynamic response value. As shown in the screenshot, we use a JSON path expression to capture the created value using JSON extractors.

Json Extractor Tester
Json extractor
Json path Tester
Validating Json path expression using json path tester before applying it

Boundary Extractor

We can capture the dynamic value using the boundary extractor by identifying its left and right boundary. In the below mentioned example id number is a dynamic value.
Now to capture this dynamic value we need to identify left and right boundaries and add it in respective fields as mentioned in screenshot.

Here in below mentioned example left boundary is {“id”:” and right boundary is “,”created At

{“id”:”132″,”createdAt”:”2023-04-27T08:37:48.790Z”}

Jmeter boundary extractor

Regular Expression Extractor

Dynamic value from a response can be extracted used using regular expression extractor. Here in this example dynamic id number is captured using regular expression “(.)” In this regular expression “.” indicates any character or integer value and “” indicates any numbers of values following the first value.

Jmeter regular expression extractor

XPath Extractor

XPath extractor becomes handy specially during other extractors like boundary and regular expressions extractors fails to capture the desired dynamic value from the response. It is useful in getting values from HTML tags similar to CSS extractors.

Xpath tester
XPath Extractor

Interested in learning more about Xpath ? , visit this website to learn more on Xpath Tutorial Point

checking extractor before applying

It is important to validate correlation before applying it. You can do it in either of the ways mentioned below.

1)Navigate to response for a particular request in “View Result Tree”. Apply the regular expression in search bar and select “Regular exp” option and click Find.

dynamic value response

2)Navigate to response for a particular request in “View Result Tree”. Select from the dropdown extractor tester of your choice. In this example it is boundary extractor tester. Place left and right boundary accordingly and click test. If you fill the input information appropriately, then only you will get the results.

Regular expression tester
Boundary extractor tester

Passing captured Correlated value to next request

To pass the captured or correlated value you need to pass the variable name as mentioned below (in screenshot). In the subsequent request to create user2, we use the ID value captured in the create user1 response. This is applicable to values captured using any JMeter extractors.

Format to keep the value in request is ${Variable Name}.

jmeter boundary extractor
Boundary extractor with a variable name as C_Id1
Replace correlation value to next request
The variable ${C_Id1} is used in the second request body create User2.
dynamic value captured from response.
ID having dynamic value 6 is captured in variable C_Id1
dynamic value passed in response.
Dynamic Id value “6” is sent in second request create User2
JMeter Thread Group

JMeter Thread Group

Table of Contents

JMeter Thread Group

In this article on JMeter thread group, you will learn on what is a thread groups. different types of thread groups, thread group properties, scheduler configuration and most importantly how will you decide which thread groups to use for your performance test execution

Thread Groups

Thread groups is a group of threads executing similar kind of actions during a test execution. Here in JMeter tool each thread represents a virtual user. As part of a performance test execution if you need to design a scenario wherein a set of users performs similar kind of actions then we add thread groups in test plan. Precisely saying thread groups are user groups and if you use JMeter for any kind of performance test execution we need to add thread groups.

Types of thread groups and how to add them

Mentioning 8 different types of thread groups available in JMeter. Few thread groups like thread groups, setUp thread group and teardown thread groups are available as a default option.

JMeter plugins used to add remaining thread group mentioned below.

  • Thread Group
  • bzm – Arrivals Thread Group
  • bzm – Concurrency Thread Group
  • bzm – Free-Form Arrivals Thread Group
  • jp@gc – Stepping Thread Group
  • jp@gc – Ultimate Thread Group
  • setup Thread Group
  • teardown Thread Group

Right click on Test plan, select add and then select either of these thread groups based on your choice.

Options in Thread groups

  • Action to be taken after a Sampler Error
  • Thread properties
  • Scheduler configuration

Action to be taken after a Sampler Error

Action to be taken after a sampler error is a common option across all the thread groups available in JMeter. Based on option we select here JMeter will decide on the actions to be taken if it encounters with any errors during the execution.

  • Continue – To continue with the test execution even in case of any errors
  • Start Next Thread Loop – It will stop the currently running thread group and proceed with other thread groups (if any)
  • Stop Thread – It will stop the running thread in thread group.
  • Stop Test – It will stop the test completely.
  • Stop Test Now – Almost the same option available with stop test. The test will stop more abruptly.

Thread Properties

Pattern of distributing the load is based on the options selected in thread properties. Below mentioned are properties available in JMeter thread groups.

  • Number of threads (users) – Mention number of virtual users or threads for load distribution
  • Ramp up period(sec)-Time in seconds needed to ramp up all the virtual users while running a test. Example if you’re running a test with 100 users and if you give 10 seconds in ramp up period, then all 100 users will be ramping up and running in your test in a time duration of 10 seconds.
  • Loop count – Indicates number of times execution iterates. Check the forever option if you want to run the test for a specific duration.
  • Same User on each Iteration – Check this option if same set of users to be used during the execution.
  • Specify thread lifetime – Total duration of test execution in seconds.

Scheduler Configuration

In scheduler configuration additional information on load distribution and its duration included. Below mentioned are the scheduler configuration available in JMeter thread groups. Scheduler configuration information available totally depends on the thread group chosen for an execution.

  • Target Rate (arrivals/min) – Targeted request/sample rate in minutes mentioned here. Target rate represents the sample / request rate in a minute and is not the user rate per minute. This option is available in bzm – Arrivals Thread Group
  • Ramp Up Time (min)-Time in minutes it takes to push the request load during the execution. This option is available in bzm – Arrivals Thread Group
  • Ramp-up Step Count-Mention total number of steps needed while ramping up the request load. This option is available in bzm – Arrivals Thread Group
  • Hold Target Rate Time (min)-This is the total test execution duration. This option is available in bzm – Arrivals Thread Group
  • Target Concurrency-Targeted number of concurrent users needed during the test.
  • This group will start-Mention the number of users needed during the start of the test. This option is available in jp@gc – Stepping Thread Group
  • First, wait for – Wait time in seconds needed before ramping the next set of users. This option is available in jp@gc – Stepping Thread Group
  • Then Start – New set of users gradually added. This option is available in jp@gc – Stepping Thread Group
  • Next, add – Next set of users added in the time intervals of seconds. This option is available in jp@gc – Stepping Thread Group
  • Then, hold load for – Overall test execution duration. This option is available in jp@gc – Stepping Thread Group

Which Thread Group Should I Use?

Based on the way you decide to design the load of the application you can decide to choose the thread group. Including few information on how each thread groups is different from one another. Going through the details on each thread group you can decide to opt either of these thread groups which suits the user load design or pattern.

Thread Group

Thread group is the most commonly used compared to other thread groups available in JMeter. Suppose you want to load test your application by using multiple concurrent users for a specific duration then this thread group can be opted. In this example mentioned below 100 users will ramp up in 10 seconds and the test will run for 1 hour duration.

bzm – Arrivals Thread Group

Bzm – Arrivals Thread Group used if we want to trigger a test with a specific number of request rate rather than number of users . In below example 100 requests simulated every minute and will run for 1 hour duration. Total of 6333 request generated by this thread group. Ideally 6000 requests in 1 hour duration, remaining 333 requests getting added in 5 min ramp up duration.

bzm – Concurrency Thread Group

Bzm – Concurrency Thread Group can be used to simulate concurrency in load. In below example, all 12 users will be ramping up in 2 steps by around 5 minutes and will do the execution for 1 hour duration. The total load test execution duration is 1 hour 5 min which is 1 hour of hold target rate plus 5 minutes of ramp up.

bzm – Free-Form Arrivals Thread Group

This thread group is similar to bzm – Arrivals Thread Group and you can design user load on the basis of total number of requests. Below mentioned user load design will run the test for 1 hour 5 min duration and will generate around 340 requests.

jp@gc – Stepping Thread Group

In this thread group we can ramp up the user load gradually. Step by step progression of user load is possible using stepping thread group. In the below example total of 100 users will be running. 20 users ramp up initially and 10 users added gradually in every 30 seconds. This test will run for a duration of 1 hour 5 min which includes 1 hour steady load with 100 users and 5 min of user ramp up.

jp@gc – Ultimate Thread Group

In JP@GC – Ultimate thread group, load can be designed with many more parameters or inputs. This thread can
be used in designing spike test. In the below example a total of 60 users will simulate the load which starts with an initial delay of 10 sec. The first thread scheduled will run for 600 seconds and second thread scheduled will run for 1 hour duration.

setup Thread Group & teardown Thread Group

Both setup Thread Group & teardown Thread Group are having the same option and is similar to basic thread group. Setup threads are like a prerequisite thread group and executed before the actual test execution.

Teardown thread groups executed post the actual test execution, generally executed for any activities needed after the actual execution. Below mentioned are some use cases of setup and tear down thread groups.

Few use cases of setup Thread Group:

  • Extracting User details data set information from database
  • Test data loaded as data set to database before load test execution.

Few use cases of Tear down Thread Group:

  • Deleting the dataset from database post the load test execution.
  • Clearing data from cache server post the load test execution.

Refer this article on JMeter setup Thread group to learn more about setup thread group.