Tuesday, May 20, 2014

How Apache JMeter simulates multiple users?

How Apache JMeter simulates multiple users?



  1. Introduction to different elements of a JMeter Test Plan.
  2. Difference between real world and JMeter world while doing a web request.
  3. Workflow of a typical web server request and response.
  4. JMeter's role in a web testing work flow.
Let us take a view at how a request for web page is sent to the Web server from a User's browser, and how a web page is finally displayed.  Understanding this workflow will give us opportunity to imagine how JMeter fits in this workflow and how it can do same thing as a browser does.


Now introducing Apache JMeter into the picture.  The actions taken by the User are no longer required.  The User action trigger some HTTP requests which are recorded in a JMeter HTTP Request Sampler for multiple uses.  

See how JMetr replaces a browser, but how the working is a little different.


So what makes one User transaction in terms of JMeter?  

When we add a HTTP Request Sampler in JMeter Test plan it stores one Web Page calling and receiving sequence.  We can call this as a single user transaction.  As soon as we tell this to JMeter it is capable of doing the same thing any number of times.  It also does this multiple times simultaneously.


As JMeter is not exactly a browser the HTTP Request Sampler makes all the received data available for further analysis.  We use View Tree Listener for actually visualizing the received response.  View Tree Listener is a good way to know what request was sent, what was the response and the result of the transaction.


When JMeter simulates multiple users by making the same call multiple times, in different operating system threads (we can say execution paths) that time more analytical data is available.  The Summary Report Listener can show us the additional calculated data line Minimum time and Maximum time taken to receive the response.  It also calculates the average time taken using all the results together.


So we have seen that for web site testing we need many items like
  1. HTTP Request Sampler
  2. View Tree Listener
  3. Summary Report Listener
To use these items provided by JMeter we will also need items like

  1. Test Plan and
  2. Thread Group
For some advanced user transactions and logical conditions there are Controllers.  Once we learn how to combine these elements we are ready to write our first Test Plan in JMeter.

Yes initially this may seem like a lot of jargon.  Eventually we will get used to these elements and then testing will be a piece of cake.  Ok, let us re-visit what they all mean in JMeter world.


We will write our first Test Plan step by step in the next article but let us first get introduced formally with the different elements we have seen till now.

Now we know some elements which will be used in creation of a Test Plan in JMeter.  It will be worthwhile checking the difference between real world transactions and the transactions that happen in JMeter world.  Is there one to one mapping between actions performed in real world and while executing a JMeter test plan?


Thats all for this article.  Thanks for reading

No comments:

Post a Comment