Stress Testing for Performance Tuning Stress Testing for Performance Tuning A t l o g y s T e c h n i c a l C o n s u l t i n g, R - 8, N e h r u P l a c e, N e w D e l h i Page 1
This Guide is a Sys Admin ToolKit for Performance Analytics and Enhancements of your Site Learn about Load Testing, Latency Measurements, Profiling and more
ATLOGYS ACADEMY @atlogys Latest trends and innovations in web and mobile technology www.atlogys.com/tips Guides, Tutorials, advice on best practices, standards, Do s and Don ts. blog.atlogys.com Practical Notes on getting *Good* software development. Contact Details: Contact: (+91) 11 26475155 E-mail: ritika@atlogys.com Address: R-8, Nehru Enclave,New Delhi 110019, India
Table of Contents Atlogys Academy... 3 1. httperf... 5 1.1 stress testing using httperf... 5 2. Apache Bench... 6 3. Autobench... 9 4. Siege... 10 5. JMeter... 11
STRESS TESTING FOR PERFORMANCE TESTING What are the tools to use? How to use them? How to study and understand the output from these tools? 1. HTTPERF httperf is a tool to measure web server performance. httperf is more advanced and reliable than apache bench. 1.1 STRESS TESTING USING HTTPERF $ httperf - - server www.example.com - - uri /index.php - - num- conn 20 - - num- cal 10 - - rate 2 - - timeout 5 server specifies the name or ip of the machine the service is running. uri specifies the context path of the service on the server. num-conn 20 instructs httperf to make 20 connections. num-cal 10 instructs httperf to issue 10 requests per connection. rate 2 specifies how many new connections are made every second, 2 in our case. timeout 5 instructs httperf to report as errors any requests that aren t answered within 5 seconds. $ httperf - - server example.com - - port 5556 - - uri /test.html - - rate 400 - - num- conn 8000 timeout 20 --server example.com Specify the sever
--port 5556 Specify the port --uri /test.html The file you want to download --rate 150 The rate in requests/second --num-conn 27000 The total number of TCP Connections --num-call 1 The number of requests for each connection --timeout 5 The request will fail if it takes longer than this 2. APACHE BENCH ApacheBench (ab) is a tool for benchmarking your Apache HTTP server. It shows you how many requests per second your Apache server is capable of serving. The ab tool comes bundled with the Apache source distribution. syntax ab - n [number of connections] - c [number of concurrent users] [url] number of connections à This is the no. of visitors in the website number of concurrent users à This is the no. of users that are using the application at exactly the same time $ ab - n 1000 - c 5 http://whatsuptest.devcloud.acquia- sites.com/ // send 1000 requests, 5 is concurrency number
Sample Output: $ ab -n 100 -c 3 http://localhost/wub/ This is ApacheBench, Version 2.3 <$Revision: 655654 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient)...done Server Software: Server Hostname: Apache/2.2.20 localhost Server Port: 80 Document Path: Document Length: /wub/ 34473 bytes Concurrency Level: 3 Time taken for tests: 12.604 seconds Complete requests: 100 Failed requests: 0 Write errors: 0 Total transferred: HTML transferred: 3490000 bytes 3447300 bytes Requests per second: 7.93 [#/sec] (mean) Time per request: Time per request: 378.112 [ms] (mean) 126.037 [ms] (mean, across all concurrent requests)
Transfer rate: 270.41 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.9 0 6 Processing: 278 375 57.0 382 455 Waiting: 245 334 53.5 342 406 Total: 278 375 56.9 382 456 Percentage of the requests served within a certain time (ms) 50% 382 66% 416 75% 431 80% 434 90% 441 95% 449 98% 452 99% 456 100% 456 (longest request) RESULT ANALYSIS: It takes 456ms to serve a longest request. This is the longest response time This server is capable of processing 7 requests per second under this condition
3. AUTOBENCH Autobench can be used to benchmark a single server. For example, the command line below: $ autobench --single_host --host1 www.test.com --uri1 /10K --quiet \--low_rate 20 --high_rate 200 -- rate_step 20 --num_call 10 \--num_conn 5000 --timeout 5 --file results.tsv This will benchmark "http://www.test.com/10k", with a series of tests starting at 20 connections per second (with 10 requests per connection), and increasing by 20 connections per second until 200 connections a second are being requested. Each test will comprise a total of 5000 connections, and any responses which take longer than 5 seconds to arrive will be counted as errors. The results will be saved in the file 'results.tsv'. The autobench output file from which the graphs were drawn can be found here.
4. SIEGE Siege is an http load testing and benchmarking utility. It was designed to let web developers measure their code under duress, to see how it will stand up to load on the Internet. $ sudo apt-get install siege $ siege -d10 -c50 http://yourwebsite.com The -d option specifies the delay, while the -c option tells siege how many users it should simulate. Note that the -d option is a random interval between 0 and X seconds, with X being the number of seconds you specify -- so if you say 10 seconds, it may be 0 seconds, it may be 4 seconds, and so on -- it just won't be longer than 10. If you want to give a site a real workout, you probably want to specify more than one URL. You can do this with a list of URLs in ~/etc/urls.txt or specify a text file with URLs using the -f file option. If you want a simulation closer to real-world usage, you'll want to use the -i option, which hits the URLs in the file randomly. A fairly good template for testing might be: $ siege -d10 -c50 -i -f mysite.txt Be careful using Siege against production sites -- especially dinky little VPSes with very little RAM. Not that I'd know from personal experience or anything. It should also go without saying that you should not use Siege against sites you're not responsible. At best, doing so is impolite, but it could also be a violation of your ISP's terms of service, and at worst it may be illegal.
5. JMETER Apache JMeter may be used to test performance both on static and dynamic resources (files, Servlets, Perl scripts, Java Objects, Data Bases and Queries, FTP Servers and more). It can be used to simulate a heavy load on a server, network or object to test its strength or to analyze overall performance under different load types. You can use it to make a graphical analysis of performance or to test your server/script/object behavior under heavy concurrent load. $ sudo apt-get install jmeter $ jmeter Configure job Right click on Test Plan heading, click Add > Thread Group Right click on Thread Group, click Add > CSV Data Set Config Click on the newly added config element and enter a valid Filename this should contain one user UUID per line Enter userid under Variable Names (comma-delimited) Click on the Thread Group, configure the Number of Threads (say 5), the Ramp- Up Period (say 180) and then the test Duration (say 600). This tells JMeter to launch up to 5 threads, ramping these up over 2 minutes, with the test running for a total of 10 minutes. Right click on Thread Group, click Add > Sampler > HTTP Request Click on the newly added sampler element and enter a valid Server Name or IP You should probably add in some Timeouts; depending on your desired performance under load Run the job!
The Complete Detailed Report.. (Want The Full Exhaustive List?) Request the full report for detailed analysis and answers to questions like: How do check global availability and simulate end-user performance? How to health check your server and networks? How to graph network and server statistics and trends? How to test your system? How to analyze performance? Write to us at ritika@atlogys.com for detailed system administration guides.
ABOUT: ATLOGYS TECHNICAL CONSULTING What We Do? We act as your CTO (Chief Technology Officer) to take full ownership of your technology. Atlogys is an IT consulting company comprising of extremely passionate and technically sound computer scientists and software engineers from Google, Carnegie Mellon and IIT. We believe that the process of offshore software development is inefficient and expensive for the end customer. Our goal is to enhance this process by making it TURNKEY, RELIABLE AND HASSLE- FREE. We do this by working for you as your CTO. We provide detailed and personalized techno- business strategy on your product à We do detailed architecture design for your application à We manage the complete offshore lifecycle and delivery of your software project with your development vendor à We Offer an extra Engineering Eye for Detail to ensure your product is 360 degree complete with respect to performance, security, scalability. Engage us on your next software masterpiece so you can focus on your business while we handle all of your software!