nginx speed

Status
Not open for further replies.

AndyLaw

Active Member
104
2012
18
0
Does many of you use nginx on your servers? We are starting to use if on several of our servers now and it seems to reduce the server load almost 3x, does it have any downside during the long run or it is simply better?
 
19 comments
nginx compared to apache2 is a huge speed improvement. Its mostly due to its event based design which means no thread per connection and no context switching. As well as this it also has a very efficient design memory wise and no module system.

I would be supprised if the improvement was only 3x (well unless you are including the php overhead). I have multiple nginx servers that serve over 10million requests every day, and all on very little resources (256mb ram, etc).

The downsides would be no .htaccess's and a different configuration system (that if you get to know, is arguably more powerful than apache2's).
 
Last edited:
Been actively using nginx on production systems as well. No downside except maybe the lack of certain features since Apache has a vast amount of modules. A lot faster and less memory usage.
 
Been using nginx for awhile now. Once I switched, I never looked back. Nginx is simply amazing when it comes to speed and low ressources usage. The only drawback I found is that you have to relearn how to configure a webserver.
 
Nginx is known for its speed in serving static pages, much faster than apache and keeping the machine resources very low.
Fundamentally both apache and nginx differs a lot.
Apache works in a multi process/multi threaded architecture, While nginx is an event driven single threaded architecture.(i will come back to event driven later). The main difference this even driven architecture makes is that, a very small number of nginx worker process can serve a very very large number of requests.
Sometimes nginx is also deployed as a front end server, serving static content requests faster to the clients, and apache in behind.
Each worker process handles requests with the help of the event driven model. Nginx does this with the help of a special functionality in linux kernel called as epoll and select poll. Apache when even run by its threaded model utilizes considerably much more system resource than nginx.
In apache when a request is being served, either a thread or a process is created which serves the request. Now if one requst needs some data from the database,and files from disk, etc the process waits for that.
So some processes in apache just sits and wait for certain task to complete(eating system resources).
Suppose a client with a slow internet connection connects to a web server running apache, the apache server retrieves the data from the disk, to serve the client. Now even after serving the client that process will wait until a confirmation is received from that cliet(which will waste that much process resource)
Nginx avoids the idea of child processes. All requests are handled by a single thread. And this single thread will handle everything, with the help of something called as event loop. So the thread pops up whenever a new connection, or some thing is required(not wasting resources.).
Step 1: Gets Request
Step 2: Request Triggers events inside the process
Step 3: Process manages all these events and returns the output(and simultaniously handles other events for other requests)

For more you can get info out here in details :- http://www.wikivs.com/wiki/Apache_vs_nginx
 
yes but the problem when site need use rewrite rule
apache with htaccess more simple, nginx use for advance user
 
I get awesome results with nginx or varnish running in front of Apache for caching and serving static content. I saw load dropping from 20 to 1-2 and speed increased multiple times in certain cases.

For a standalone web-server I would always go with Lighttpd, I use it for my private servers and it's been working like a charm.

LiteSpeed used to be good several years ago, I remember I loved it back in days when I was a Linux novice. A lot changed until now and LSWS went crap, it used to be the fastest on benchmarks done several years ago, now both nginx and lighttpd are faster and more reliable.
 
nginx, always nginx.

no point in any other web server ever unless you're the kind of person who cares about microoptimisation.
 
I am now switched to nginx on my project and seems to work much better than Apache too. Hopefully will not face any problems in the future :)
 
Status
Not open for further replies.
Back
Top