Announcement Announcement Module
Collapse
No announcement yet.
Apache VS Nginx Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Apache VS Nginx

    Apache is a webserver notable for playing a key role in the Initial growth of world wide web. Its developed and maintained by apache software foundation. One popular configuration, for instance, is to use Apache to server up static web pages and the mod_jk module to run Java and JSP code on Tomcat to make an interactive application. Another example is using mod_php to execute php scripts without having to use cgi.

    Apache Configuration file

    /usr/local/apache/conf/httpd.conf or /etc/httpd/conf/httpd.conf

    Nginx become more popular due to its event driven design which can make better use of the hardwares that apache's process driven design. Nginx can serve more concurrent clients with higher throughput than Apache on the same hardware.

    Nginx Configuration file

    By default, the configuration file is named nginx.conf and placed in the directory/usr/local/nginx/conf, /etc/nginx, or /usr/local/etc/nginx.
    Sample configuration:
    user www www;
    worker_processes 2;
    error_log /var/log/nginx-error.log info;
    events {
    use epoll;
    worker_connections 2048;
    }

    Apache works in Pre-forked or Worker multi process mode (MPM). Preforked mode creates one Thread per request, each of which handles one user request. Workers mode creates new process too, but each has more than one thread each of which handles one request per user. One workers mode handles more than one connection and one prefork mode handles only one connection. Workers mode use less memory than prefork mode, because processs consumes more memory than threads.

    Nginix works in Event-driven architecture method is capable of handling more number of clients with less threads compared to conventional way (1 thread for 1 client). In apache each thread is detected to handle one client so there will be many cases. When a certain threads need to be on hold due to I/O problems until certain data Is read from persistance layer in “accept” and delivered to the client. There should be the same number of threads as that of client. In EDA a method enables event to be processsed every time it takes place by designating each state . In other words , with less thread, CPU can be used more efficiently. By Event-driven it means that notifications or signals are used to mark the initiation or completion of a process. Thus, the resources can be used by other process until a process initiation event is triggered and resource can be allocated and released dynamically. This leads to the optimized use of memory and CPU. By Asynchronous it means that the threads can be executed concurrently with out blocking each other. It enhances the sharing of resources without being dedicated and blocked. Non-blocking means that, multiple clients can be handled by a single worker process as the resources are not blocked. Nginx do not create a new process or thread for a new request. Here the worker process accepts the requests and process thousands of it with the implementation of highly efficient event loops. Nginx is able to do the same work with less memory as it is utilized in a very optimized way.


    Using both apache and nginix
    • Apache is known for its power and Nginx for speed.
    • Nginx can serve up static content quicker, but Apache includes the modules needed to work with back end application servers and run scripting languages.
    • Nginx as a proxy server and Apache as the back end is a common approach to take.
    • Nginx includes advanced load balancing and caching abilities. Apache servers can, of course, be deployed in great numbers.

    Comparision of Apache & Nginix
    • Nginx is based on event-driven architecture. Apache is based on process-driven architecture. It is interesting to note that Apache in its earliest release was not having multitasking architecture. Later Apache MPM (multi-processing module) was added to achieve this.
    • Nginx doesn’t create a new process for a new request. Apache creates a new process for each request.
    • In Nginx, memory consumption is very low for serving static pages. But, Apache’s nature of creating new process for each request increases the memory consumption.
    • Several benchmarking results indicates that when compared to Apache, Nginx is extremely fast for serving static pages
    • In complex configurations situation, when compared to Nginx, Apache can be configured easily as it comes with lot of configuration features to cover wide range of requirements.
    • In general, Nginx have less components to add more features. But Apache has tons of features and provides lot more functionality than Nginx.
    • Nginx do not support Operating Systems like OpenVMS and IBMi. But Apache supports much wider range of Operating Systems.
    • Since Nginx comes only with core features that are required for a web server, it is lightweight when compared to Apache.
    • The performance and scalability of Nginx is not completely dependent on hardware resources, whereas the performance and scalability of the Apache is dependent on underlying hardware resources like memory and CPU.
Tag Cloud Tag Cloud Module
Collapse
Working...
X