**Vietnamese: mục tiêu của bài viết này là giới thiệu sơ lược về công cụ JMeter và cách áp dụng nó để kiểm tra tính bền vững của một website với số lượng truy cập lớn. **
The purpose of this article is to make a quick introduce about JMeter tool and how to apply it to test the performance of a website with high loading.
Why using JMeter for load testing
JMeter is a free tool, with a wide range of supported functions, and is very popular. Well, as I know (from several StackOverflow questions) there’s hundreds of popular web-testing tools out there. Just pick one, and this time I take JMeter.
Another notice is that this article won’t tell you how to configure Ant to use it along with JMeter. This tutorial is the guide to build a basic test plan to run with the JMeter GUI.
Build a test plan
First you need a test plan. For example, you want to test a Library Website when there are 200 users access at the same time. This is a very high load, given the fact that if your website has about 1000 users, it’s very rare to see 10 of them access the website resource simultaneously.
We need to specify what a typical user do when accessing our website, for example:
- The user login
- The user browse books in library
- The user review some page of the book
To perform those actions, the user (unconsciously) send HTTP request to web-server through the browser. Assume they are:
To achieve a list of requested links (and their parameters), you may use proxy server of JMeter, or an intercepting program like Fiddle2. But we don’t go into details of that issue here.
Get your test plan to JMeter:
After opening jmeter.bat, it makes a blank test plan ready for you. Here’s a screenshot:
Add a thread group: a thread group is the simulation of a user (a thread). In this thread group, we will add many HTTP Sampler Request – the action that the user will perform. Several important parameters of thread group is:
- Number of thread(user): the number of thread will run simultaneously. For example, if you want to run 100 user at a time, this number is 100.
- Loop: the number of times the thread will repeat.
- Ramp up time: the time for the system to increase the thread number to the value specified by “number of thread”. If ramp-up time is 100s for 100 users, it means the time for JMeter to start 100 thread is 100s. If not specified, the system will try to start all the thread at 0s, which may cause overloading for the machine running JMeter.
Add a HTTP Sampler Request: this is a fake HTTP request, to an URL specified. You may select the request type (POST/GET), include data in parameter table or by specifying an included file.
Add custom variable: Not all request to web server is static. Some of them maybe dynamic, based on the previous request. Hence JMeter supports perl-like syntax to include variables in request URL.
Extract information from response: JMeter support extracting value from response to put it in local variable (which may be used in following requests). The value can be extracted by XPath or Regular expression.
Add a listener: To view and do statistics on the results, you will need a listener. In JMeter, there are lots of Listener type for you to choose. Basically, “View result tree” and “View result table” listeners is used to check the server concrete response; the others are statistic reporters that summarize the result of the load-test. The most important reporters are Aggregate Report and Summary report.
User think time: An easy-forgettable parameter in building test plan is user think-time. It bases on the fact that a user can not request as rapidly as a computer, but rather, having time to think(inputting forms, viewing items,…). JMeter has various timer object to have a request delayed for a specified (maybe dynamic) time.
Mostly the estimation is rather subjective, based on parameters like:
- Error rate
- Average response time
- Max response time
- 90% Line
- CPU/ RAM usage of server
I don’t go into details of all those parameters here. But maybe it’s a subject of another post.