Load Testing Using JMeter
If your company hasn’t been performing load testing, you may have problems getting room in the budget for a testing solution. Using an open source solution like Apache JMeter will get the job done and may even convince the big bosses that they should pay for something with more functionality, such as Dotcom-Monitor’s LoadView.
Remember, load testing isn’t the same as stress testing. You’re not trying to break your website. You’re seeing how the site behaves with heavy traffic. A site that slows down on the day of a big product launch could damage the business irreparably. So load test as thoroughly as Apache JMeter allows.
Apache JMeter will run on any operating system that supports JAVA 6 or later. You’ll also need to install Oracle JAVA or OpenJDK. JMeter has a fairly intuitive GUI interface.
Creating the Test Plan
You’ll see a Test Plan icon on the left side of the JMeter window. Right click it and select Add > Threads (Users) > Thread Group. This brings up the Thread Group Control Panel where you can specify the number of users for your load test (Number of Threads), the amount of time you want to spend ramping up to the full number of users (Ramp-Up Period) and the number of times each user should perform the test scripts (Loop Count).
Make sure the number of users reflects the amount of traffic you expect on a busy day like Black Friday.
Once you’ve created a Thread Group, it should appear in the tree underneath the Test Plan. Now you need to add HTTP Request Defaults. Right click the Thread Group icon and select Add > Config Element > HTTP Request Defaults. Enter your website’s URL in the control panel.
Recording Test Scripts
You’ll want to record test scripts that mimic actual user behavior, such as putting items in a shopping cart and checking out. Open a web browser, such as Firefox or Chrome, and change the browser’s Network Preferences to use JMeter’s proxy. Select Manual Proxy Configuration, and enter “localhost” for Address and “8888” for the Port.
Now you’re ready to start recording a test script. Type your website’s URL in the browser’s address bar and hit Enter. From your site’s home page, click on a few links like an actual user would. Close the browser and return to JMeter. Expand the Thread Group tree and verify that there are now several samplers under the Thread Group. These are the different pages you navigated to when recording your script.
Save your test plan and validate the script by right clicking on Thread Group and selecting Validate. Click on the View Results icon under the Thread Group to see if validation was successful.
Run the Test
Click the Run icon on JMeter’s toolbar to start the load test. JMeter will display the test results in a graph updated in real time.
Analyze the Results
JMeter displays Throughput on the graph in green. The higher the throughput is, the better your server is able to handle the heavy load.
Note that JMeter sends virtual users to your website from your computer. The calls are coming from inside the house. This means that your load test doesn’t reflect real world traffic. If this is inadequate for your needs, you may want to try a cloud-based load testing solution such as LoadView that sends virtual users to your site from servers all over the world.