A software defect traced during the initial development stage is usually much easier to resolve than a defect encountered at later stage in a system’s lifecycle. Today’s typical multi-tier applications have separate tiers for presentation, business, and data logic, plus potential legacy integration. So application load testing with Apache JMeter can be applied at different phases in the life cycle of software development to get maximum benefit, helping development teams identify potential problems as early as possible.
According to Wikipedia, Load testing (http://en.wikipedia.org/wiki/Load_testing) is the process of putting demand on a system or device and measuring its response. Load testing is performed to determine a system’s behaviour under both normal and anticipated peak load conditions. It helps to identify the maximum operating capacity of an application as well as any bottlenecks and determine which element is causing system degradation. When the load placed on the system is raised beyond normal usage patterns, in order to test the system’s response at unusually high or peak loads, it is known as stress testing.
Apache JMeter is an Open Source load and performance testing application that can be used to simulate a heavy load on a server, group of servers, network or object to test its strength or to analyse overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behaviour under heavy concurrent load.
Setting up a test environment
A JMeter master-slave setup is required to test the system with multiple machines and to test the system with multiple users. It not only supports unlimited user creation but it also helps in replicating various browsers environment. JMeter is setup on various machines and configured. To replicate network bandwidth, a machine can be setup with limited bandwidth access. CPU utilization and Memory utilization are measured using various profilers to measure the key performance indicators.
Apart from the master-slave configuration, you can also setup independent machines with JMeter with multiple users and can execute the test cases. The only difference between the two methods is that in the master-slave configuration we get the test reports on the master machine and in the other parallel configuration test result are attained at each configured machines.
Designing a test script
Designing a script requires a thorough understanding of application functionality and its architecture including database and application server configuration. While designing a script we can start with the heaviest weighted use cases which represents the most common transactions a user can perform and proceed to the least weighted one. This use of weighted use cases helps to allocate resources according to the expected stress on the system and helps to record the system response at various stages and the break point. JMeter provides controller, timers, thread groups, loops and assertions to address various test scenarios. If a user is performing a certain activity a number of times, then it keeps the user request under a loop controller and configures a loop count. It may also happen that the user may be performing two simultaneous activities, for this JMeter provides functions, comma separated values (CSV) data set configuration elements.
Executing a test script to perform load test
A few checks are important before running the test script:
- Have smoke tests been performed before executing the script?
- Are all the secondary background services like database backup process are stopped?
- Is there any requirement of the test data to run the test scripts?
- Have the previous log files been cleared or rotated from application, database?
Now, enable memory and CPU logs in the database and application servers and execute the test scripts for 1-2 hours or more as per the need in an iterative manner to test. Once the test stops, take the logs from the database/application server and save JMeter scripts.
Analysing the result
The test result can be obtained with JMeter; the report mainly gives the details for Response time (time taken for request made and request served), Throughput (number of requests handled by server in a unit time) , Hits per second (number of HTTP request triggered on server to perform certain processes per second), Memory utilization and CPU utilization.
Another tool is Hyperic- an open source systems monitoring, server monitoring, and IT management software. A separate server can be setup for Hyperic so that the performance processes to be tested are not affected by the monitoring tasks. The Hyperic reports gives a deep analysis like Peak Load Time, Hits per second, CPU usage and Load average. The result help in decision making for choosing the right hardware configuration for the system with right load bearing capacity.
JMeter is an excellent tool for performing load testing as it’s so easy to use. You can find more details on Apache JMeter website on how to do it. In our next blog we will share details of the JMeter test Architecture best suited to perform load testing on Apache OFBiz so please stay tuned.
Thanks for your time!