The difference between Nginx and Apache as webserver

Source: Internet
Author: User

1. The driving modes used are different.

Nginx uses the Epoll non-clogging mode event driver.

Apache uses the plug-in mode event driver for select.

The difference between 2.fastcgi and CGI

When a user requests a Web service. The web will send requests to different CGI to handle according to different requirements.

The CGI pattern is that each time a request is requested, a new process is forked to process the request. Close the process after processing is complete.

fastcgi mode. is to establish a few CGI interfaces based on the configuration file when the server is started, the process is in memory, and when there is a request to connect, the CGI is activated to process the request connection. The CGI process does not close after processing is complete. Will wait for the next request connection again.

Because the process is created and shut down, it requires very large memory and CPU resources. So, more than that. The merits of the fastcgi pattern are self-evident in the case of multi-request processing.

3. Support modules for both

Apache supports a very great number of modules. and also more stable. and Nginx because the appearance is relatively late, so in this respect may not be inferior to Apache.

Nginx itself is a reverse proxy server, and supports 7-tier load balancing.

Apache's Rewrit features are much more powerful than nginx.

Nginx is multithreaded, and Apache is multi-process.

Nginx is an asynchronous plug, while Apache is clogged

Nginx processing Dynamic page is very chicken, generally only with the processing of static pages and reverse proxy.

Apache supports more modules than that. Able to support a much larger dynamic page. And the performance is relatively stable.

Assume that performance is required. Just use Nginx. The hypothesis needs to be stable. Just use Apache.


3.1.1 Clogging and non-clogging:

Clogging and non-clogging refers to whether an operation is run and returned at the end of the operation, or immediately.

For example, restaurant waiter for the user order, when the real user after the dish, the waiter will menu to the background chef, there are two ways:

    • First: Just wait in the out-of-the-way form until the chef finishes cooking and sends the dish to the form, and the waiter then sends the dish to the user's hands.
    • Another way: Wait a minute and ask the chef, is there a dish ready? Suppose you don't deal with other things first, and then ask them again;

The first is the way of plugging. The other one is non-clogging.

3.1.2 Synchronous and asynchronous:

Synchronization and Asynchrony are another concept. It is a property of the event itself. Also take the first order for example, the waiter directly with the chef to deal with, the dish out did not come out, the waiter direct guidance, but only when the chef will send the food to the waiter hand, the process is normal, this is the synchronization of events.

The same is a la carte, some restaurants have a special food transfer staff. After the chef has cooked the dishes. The dish-feeder sends the dish to the food transfer form and notifies the waiter that it becomes asynchronous. In fact, there are two types of asynchrony: notification and without notification. The one in front of you belongs to the one with the notice.

Some of the food-transfer staff may not be very active, and will not be able to inform you, you need to pay attention to the state from time to time. This is asynchronous without notification.

For synchronized events. You can only do it in a clogged way. And for an asynchronous event. Both clogging and non-clogging are possible.

There are two ways of non-clogging: actively querying and passively receiving messages.

Passivity does not mean that it must be bad. Here it is precisely the more efficient, because in the active query most of the query is doing a useless. Both are available for asynchronous events with notifications.

And for the non-notification, you can only use active query.



Nginx and Apache as webserver differences

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.