Friday 8 November 2013

APACHE BENCHMARKING

make a file in /var/www/html/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Webserver test</title>
</head>
<body>
This is a webserver test page.
</body>
</html>
or

<?php
echo “Test Page”;
?>

$ ab -n 1000 -c 5 http://192.168.0.1/index.html

  • -n 1000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session
  • -c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a time to server 202.54.200.1

Use -k option that enables the HTTP KeepAlive feature using ab test tool.
$ ab -k -n 1000 -c 5 http://192.168.0.1/kpage.html

Use -e option that allows to write a comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests:
$ ab -k -n 50000 -c 2 -e apache2r1.cvs http://192.168.0.1/snkpage.html

$ ab -k -n 50000 -c 2 -g apache2r3.txt http://192.168.0.1/snkpage.html

To check perl test.pl
#!/usr/bin/perl
$command=`perl -v`;$title = "Perl Version";
print "Content-type: text/html\n\n";print "<html><head><title>$title</title></head>\n<body>\n\n";
print "
<h1>$title</h1>
\n";print $command;
print "\n\n</body></html>";

$ ab -n 3000 -c 5 http://202.54.200.1/cgi-bin/test.pl

To test sql make file psql.php
<html>
<head><title>Php+MySQL</title></head>
<body>
<?php
  
$link = mysql_connect("localhost", "USERNAME", "PASSWORD");
 
 mysql_select_db("DATABASE");

  
$query = "SELECT * FROM TABLENAME";
  
$result = mysql_query($query);

  
while ($line = mysql_fetch_array($result))
  
{
     
foreach ($line as $value)
      
{
       
 print "$value\n";
     
}
  
}

  
 mysql_close($link);?>
</body>
</html>


$ ab -n 1000 -c 5 http://202.54.200.1/psql.php

No comments:

Post a Comment