หลายคนคงเคยใช้โปรแกรมทดสอบประสิทธิภาพเครื่องแล้วก็ Card จอมาเยอะแล้ว
แค่สำหรับคนที่อยากจะทดสอบความสามารถของเครื่องที่ Run Apache ว่าสามารถรองรับการใช้งาน
ผู้เข้าชมมากน้อยเพียงใดคงต้องอ่านคู่มือนี้
[hide=2]
Howto: Performance Benchmarks a Web server

Posted by nixcraft in FreeBSD, Linux, UNIX, Networking, Apache

You can benchmark Apache, IIS and other web server with apache benchmarking tool called ab. Recently I was asked to performance benchmarks for different web servers.

It is true that benchmarking a web server is not an easy task. From how to benchmark a web server, “First, benchmarking a web server is not an easy thing. To benchmark a web server the time it will take to give a page is not important: you don’t care if a user can have his page in 0.1 ms or in 0.05 ms as nobody can have such delays on the Internet.

What is important is the average time it will take when you have a maximum number of users on your site simultaneously. Another important thing is how much more time it will take when there are 2 times more users: a server that take 2 times more for 2 times more users is better than another that take 4 times more for the same amount of users.”

Here are few tips to carry out procedure along with an example:
Procedures

* You need to use same hardware configuration and kernel (OS) for all tests
* You need to use same network configuration. For example, use 100Mbps port for all tests
* First record server load using top or uptime command
* Take at least 3-5 readings and use the best result
* After each test reboot the server and carry out test on next configuration (web server)
* Again record server load using top or uptime command
* Carry on test using static html/php files and dynamic pages
* It also important to carry out test using the Non-KeepAlive and KeepAlive (the Keep-Alive extension to provide long-lived HTTP sessions, which allow multiple requests to be sent over the same TCP connection) features
* Also don’t forget to carry out test using fast-cgi and/or perl tests

Example:

Let us see how to benchmark a Apache 2.2 and lighttpd 1.4.xx web server.
Static Non-KeepAlive test for Apache web server

i) Note down server load using uptime command
Code:
$ uptime
ii) Create a static (small) html page as follows (snkpage.html) (assuming that server IP is 202.54.200.1) in /var/www/html (or use your own webroot):
Code:
<!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>
Login to Linux/bsd desktop computer and type following command:
Code:
$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html
Where,

* -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

For example if you want to send 10 request, type following command:
Code:
$ ab -n 10 -c 2 http://www.somewhere.com/
Output:

This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright