Joe
Joe

Reputation: 3089

nginx/apache/php vs nginx/php

I currently have one server with nginx that reverse_proxy to apache (same server) for processing php requests. I'm wondering if I drop apache so I'd run nginx/fastcgi to php if I'd see any sort of performance increases. I'm assuming I would since Apache's pretty bloated up, but at the same time I'm not sure how reliable fastcgi/php is especially in high traffic situations.

My sites gets around 200,000 unique visitors a month, with around 6,000,000 page crawls from the search engines monthly. This number is steadily increasing so I'm looking at perfomrance options.

My site is very optimized code wise and there isn't any caching (don't want that either), each page has a max of 2 sql queries without any joins on other tables, indexes are perfect as well.

In a year or so I'll be rewriting everything to use ClearSilver for the templates, and then probably use python or else c++ for extreme performance.

I suppose I'm more or less looking for any advice from anyone who is familiar with nginx/fastcgi and if willing to provide some benchmarks. My sites are one server with 1 quad core xeon, 8gb ram, 150gb velociraptor drive.

Upvotes: 12

Views: 9476

Answers (4)

setufaisal
setufaisal

Reputation: 11

NGINX is the best choice as a webserver now a days.

  1. The main difference between Apache and NGINX lies in their design architecture. Apache uses a process-driven approach and creates a new thread for each request. Whereas NGINX uses an event-driven architecture to handle multiple requests within one thread.
  2. As far as Static content is concerned, Nginx overpasses Apache.
  3. Both are great at processing Dynamic content.
  4. Apache runs on all operating systems such as UNIX, Linux or BSD and has full support for Microsoft Windows & NGINX also runs on several modern Unix-like systems and has support for Windows, but its performance on Windows is not as stable as that on UNIX platforms.
  5. Apache allows additional configuration on a per-directory basis via .htaccess files. Where Nginx doesn’t allow additional configuration.
  6. Request Interpretation-Apache pass file System location. Nginx Passes URI to interpret requests.
  7. Apache have 60 official dynamically loadable modules that can be turned On/Off.Nginx have 3rd Party core modules (not dynamically loadable).NGINX provides all of the core features of a web server, without sacrificing the lightweight and high-performance qualities that have made it successful.
  8. Apache Supports customization of web server through dynamic modules. Nginx is not flexible enough to support dynamic modules and loading.
  9. Apache makes sure that all the website that runs on its server are safe from any harm and hackers. Apache offers configuration tips for DDoS attack handling, as well as the mod_evasive module for responding to HTTP DoS, DDoS, or brute force attacks.

When Choose Apache over NGINX?

  • When needs .htaccess files, you can override system-wide settings on a per-directory basis.
  • In a shared hosting environment, Apache works better because of its .htaccess configuration.
  • In case of functionality limitations – use Apache

When Choose NGINX over Apache?

  • Fast Static Content Processing
  • Great for High Traffic Websites

When Use Both of them -Together

User can use Nginx in front of Apache as a server proxy.

Upvotes: 0

Soroush
Soroush

Reputation: 659

Here is an independent benchmark for g-wan vs nginx, varnish and others http://nbonvin.wordpress.com/2011/03/14/apache-vs-nginx-vs-varnish-vs-gwan/

g-wan handles much more requests per second with much less CPU time.

Upvotes: 1

Jarod
Jarod

Reputation: 21

Here is a chart showing the respective performances of nginx, apache and g-wan:

g-wan.com/imgs/gwan-lighttpd-nginx-cherokee.png

apache does not seem to lead the pack (and that's a -Quad XEON @ 3GHz).

Upvotes: 2

Frankie
Frankie

Reputation: 94

nginx will definitely work faster than Apache. I can't tell about fastcgi since I never used it with nginx but this solution seems to make more sense on several servers (one for static contents and one for fastcgi/PHP).

If you are really targeting performance -and even consider C/C++- then you should give a try to G-WAN, an all-in-one server which provides (very fast) C scripts.

Not only G-WAN has a ridiculously small memory footprint (120 KB) but it scales like nothing else. There's work ahead of you if you migrate from PHP, but you can start with the performance-critical tasks and migrate progressively.

We have made the jump and cannot consider to go back to Apache!

Upvotes: 6

Related Questions