Which of the following is better for LNMP and Lamp in high concurrency,

Source: Internet
Author: User
I saw an article saying that apache has a maximum concurrency of 3000 or 4000, and nginx is ten times higher than apache, but nginx is implemented based on caching, apache is actually 3000 or 4000. According to an article, the maximum number of concurrent connections allowed by apache is 3000 or 4000, and nginx is 10 times that of apache. However, nginx is implemented based on caching, apache is actually 3000 or 4000

Reply content:

According to an article, the maximum number of concurrent connections allowed by apache is 3000 or 4000, and nginx is 10 times that of apache, but nginx is implemented based on caching. apache is actually 3000 or 4000.

I don't know what the landlord actually refers to. The concurrency, request, and pv are different. The single-host apache concurrency cannot reach, and nginx cannot be generalized, the number of concurrency is ten times that of apache. nginx only acts as a proxy server. php-fpm is used to process php scripts, nginx is better at processing static files than apache. apache is a well-established web server with higher stability, including memory usage and cpu overhead.

There is basically no need to worry about this. Let's talk about it first!
In general, nginx is used for businesses. This is the standard, mainly to expand the architecture in the future to improve access convenience. In addition, it is impossible to say that apache is stable and unstable.
Under normal circumstances, php business bottlenecks are on the database, and php is free to use anything.
Unless the business is too abnormal or there is a problem with program writing, there will be no bottleneck at all.
If concurrency is 3000 or 4000, someone can solve the problem. On that day, tens of thousands of concurrent jobs have a solution.

On Linux Nginx and PHP-FPM combination is good. Nginx lightweight, stable, efficient, with PHP-FPM through FastCGI network communication, loose coupling.

Nginx is responsible for processing all the static resources, the PHP-FPM is focused on executing the PHP script, a PHP-FPM is blocked and will not cause Nginx to be blocked. A PHP-FPM process crashes, the main process of the PHP-FPM will automatically restart a working process, Nginx can configure fastcgi_next_upstream for failover, switch to another set of PHP-FPM services in upstream.

The PHP-FPM can be configured to listen to the pool of different ports, the working process in different pools is not affected, you can put the PHP-FPM of different pools in the Nginx upstream cluster.

Nginx is added to the AIO thread pool from 1.7.11, which can read and send files using multiple threads to prevent the worker process from being blocked. for attachments output after PHP authentication, PHP can use X-Accel-Redirect to tell the Nginx file path, so that Nginx can use its AIO thread pool to read files and send them to the browser, to avoid blocking PHP processes.
Header ("X-Accel-Redirect: $ filePath ");
// Compare the output file directly through PHP below (the PHP process will be blocked)
// Readfile ($ filePath );

NGINX 1.9.1 after reuseport is enabled, the number of requests processed per second is increased by 2 to 3 times, and the latency and stdev metrics are reduced.
Http://nginx.com/blog/socket-sharding-nginx-release-1-9-1/

For example, if you want to launch 100 PHP worker processes:
1. To use Apache + MOD_PHP, You need to enable 100 httpd working processes. Each httpd Working Process provides HTTP and PHP parsing services.
2. using Nginx + PHP-FPM enables 4 Nginx worker processes (assuming you have 4 CPU cores), and 100 PHP-FPM processes, a total of 104 processes, but it is worth noting that, 100 PHP-FPM processes certainly occupy less memory than 100 httpd processes, because the PHP-FPM does not provide HTTP Services, that is to say, Nginx + PHP-FPM than Apache + MOD_PHP can save 94 sets of HTTP service memory.
3. Nginx + Apache + MOD_PHP is the most memory-consuming combination.

For ease of use, the classic combination of Apache (prefork MPM) and MOD_PHP is also good for small and medium-sized websites. in addition, PHP officially does not recommend using event-based Apache MPM on Linux to run with MOD_PHP. For details, see:
Http://www.php.net/manual/zh/faq.installation.php#faq.installation.apa...

I recommendnginx.
nginxThe configuration is quite flexible.nginx,apacheI have never used it.

Our company also usesnginx.

Nginx does not process php dynamic pages. High concurrency NB refers to processing static pages. To handle real php requests, nginx also needs the same thing: fastcgi, which is another service and will be transferred to nginx for processing in case of php. Second, apache can load php into its own system in the form of mod, so both static pages and php are handled by itself. Of course, apache can also process php requests through fastcgi like nginx, and many companies do this. In this case, the concurrency is equal to that of nginx. Whether apache uses mod or fastcgi depends on the characteristics of your own business. Static or dynamic, high stability or high concurrency. The bottleneck for Processing dynamic content is not on apache or nginx, but on the php interpreter. If you want to pursue high concurrency, you can create a server cluster. This is the most real thing.

If the website is used, why notNginxAndApacheAdd oneVarnishWhat about it?

And,Nginx10 times more than static pages. If it is dynamic, the two should be similar.

The trend is to use nginx. Several companies I have stayed in have switched from apache to nginx.

Currently, we use LANMP, Nginx + Apache, and Nginx and PHP scripts on the front end to reverse proxy Apache!

Nginx is a reverse proxy, but apache is not. apache is more stable than nginx. apache is recommended.

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.