e-Zest members share technology ideas to foster digital transformation.

Apache vs Nginx

Written by Prasannasingh Bayas | Oct 18, 2016 6:15:09 AM


Today, the two most amazing open source servers, Apache HTTP and Nginx are ruling the internet world. Apache being the oldest is being used on large scale by the enterprises. However with the growing online traffic, Apache server deprives in terms of scaling and performance due to load of multiple processes, resulting into additional consumption of computer memory. On the other hand, Nginx being able to manage large amount traffic is the second most used proxy server. Nginx was written particularly to address the performance limitations of the Apache server. Thus, Nginx being an emerging technology is now slowly taking over Apache. 

One of our recent project was running on Apache server as it is very easy to install and flexible. Still, it was facing performance issues and was slowing down due to concurrent requests sent to the server. 

Why we decided to opt of NGINX server?

Our product was a build on Python having lots of static files for website where all static files were stored in Amazon S3 bucket. To access these files, multiple concurrent requests were sent to the server resulting into its slow performance. Therefore, a highly scalable server having a better performance was required to cache those static files and provide access to them within fraction of time. Nginx being fast at serving static files with good scalability, was able to handle multiple HTTP requests concurrently. This was due to its event-driven architecture and as a result, we decided to move from Apache to Nginx. Also, for serving static pages, Nginx server consumed less memory as compared to Apache, as in this case generating new process for every new request was not required. These processes being single-threaded were able to handle multiple connections asynchronously. Other than performance and memory, Nginx provided us with an added advantage of seamless support to Python. Web Server Gateway Interface (WSGI) being a common method of communication between Python and Nginx worked in multi-threaded and multi-process environment providing a good scalability for all kind of deployments. 

Our site was more of static one and hence opting for Nginx was the best decision for us. Furthermore, Nginx is open source, lightweight and provides all the core features of the web-server. But if you are looking for some advanced features like flexibility, documentation and security then Apache Server is for you. Both have their own pros and cons. So, opt for the server which completely suits your project needs.