Pages

Wednesday 22 May 2013

Load Testing with JMeter

Load Testing with JMeter
Apache JMeter is a 100% pure Java desktop application which is used for load/traffic testing of Web Applications. 

  • JMeter is mainly used for load testing. It will throw many concurrent requests at your site for an extended period of time as you wish.While our load test is executing, we have the opportunity to monitor our entire server stack and see what happens over time as your application handles the load.
  • Initially JMeter needs to be configured to sit between the browser and the target server and then it records all the HTTP requests sent by the browser to the server. If the target GUI accepts only HTTPS requests, then at this phase the browser should send HTTP requests (and Not HTTPS) to the JMeter, JMeter records those requests and encrypt and send those to the server. Reverse thing happens for HTTPS response. JMeter receives the responses from the server, decrypts those records and sends the HTTP responses back to the browser. The logical entity that is responsible for this HTTP message recording is called Http Proxy manager.
  • Once the recording is done, JMeter can be configured to start a large number of simultaneous threads. Each thread represents one user sending/receiving the same set of requests/responses recorded. Now onwards, it’s between the JMeter and the server; browser is no longer used. The component responsible for this is called thread group.

Now, To Configure JMeter follow the bellow steps.

  1. Download Jmeter from Here
  2. Go to JMETER_HOME/bin and start JMeter with jmeter.bat on windows. New window will open once you run jmeter.bat file
  3. Select "Test Plan" on the tree.
  4. Enter the details in User Defined Variables if you wish. It's not mandatory.
  5. Right click on the "Test Plan" and add a new thread group: Add > Threads (Users) >Thread Group.
  6. Select the Thread Group.
  7. Right click on Add -> Config Element -> HTTP Request Defaults.
  8. In new HTTP Request Defaults element: Server name or IP - Enter “localhost” (if you are testing it on your local machine otherwise enter relevant URL or IP address).
  9. Path – leave blank.
  10. Right click on the "Thread Group" and add a recording controller: Add > Logic Controller > Recording Controller.
  11. Next, select WorkBench. 
  12. Right click on WorkBench and add the Http proxy: Add -> Non-Test Elements -> HTTP Proxy Server.
  13. On HTTP Proxy Server, Under Global Settings section entered port number (e.g:9090)
  14. On HTTP Proxy Server, Select the target Controller (created in above point number 11).
  15. On HTTP Proxy Server, click the “Add” button in “URL Patterns to Include”. This will create a blank entry.
  16. Enter ".*\.html"
  17. On HTTP Proxy Server, click the “Add suggested Excludes” button in “URL Patterns to Exclude”.
  18. Right click on "HTTP Proxy Server" and add a listener: Add -> Listener -> View Results Tree.
  
Now, Configure your browser to use the JMeter HTTP Proxy.
  1. In Firefox :    
    1. Click on Tools >  Options > Select Advanced > Select Network Tab > Click on Settings.
    2. Select Radio Button "Manual Proxy Configuration".
    3. Add Http Proxy: localhost and Port (Entered the same port number as entered in above point number 14)
    4. Checked check box of "Use this proxy server for all protocols".
    5. Press Ok.
  2.  In Chrome:
    1. Click on Settings.
    2. Type Change proxy settings in search box.
    3. Click on Change proxy settings button.It will open new window of Internet Properties.
    4. Click on LAN settings.
    5. Checked the check box of "Use a proxy server for your LAN".
    6. Add Address: localhost and Port (Entered the same port number as entered in above point number 14)
    7. Click on Advanced button and Checked check box of "Use the same proxy server for all protocols". 
    8. Click Ok.
  3.  In IE :
    1. Click on Tools > Internet Options > Select Connections.
    2. Click on LAN settings.
    3. Checked the check box of "Use a proxy server for your LAN".
    4. Add Address: localhost and Port (Entered the same port number as entered in above point number 14)
    5. Click on Advanced button and Checked check box of "Use the same proxy server for all protocols". 
    6. Click Ok.

Record Your Test Plan:
  1. Return to HTTP Proxy Server, and click the "Start" button at the bottom
  2. In your browser, In the Address bar enter "localhost:8080" (localhost: web server port number) and hit the enter key.
  3. Click on a few links of your application pages.
  4. Return to HTTP Proxy Server, and click the "Stop" button at the bottom.
Now,Expand the thread group and there should be several samplers.

 Run the Test plan with JMeter:
At this point, we are ready to run our test plan. You can run the test plan with below two ways:
    1. Run --> Start
    2. Ctrl + R 
While the test plan is running, in the upper right-hand corner, there should be a green square. When the test is done, the box should be grey.

1 comment:

  1. Hi,A major factor in determining your online success in Web Design Cochin is the amount of time you commit to educate yourself regarding proper website design.Thanks.....

    ReplyDelete