Download Now

The biggest players in the web server business, Apache and IIS, have had the field to themselves for a long time. Now, however, they have to contend with a few seriously capable upstarts, the most prominent of which is Nginx (pronounced ‘engine-x’). This young turk was first developed in 2002 and boasts a growing, dedicated following among many webmasters. Nginx’s popularity is mainly due to being open-source and having the desirable combination of high performance and low resource consumption. It is important to note that Nginx is most often compared to Apache due to its similar open-source philosophy.

About Nginx

Nginx was developed in 2002 by Russian developer Igor Sysoev. Like Apache it is a free, open-source web server and runs on Linux, Unix, Mac OS X and sort of on Windows. (It has a proof of concept port and most features work on Windows, but there is no significant performance benefit.) Nginx is maintained by an active user community which provides plenty of personal help, even for newbies. However, Nginx does not have anywhere near the rich feature-set of Apache—which is both a pro (makes it fast and nimble) but also a con (is limited in its range of deployments and customize-ability). And because Nginx is newer, there is less documentation and support for it compared to Apache.

Nginx’s major selling point is that it is an asynchronous web server. Igor Sysoev was looking for a way to optimize and improve the web server’s architecture without having to massively increase the hardware resources. His solution was an event-driven, asynchronous, single-threaded architecture, as opposed to Apache’s (and IIS’s) synchronous, one-thread-per-process model. In traditional thread-based models, the server spawns a separate, dedicated thread for each client connection. As the number of clients increases, this might cause I/O blocking problems because there is an increasing number of processes that may have to wait for another process to release the resources (memory, CPU) they are currently holding. Also, creating individual processes hogs more limited hardware resources. Nginx, on the other hand, does not create a separate thread for each process. Instead it utilizes a master thread and worker processes within one main thread. Instead of being dedicated to each client, each worker is assigned to an event, that is, a request by a client for resources or processing. In this way, each worker can easily service several hundred clients, even with minimal memory and CPU, making Nginx very efficient for high-volume websites.

It will come as no surprise then, to hear that Nginx powers a large number of the world’s best-known high-traffic websites, among them Netflix, Hulu, Pinterest, Wordpress, Zynga and Airbnb. According to a Feb 2014 Netcraft survey, Nginx is in 3rd place with about 15% of the web server market, compared to leader Apache’s 38% slice of the pie.

Regarding performance, Nginx beats Apache hands-down by a large margin. Independent tests report that given the same baseline (defined as hardware resources and OS platform), Nginx can handle about 40% more traffic in an astonishing 300% less time. This makes Nginx about 4.2 times faster than Apache.

About Apache

The Apache HTTP server is an open source Web server application managed by the Apache Software Foundation. The server software is freely distributed, and the open source license means users can edit the underlying code to tweak performance and contribute to the future development of the program. Support, fixes and development are handled by the loyal user community and coordinated by the Apache Software Foundation.

Although Apache will run on all major operating systems (Linux, Windows, Unix, OSX, NetWare), it is most frequently used in combination with Linux. These two, combined with MySQL database and PHP scripting language, comprise the popular LAMP Web server solution.

Apache has always been the market leader almost since its inception in 1996, and in 2009 hit the 100-million website milestone. But as the old adage goes, when you’re at the top the only way is down. Apache’s once mighty dominance has been steadily eroded over the years by its ever-improving rivals; IIS from Microsoft is a close number 2 and Nginx represents the first of several young pretenders to the throne. Apache’s market share has dropped from about 60% in 2010 to 54% in June 2013, to a (relatively) woeful 38% in Feb 2014. Nevertheless, the Apache Software Foundation strives to keep their product in fighting form by releasing external modules for new features, such as a new extension to implement the master-threaded processing that makes Nginx so much faster than Apache.

As noted before, Apache is much slower than Nginx. But that’s not the whole story, because that statistic is for static pages. Apache actually has slighty better load and refresh times for dynamic pages. And Apache is the clear winner when you consider the number of features supported in a web server. Many of Apache’s features are implemented as compiled modules that extend the core functionality. Some of these features and modules are:

  • Server-side programming language support
  • Common language interfaces support (for instance Perl, Python, Tcl, and PHP)
  • Authentication modules: mod_access, mod_auth and mod_auth_digest
  • SSL/ TLS support module - mod_ssl
  • Proxy module - mod_proxy
  • URL rewriter - mod_rewrite
  • Custom log files - mod_log_config
  • Filtering support - mod_include and mod_ext_filter
  • Virtual hosting, which enables one machine to host and simultaneously serve several different websites.
  • Several well-developed GUI interfaces
  • Webpage compression - mod_gzip
  • Excellent security for hosted websites

Conclusion

Apache and Nginx are close rivals, and in fact they are spiritually much closer to each other than either is to IIS. Nginx’s major selling points are its blazing request-processing speed and its light weight. Apache can’t match it on performance but is much more established, has proper organizational support (Apache Software Foundation) instead of relying solely on the user community, and excellent security, a much larger feature-set (including masses of documentation). And unlike Nginx, Apache is fully supported on Windows.

However, one thing to keep in mind when comparing Nginx vs. Apache is that it doesn’t always have to be an either/or decision. Several webmasters combine the two in a hybrid solution that takes advantage of each one’s strengths. For example, you could use Nginx in front of Apache as a reverse proxy (a type of proxy server) for serving static content, for SSL termination, or in other combinations and configurations depending on your requirements.

Feature Nginx Apache
Supported OS Linux, Unix, macOS, Windows Linux, Unix, Windows, macOS
User support & fixes User community only Corporate support & user community
Cost & development Free, open source Free, open source
Security Very good Excellent
Features & documentation Good  Excellent
Performance Excellent Good

Ready to see
UpGuard in action?

Ready to save time and streamline your trust management process?