Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to evaluate the performance of web servers?

I'm planing to deploy a django powered site. But I feel confused about the choice of web servers, which includes apache, lighttpd, nginx and others.

I've read some articles about the performance of each of these choice. But it seems no one agrees. So I'm wondering why not test the performance by myself?

I can't find information about the best approach to performance testing web servers. So my questions are:

  1. Is there any easy approach to test the performance without the production site?
  2. Or can I have a method to simulate the heavy traffic to have a fair test?
  3. How can I keep my test fair and close to production situation?

After the test, I want to figure out:

  1. Why some ones say nginx has a better performance when serving static files.
  2. The cpu and memory needs of each web server.
  3. My best choice.
like image 222
Zhu Tao Avatar asked Sep 17 '09 09:09

Zhu Tao


1 Answers

Tools like ab are commonly used towards testing how much load you can take from a battering of requests at once, alongside cacti/munin/your system monitoring tool or choice you can generate data on system load & requests/sec. The problem with this is many people benchmarking don't realise that they need to request a lot of different requests, as different parts of your code executes it will take varying amounts of time. Profiling and benchmarking code and not requests is also important, to which plenty of folk have already done so for django, benchrun is also not a bad tool either.

The other issue, is how many HTTP requests each page view takes. The less amount of requests, and the quicker they can be processed is the key to having websites that can sustain a high amount of traffic, as the quicker you can finish and close connections, the quicker you allocate resources for new ones.

In terms of general speed of web servers, it goes without saying that a proxy server (running reverse at your end) will always perform faster than a webserver with static content. As for Apache vs nginx in regards to your django app, it seems that mod_python is indeed faster than nginx/lighty + FastCGI but that's no surprise because CGI, regardless of any speed ups is still slow. Executing and caching code at the webserver and letting it manage it is always faster (mod_perl vs use CGI, mod_php vs CGI, etc) if you do it right.

like image 109
squeeks Avatar answered Nov 01 '22 10:11

squeeks