Do you think IIT Guwahati certified course can help you in your career?
No
Introduction
Apache JMeter is an open-source load and performance testing software that is purely based on Java Language. JMeter was developed by Stefano Mazzocchi of the Apache Software Foundation. It was primarily written to load and test the performance of Apache JServ (also called the Apache Tomcat project). Later on, to add more features and functional testing capabilities, the Apache community redesigned it to enhance the GUI. Its functionalities have grown to include testing web pages, web apps, and other static and dynamic resources like databases, LDAP, Java objects, rest web services, and more.
The timers help us to generate real-life experience traffic. Suppose there are thousands of users hitting the website. First of all, not all the users are hitting the website at the same time, and second thing, not all the users have the same way of exploring the website. There will be some time gap in each and every action taken by the users. So to generate real traffic, Jmeter has provided us with some timers.
Let's now explore these JMeter timers.
About Jmeter Timers
The primary objective of using timers is to simulate the "think time" of a virtual user. The term "think time" in the context of load testing refers to the simulation of real user behavior that results in a pause between user engagements with a web application.
Testing without a JMeter timer can give inaccurate test results because the simulated requests will be in a different pattern than what we get in the real-world scenario.
Jmeter is a very handy tool. It does not require extensive programming knowledge. Only prior knowledge of Java language is preferred. To install Jmeter, run JMeter.bat on windows and Jmeter.sh on Linux.
Features of JMeter Timers
The main features of JMeter include:
License: JMeter is open source and platform-independent, supports all environments, and is readily available.
Graphical User Interface: Compared to other performance testing tools, Jmeter timers are simple, free of cost, user-friendly, and easy to learn.
Server/ Protocol Support: JMeter can test different servers, apps, and protocols for load and performance. A few protocols include the following -
Test Result Visualisation: Test results can be viewed in different formats-
Simulation: Simulate multiple users using virtual or unique users to generate heavy traffic on web servers or services.
Reporting: JMeter only offers XML and CVS Report Formats by default. We can combine Jmeter with ANT to create an HTML report per our requirements.
Testing Types: Jmeter is effective for functional, regression, and soak/endurance testing in addition to performance, load, and stress testing.
Let’s now understand the workflow of Jmeter Timers.
JMeter Timer Workflow
Now that you might be wondering how the JMeter timer actually works? Let's understand the concept in brief. A large number of users are simulated by JMeter while sending a requests to the AUT(Application Under Test). When JMeter simulates requests, the server responds, and Jmeter starts collecting data.
Jmeter records every response and provides statistics based on the server response. Thus, in order to implement real-world scenarios, we can use JMeter, to simulate the demand on the servers, networks, or objects originating from various machines.
Types of Timers present in Jmeter-
There are total nine types of JMeter timers available. Each timer has its own usability. Some of the timers are discussed below-
Some of the timers are discussed below-
Constant Timer
The Constant Timer will add some delay to the threads before they are initiated. This thread delay is a constant in milliseconds. Hence, this timer is used to add some 'think time'(or delay) between each user request.
Uniform Random Timer
Uniform random timer is used to add a random amount of delay or think time between the user requests so that each request has a unique timing. The total delay in the uniform random timer is the sum of the random delay value and the constant delay offset value.
Precise Throughput Timer
In the precise throughput timers, the user sets a target # of requests per minute/second(number of samples per throughput period).
Constant Throughput Timer:
The Constant Throughput Timer is similar to the Precise Throughput Timer, except that it offers fewer settings. Essentially, it strictly sticks with a target throughput, and does not allow the flexible variance of the Precise Throughput Timer.
BeanShell Timer
In the BeanShell Timer we can develop the logic of how to implement a timer. It can be used to generate a delay time between every user requests.
JSR223 Timer
JSR223 Timer is a scripting-based timer that creates a delay between each user request.
Gaussian Random Timer
Gaussian random timer delays each user request for a random period of time. It has a random deviation around the Constant Delay Offset based on Gaussian curve distribution.
Here the value of total delay time will be the sum of return value of Gaussian distribution function and constant delay offset(Additional value in milliseconds).
Poisson Random Timer
Poisson Random timer has almost the same functionalities as a Gaussian Random timer. It offers a delay time between the requests for a random interval of time. The sum of Lambda (in milliseconds) and Constant Delay offset represents the total delay in time.
Synchronizing Timer
The Synchronizing Timer in JMeter holds the threads until X number of threads arrive, and then they are all released at once. Introducing delays between requests prevents all (specified) threads from firing at once, thus creating heavy load bursts on the application. Hence the Synchronizing Timer pauses all the threads in its scope unless their number won't be equal or greater than the number, specified in “Number of Simulated Users to Group by” input.
Using Timers
Now that we know that timers can be used to set a fixed or a random delay between each user requests. Let us consider an example of an employee who is overloaded with the task of performance testing of www.google.com for 100 users. That seems like a herculean task. Isn’t it? But don’t worry JMeter Timers is there for the employee’s rescue!
Using the JMeter Timers, employee can add a constant timer and add view results in a table. After that he can simply run his test and get the desired result. Still unclear? Keep calm and follow these steps-
Step 1 : Open the JMeter window by clicking-
Once you click on the batch file, Apache JMeter screen will appear as this:
Step 2: Now right click on the Test Plans and follow these steps-
Now enter the thread properties so that JMeter can create one user request to http://www.google.com for 100 times.
Step 3: Now add the Jmeter sampler as per your requirement.
Step 4: The next step is to add the timer. Here you can use the constant timer. To add the timer follow the given steps-
Configure the thread delay of 4000ms.
Step 5: Now add the ‘View Results in Table’ to displays the test result in table form by following the given steps-
Step 6: After adding the required output format, save the file and click the ‘Run’ button on the menu bar. Your out should be somewhat similar to this-
Where the delay of every sample is equal to the value you have assigned to the thread delay while adding the timer. By following similar steps, you can use other timers for different use cases. Now it’s time for some frequently asked question.
What is Performance Testing, and why is it important?
Performance testing is non-functional testing that evaluates the application's performance under expected or higher loads. It's done before the app goes live to ensure it doesn't crash and replies in a reasonable amount of time under real-world conditions.
Is the JMeter tool capable of simulating a real browser?
No, JMeter does not replicate or operate the same way as a genuine browser. It cannot render HTML responses as a real browser can.
Describe how JMeter works internally.
JMeter creates numerous threads that make simultaneous requests to a target server to simulate real-world user load. The server's performance is then displayed via tables and graphs.
What is the purpose of the Timer in JMeter?
JMeter can use a timer to delay the time between each request a thread makes. It is capable of resolving the server's overload issue.
Conclusion
JMeter timers are simple, yet it is very powerful tool. You can create excellent load tests with the proper knowledge of the timers functionality. This article is all about JMeter timers and its types.
To explore more on JMeter Timers, here are more articles for rescue.