Apache vs Nginx
Yes, its about web servers. Starting from Netscape we have come across many web servers which came in to the picture while all Microsoft based web servers has failed miserably, due to its OS failures, Unix based, servers have survived like the OS its self, And Apache has been in use for multiple decades with lease number of problems. However there is a new kid on the block Nginx yes engin X , trying to take a chunk of Apache market. So how do we find which is better. It is not that straightforward, because both servers has good and bad features.
Architecture :
But one major difference is that Apache is pure multi threaded system where load balancing is mostly being transferred to the OS to decide how load should be done, where lot of control is given to admins to do manual adjustments. But Nginx on the other hand its event driven, where one might panic that ohh servers will get stuck. No its not, it basically takes care of the load by its self by employing a non-blocking event-driven architecture and deals with the requests asynchronously. Hence it creates many content serving issues as compared to the MPMs (Multi-Processing Modules) that provides a flexible architecture for choosing different connections and different handling algorithms in a multi domain environment. Before looking at those issues it would be important to see the overall content serving mechanism of both candidates.
Content :
It is one of the most important factors of a web server and Nginx shows an edge over Apache by the looks of it. And let see why?. Nginx has a magic up in its' sleeve where it does not uses PHP interpreter when it serves static content where Apache relies on file based method. However when it comes to dynamic content, Nginx can’t process it within the web server as Apache does. It relies on an external process like PHP-FPM for the execution.
Operating System :
This is a very important factor when it comes to providing support for programmers of all walks of life. Hence Nginx lags behind when it comes to platform support. As we know Apache is the king in all Unix-like systems including Linux and BSD and on top if it fully supports MS-Windows, but Nginx supports almost all Unix-like OSes and partially windows platform. Thus dropping all newcomers to the web industry where they think windows platform is a good choice.
Configuration :
This is one of the points where Nginx fails really bad. Apache allows additional configuration per directory basis .htaccess that allows sub directory level additional configuration that will allow content developers to control certain aspects of their web site thus providing better control for users who have parked domains to one single directory structure to to enable share files and also allow different domain controllers to take care of their sub-directory. But unfortunately Nginx does not have this flexibility even-though it has some flexibilities as far as the .htaccess is concern.
Requests :
One of the core functions of a web server is the request interpretation where Nginx doesn't seem to be having a clue on dynamic handling of web content with multiple domains. Of course that means these two candidates processes requests in an entirely different manner. Apache passes file system locations and and of course it refers to appropriate location within the server however Nginx assumes that request URI is the way to go and passes URI instead of the file location thus creating havoc in interpretations of the locations in server side scripting specially multi domain environment. Which is cumulative result of way it handles server side scripting and configuration etc.
Modules :
of-course both candidates are equipped to handle different support modules but as you guessed these two servers handles them differently, while Apache boasts having able to load and turn on and off 60 official dynamically loadable modules with many more unofficial modules Nginx is unable to dynamically load 3 rd party core modules where such 3 rd party plugins has to be selected and compiled thus restricting ability to dynamically loading of such modules.
Security :
The security of the server is always debated and it all about how to setup you server environment and of course its a balancing act of flexibility and security. However must say that Apache offers few tips for DDoS attacks handling, and mod_evasive module for responding to HTTP DoS, DDoS, or brute force attacks, while Nginx also have given out some security advisories on how to take care of DDos attacks. But at the endof the day router level security and firewalls are the way to go.I personally wouldn't rely on the server it self to handle the secutiry
Support :
They both provide support via mailing lists, IRC, and Stack Overflow. That brings both in par with each other.
Analysis :
Starting from architecture, Nginx fails in it’s core functionality when it comes to handling of dynamic server side scripting of multiple domains, however Nginx provides a faster and rugged solution for single domain files structures with static content, which is of course the major portion of domains on the internet space, however if you are looking at a more dynamic web content with resource (inodes etc) optimization then Nginx is no where near Apache. Hence both serves different purposes thus choosing which is better is always based on the web application you are running.
-
Nginx does not provide much control to the programmer but Apache on the otherhand is designed to that.
-
Due to its architectural and method of handing request Nginx fails in files access and goes in to wrong URI.
-
Centralization of .htaccess controls has failed Nginx in its certain aspects of security and manipulation, which of course due its inability to load or switch on and off different modules.
So if you are starting a project and not sure of what is required better to start with Apache.
Comments
Post a Comment