Apache vs Nginx - robbiehume/CS-Notes GitHub Wiki

Apache vs Nginx

Links

Comparison

  • Nginx was initially made to be a reverse proxy. Initially all it did was serve static files and reverse proxy to a backend server via HTTP. Since then, fastcgi, load balancing, and other various features have been added, but it's initial design purpose was to serve static files and reverse proxy, and it does that really well
  • Apache, on the contrary, is a general purpose web server. It can probably reverse proxy perfectly fine, but it was not designed to have a minimal memory footprint and as a result it requires more resources than Nginx does
  • Apache can also act as a reverse proxy and load balancer like Nginx. However, it's more often used as a backend server to leverage its modules and dynamic content processing
  • Nginx's configuration can be a little more difficult to understand than Apache's

Apache (httpd)

General notes

  • Install Apache Web Server on CentOS
  • 2nd most popular web server software (~31% of web servers)
  • It's part of the LAMP stack (Linux, Apache, MySql / MariaDB, PHP (or Python or Perl))
  • Uses Apache httpd (apache2) to listen and respond to network requests
  • Apache server is popular for its module system that provides high performance and flexibility. With Apache’s modules, users can easily add or remove functions to modify their server according to their needs

Nginx

  • Most popular web server software (~34% of web servers)
  • It is about 2 times faster than Apache for static content and consumes less memory as well
  • It was released with an asynchronous and event-driven architecture, allowing it to process many client requests simultaneously
  • It excels at efficiently delivering static files and can also act as a reverse proxy
    • This reverse proxy capability makes Nginx a valuable tool for load balancing, caching, and enhancing the performance and reliability of web applications