Nginx (1): Introduction

Source: Internet
Author: User

  Nginx is a lightweight event-driven HTTP and reverse proxy server for Web, as well as mail server.

  Apache: Thread/process oriented.

  c10k Challenge?
Network services in the processing of tens of thousands of client connections, often appear inefficient or even complete paralysis, which is called c10k problem.
The most important feature of the c10k problem is that the design of the program is not good enough, the relationship between the performance and the connection number and machine performance is often non-linear. For example: If the c10k problem is not considered, a classic select-based program can handle 1000 concurrent throughput on the old server, and it will often not handle the throughput of concurrency 2000 on a new server with twice times performance. This is because the consumption of a large number of operations at the time of the policy is linearly correlated with the current number of connections N. The relationship between the resource consumption of a single task and the current number of connections will be O (n). While the service program needs to handle tens of thousands of sockets simultaneously I/O processing, the accumulated resource consumption will be considerable, which obviously will cause the system throughput can not match the machine performance. To solve this problem, you must change the policy that provides service to the connection.

  Nginx Solution: Event-driven Architecture/single non-blocking Thread

  Event-driven: What is it?
A simple example is:
1) Accept the request
2) triggering events in a process (event)
3) Process processing and return results

The biggest difference between Nginx and Apache is that the mechanism for dealing with transactions is different:
Apache works in a common way, each request will monopolize a worker thread, and when the number of concurrent numbers is thousands of, thousands of of the threads are processing the request. This is a big challenge for the operating system, the memory footprint of the thread is very large, the thread context switch brings a lot of CPU overhead, the natural performance will not go up.
Nginx uses an asynchronous, non-blocking event handling mechanism, which is mentioned later in the article.

Nginx (1): Introduction

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.