LNMP and lamp Choose which is better in high concurrency,

Source: Internet
Author: User
See an article that Apache Max endure concurrency number is three thousand or four thousand, Nginx is his 10 times times, but Nginx is based on the implementation of cache, Apache is the real three thousand or four thousand

Reply content:

See an article that Apache Max endure concurrency number is three thousand or four thousand, Nginx is his 10 times times, but Nginx is based on the implementation of cache, Apache is the real three thousand or four thousand

Do not know what the landlord so-called Real refers to what, concurrent number, the number of requests, PV is not the same, single-machine Apache concurrency number can not reach 34,000, Nginx can not generalize, said concurrency is 10 times times the Apache, Nginx just acting as a proxy server role, The real process of PHP script is php-fpm, if you want to divide a good or bad, the ability of Nginx to handle static files than with Apache,apache after all, is the old Web server compared to the stability of the higher, there is memory, CPU overhead these are factors to be considered.

Basically there is no need to tangle this, you do it first!
General business we all use Nginx. This is standard, mainly for the future expansion of the architecture to improve the traffic convenience. In addition, Apache stability Nginx instability is no way to talk about, not this thing.
Under normal circumstances, PHP business bottlenecks are in the database above, as for the PHP side with what is arbitrary.
Unless the business is too perverted, or its own program is written in a problem, it is impossible to meet the bottleneck.
Can do concurrency three thousand or four thousand, you naturally have a way to solve. It's the day you have a tens of thousands of solution.

The combination of Nginx and php-fpm on Linux is good. Nginx lightweight, stable, efficient, with PHP-FPM through the FASTCGI network communication, loose coupling.

Nginx is responsible for all static resources, PHP-FPM is dedicated to execute PHP script, a php-fpm is blocked does not cause Nginx blocked. A php-fpm process crashes, and the PHP-FPM main process automatically restarts a worker process. Nginx can configure Fastcgi_next_upstream to implement failover and switch to another set of PHP-FPM services in upstream.

PHP-FPM can be configured to listen to different ports of the pool, different pool working process is not affected, you can put php-fpm different pool into nginx upstream cluster.

Nginx joins the AIO thread pool from 1.7.11 and is able to use multithreading to read and send files to prevent worker processes from being blocked. For an attachment that is exported after PHP authentication, PHP can tell the path of the Nginx file through X-accel-redirect, Let Nginx use its AIO thread pool to read the file and send it to the browser to avoid blocking the PHP process.
Header ("X-accel-redirect: $filePath");
Compare directly with PHP output file below (PHP process will be blocked)
ReadFile ($filePath);

NGINX 1.9.1 Enable Reuseport the perfect solution to the surprise cluster, the number of requests processed per second increased by 2 to 3 times times, while reducing the latency and stdev metrics.
http://nginx.com/blog/socket-sharding-nginx-release-1-9-1/

For example, you need to open 100 PHP work processes:
1. Using Apache + mod_php, you need to open 100 httpd worker processes, each HTTPD worker process provides HTTP service and PHP parsing service.
2. Using Nginx + php-fpm can open 4 nginx work process (assuming your CPU core number is 4), and 100 php-fpm process, a total of 104 processes, but it is worth noting that 100 PHP-FPM processes consume less memory than 100 httpd processes because PHP-FPM does not provide HTTP services, which means that Nginx + PHP-FPM can save 94 of the memory consumed by HTTP services than Apache + mod_php.
3. Using Nginx + Apache + mod_php is the most memory-consuming combination.

Easy to use, small and medium-sized Web sites directly deployed Apache (prefork MPM) +mod_php This classic combination is also good. Also note that PHP officially does not recommend using the threaded Apache MPM on Linux to run with mod_php, For details, please see:
Http://www.php.net/manual/zh/faq.installation.php#faq.installation.apa ...

I recommend it nginx .
nginxThe configuration is quite flexible, to tell the truth, since the use of nginx , I have no apache use.

Our company uses the same nginx .

First Nginx does not process PHP dynamic page, said it high concurrency NB, refers to the processing of static pages. Nginx to handle the real PHP request, also need one thing: fastcgi, it is another service, Nginx encountered PHP will be transferred to it to handle. Second, Apache can load PHP into its own system via mod, so both static pages and PHP are handled by themselves. Of course, Apache can also use fastcgi to handle PHP requests like nginx, and many companies do so, so the concurrency and nginx are comparable. As for whether Apache uses mods or fastcgi forms, it depends on the characteristics of your business. Static or dynamic, high stability or high concurrency. The bottleneck for handling dynamic content is not on Apache or Nginx, but on the PHP interpreter. Want to pursue high concurrency, to do server cluster it, this is the most real.

If it is a website, why not Nginx Apache add one on top of it Varnish ?

Also, Nginx the 10 times times should be said to be static pages. If it is dynamic, there should be little difference between the two.

The trend is to use nginx, a few of the companies I've stayed from Apache to Nginx.

Currently we are using Lanmp,nginx + Apache, front end with nginx,php script reverse proxy to Apache to deal with!

Nginx is a reverse proxy, and Apache is not, Apache is more stable than nginx, or it is recommended to use Apache.

  • 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.