What is nginx and why might I want to use it over apache?

  • Posted June 2, 2013

Specifically for WordPress installed on Ubuntu.


I am trying to log onto firefox web browner and I am gettingn400 Bad Request (too large -cookies)? What the hell is that. It was fine until yesterday

Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

When I switched to Nginx from Apache. I read these two guides and it helped understand why. <br> <br>

I just posted about this on Linkedin today <br> Below are two posts from me, (Copy/Pasted) <br>Post-1 <br>I recently came across a blog (not Digital Ocean Blog, some other blog) that says Nginx performance is better than Apache because, “Nginx doesn’t create a new process for a new request. Apache creates a new process for each request” This is not completely true, Apache MPM has two models, 1. Prefork (Above statement is applicable for this model) 2. Worker The worker MPM uses processes with many threads for each process. Each thread handles one connection at a time. This model is suitable for high performance web servers. I have not worked on Nginx and but managed high few high traffic website with Apache (Tuned) and lighthttpd quite well. I wanted to learn more about the performance advantage that Nginx has over Apache or lighthttpd. Is there any study/load testing done to prove Nginx could perform better than Apache (Tuned) for high traffic website? Please back your statement with data. (In Data we trust rest is ;) <br> <br>Post 2- (In response to Event Driven Arch) <br> <br>Agree Buddy :) Nginx is event driven and asynchronous from design perspective and I guess this very helpful for more requests that are long-running but of a small size (Example Mobile) <br>As ONESTONE says: <br>“Nginx uses the Reactor pattern. Basically, it’s single-threaded (but can fork several processes to utilize multiple cores). The main event loop waits for the OS to signal a readiness event - e.g. that data is available to read from a socket, at which point it is read into a buffer and processed. The single thread can very efficiently serve tens of thousands of simultaneous connections (the thread-per-connection model would fail at this because of the huge context-switching overhead, as well as the large memory consumption, as each thread needs its own stack)” <br> <br>But Apache has a fix around it- Event MPM ( <br>As I know this fix is experimental and has issue with https :( <br>But again as per Kevin, Apache could outrun Nginx when “you are running pure PHP content on a given server, Apache seems to still be the best bet for the job.” <br> <br> <br> <br>I would design this in following way, <br>* CDN (CSS, JS and images) <br> <br>* Run PHP from Apache (Tuned) <br> <br>Again as I mentioned before I don’t know Nginx (Never worked on it) so idea is to LEARN and EVOLVE. Leverage Nginx when required and possible. <br>I never carry any preconceived notion/baggage of dogma :) just a student of life/events :)

NGINX is a very fast Webserver, its faster than Apache (under similar conditions) because it doesn’t need to spawn new processes or threads for each request like Apache does. Hence it also has a low memory foot print. It doesn’t support .htaccess files in its quest for speed and rewrite rules that you would write in .htaccess files for Apache are included in the virtual host configuration files. There could be others like the architecture etc, but I think this answers your question. Does it?

nginx is better and secure than apache(under bad configurations) and ideal for high traffic websites. It is compatible with most platforms like wordpress but with additional configuration code. <br>Most of the people think that it’s configuration is hard to learn, but for me, it was a lot easier to learn than apache. Once done correctly, it becomes a mean webpage serving machine with low resources. Better solution than Varnish is to use the built in FastCGI cache if you run a blog or something.

I am no expert but since no-one else has replied yet… <br> <br>nginx and Apache are alternative web server softwares. Web server softwares serve web pages in response to browser requests. Some people say that nginx is leaner that Apache ie consumes less RAM, has better caching and serves web pages more quickly. But if you are using a cache application such as then for at least some browser requests the web page is served by the cache ie without troubling the web server software and so nginx vs apache becomes irrelevant. <br> <br>I think it is said that that Apache + Varnish is good but Apache on its own is not good ie is heavy and slow.
<br> <br>Here is some discussion - this is about Drupal rather than Wordpress but a lot of the issues will be the same.