How to create a load testing environment for your web apps using open source tools by Sukrit Dhandhania
Open source load testing for web putting demand on an application and measuring its response see how application acts when you have several concurrent users logging in difference between "regression testing tools" and "load testing" goal - to define the maximum amount of load a system can handle without a significant degradation in performance
What do we test for? how does my application act when I have more than a single user logged in? what hardware configuration does my application need? how does my application scale with more and more concurrent users? how much load can my application handle? up to what point is my application useable with a growing load? what is the right web/app and database server configuration for my setup?
What do we test? the application the front end servers with different hardware and software configurations the database server
How do we test? Application: log in run search add item to cart check out Front-end servers: create a simple page and hit it with different loads change configuration and run tests again Database servers: transactional read/write benchmarks change configuration and run tests again
What tools can we use? Web Server/Application: apache bench siege httperf Jmeter Database: sysbench iibench
Monitoring and creating graphs monitor the performance of our servers use test monitoring data to build graphs for easy comparison use dstat to gather monitoring information use gnuplot to plot graphs or use orca to get monitoring and graphing all in one
Let's get our hands dirty setup the applications required for simulating a load on the web server setup monitoring tool - dstat run tests and restart web server after each test collect data for all tests and keep organized
Web server load testing with Apache bench get apache bench write a simple web application that will read some data from the DB and display run a test such as "# ab -n 100 -c 10 http://localhost/benchmark.php" this will create 10 concurrent threads and a total of 1000 requests increase number of requests gradually
How do we use siege for our load test? get siege from ftp://ftp.joedog.org/pub/siege/ "siege -c25 -t1m http://localhost/bookmark.php" - 25 concurrent users for 1 minute great thing about it is that you can use the POST feature with this tool quite flexible options
How do we use httperf? get from http://httperf.sf.net one the most advanced command line load testing tool "# httperf --server localhost --uri /benchmark.php --num-conn 1000 --num-call 10 --rate 200 --timeout 5" add http method, input file, POST etc
How do we monitor the performance of our servers? get dstat from http://dag.wieers.com/homemade/dstat/ simple, great, flexible, all info you need, with csv output file... "# dstat --output benchmark.csv -tcmn 10" - read time, cpu, memory, and network every 10 seconds and write to file
How do we run the actual tests? localhost vs remote server leave gap between tests restart server start monitoring before you fire the load building script the whole thing
How we test the database server with sysbench? general database performance evaluation tool helps you evaluate your OS's parameters for database server without installing DB get from http://sysbench.sourceforge.net "# sysbench --num-threads=16 --maxrequests=100000 --test=oltp --oltp-tablesize=1000000 \ --mysql-socket=/var/lib/mysql/mysql.sock --mysql-user=root run"
How to use iibench to test the database server? iibench does a raw INSERT testing of your database get from http://tokutek.com/contest.php great for web application where you expect a lot of UGC
How do we run the actual load testing for our database servers? run tests with default configuration modify database server configuration and run tests again restart database server after each test try with different hardware configurations capture performance data with dstat
What do we do with all this performance monitoring data? we plot graphs use a spreadsheet application gnuplot is very advanced, flexible, and can read from csv files write a script to plot graph from monitoring data
How do we get monitoring and graphs all in one package? get orca from http://www.orcaware.com/orca/pub/snapshots/ lots of perl prerequisites runs on the web server, so easy to access remotely used by amazon web services
What next? automate the testing by scripting fine tune and improve test framework limitations of this type of testing browsermob share findings with community
About me Sukrit from Pondicherry, India open source enthusiast help organizations adopt open source tools contact: sukritd-at-sevenacross-dot-com