Nginx + php set up super performance WEB server

  • 2020-05-06 12:11:57
  • OfStack

Nginx was developed by Igor Sysoev, the second most visited Rambler.ru site in Russia, and it has been running there for more than two and a half years. Igor publishes the source code as a class BSD license.

In the case of high concurrent connections, Nginx is a good alternative to Apache servers. Nginx can also be used as a 7-tier load balancing server. According to my test results, Nginx 0.6.31 + PHP 5.2.6 (FastCGI) can withstand more than 30,000 concurrent connections, which is 10 times that of Apache in the same environment.

In my experience, servers with 4GB memory +Apache (prefork mode) typically handle only 3,000 concurrent connections, because they will take up more than 3GB of memory and have to reserve 1GB for the system. I once had two Apache servers because the MaxClients set to 4000 in the configuration file crashed when the Apache concurrent connections reached 3800.

While this Nginx 0.6.31 + PHP 5.2.6 (FastCGI) server, with 30,000 concurrent connections, opened 10 Nginx processes consume 150M memory (15M*10=150M), opened 64 php-cgi processes consume 1280M memory (20M*64=1280M), plus the memory consumed by the system itself, the total consumption of less than 2GB memory. If the server has a small amount of memory, it is perfectly possible to open only 25 php-cgi processes, so that the total amount of memory consumed by php-cgi is only 500M.

Related articles: