12 April 2011

Stress Testing ...? Do We Need To...???

Server configuration has been completed, the system / web application has no error, the network confirmed ready, whether it is ready for live production ...?

Wait a minute (do) we also have to estimate how many users will be live using the system / application, we must also estimate how many and how large the data received and sent by the server, was also request from users of the system ... What if the server is runing live was unable aka kuwalahan to receive many requests at one time, or a lot of data transferred (uploaded) to the server at the same time.

Nahhh, to find out, we can test the server and the network to be used as the live production. The term stress testing or benchmarking stress.

What tools do we need ..?

Just use ab, the tools already in the build to be included when you install apache2.

How To ...?

How, we first create a dummy file (if it does not have a file to be used for testing ...
$ Time dd if = /dev/zero of = test.pdf bs = 500000000 count = 1
1 +0 records in
1 +0 records out
500000000 bytes (500 MB) copied, 5.77993 s, 86.5 MB/s

real 0m5.832s
user 0m0.000s
sys 0m1.140s
$ Ls-l
Total 488 288
-Rw-r - r - 1 500 000 000 andri andri 2010-05-07 01:33 test.pdf

Nahhh, already have a file that we want to use to beat up our server, the size of 500 Mb. Time for us to test:

$ ab -n 100 -c 10 -p test.pdf http://localhost/

means we are going to test the server with 100 requests (-n) with 10 connections (-c) the upload file test.pdf (-p) of 500 Mb.

We'll see what ab word:

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: Netscape-Enterprise/6.0
Server Hostname: localhost
Server Port: 80

Document Path: /
Document Length: 309 bytes

Concurrency Level: 4
Time taken for tests: 45.042 seconds
Complete requests: 100
Failed requests: 0
Write errors: 0
Non-2xx responses: 100
Total transferred: 57000 bytes
Total POSTed: 50000013100
HTML transferred: 30900 bytes
Requests per second: 2.22 [#/sec] (mean)
Time per request: 1801.683 [ms] (mean)
Time per request: 450.421 [ms] (mean, across all concurrent requests)
Transfer rate: 1.24 [Kbytes/sec] received
1084056.23 kb/s sent
1084057.47 kb/s total

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 455 374.5 444 1325
Processing: 443 1347 393.0 1332 2307
Waiting: 1 896 384.3 889 1817
Total: 1325 1802 644.2 1348 3195

Percentage of the requests served within a certain time (ms)
50% 1348
66% 1817
75% 2661
80% 2664
90% 2688
95% 2711
98% 3142
99% 3195
100% 3195 (longest request)

To determine the extent to which powerful server, do to get an error / failed in the output.

And to know the parameters ab more, please visit: http://httpd.apache.org/docs/2.0/programs/ab.html

HTH ;)