Build a Web server 10 times times better than Apache Nginx 0.8.x+php 5.2.13 (FastCGI)

Source: Internet
Author: User
Keywords Php apache nginx web server Web server FastCGI
Tags apache configuration connections development environment file files high

This is the 6th article I wrote about building a "Nginx + PHP (FastCGI)" Web server. This series of articles as the earliest detailed introduction Nginx + PHP installation, configuration, use of one of the information to promote Nginx in the domestic development has produced a positive role. The 6th article mainly introduces the new smooth restart method of Nginx 0.8.x, and upgrades PHP to 5.2.14, and fixes the pear problem. Another MySQL 5.1.x upgrade to the 5.5.x series, the configuration file changes larger.

Nginx ("Engine X") is a high-performance HTTP and reverse proxy server and a IMAP/POP3/SMTP proxy server. Nginx was developed by Igor Sysoev, the second rambler.ru site for Russian traffic, which has been in the site for more than three years. Igor releases the source code in the form of a BSD-like license.

Nginx beyond the high performance and stability of Apache, so that domestic use of Nginx as a Web server more and more sites, including Sina blog, Sina Podcast, NetEase News, Tencent Network, Sohu blog, such as portal channel, six rooms, 56.com video sharing site, discuz! Official forum, water wood community and other well-known forums, Shanda online, Jinshan Xiaoyao network, such as network game sites, watercress, Renren, Yupoo albums, Kimshan PowerWord, Thunder Online and other emerging Web 2.0 Web sites.

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

In my experience, the server +apache (prefork mode) of 4GB memory generally can only handle 3,000 concurrent connections, because they will consume more than 3GB of memory and have to reserve 1GB of memory for the system. I used to have two Apache servers, because the maxclients set in the configuration file is 4000, and when the number of Apache concurrent connections reaches 3800, the server memory and swap space are full and crash.

And this Nginx 0.8.46 + PHP 5.2.14 (FastCGI) server in the 30,000 concurrent connection, the 10 open Nginx process consumes 150M of memory (15m*10=150m), the open 64 php-cgi process consumes 1280M memory (20m* 64=1280m), combined with the memory consumed by the system itself, consumes less than 2GB of memory. If the server memory is small, you can simply turn on 25 php-cgi processes so that the total amount of memory consumed by php-cgi is 500M.

Under 30,000 concurrent connections, access to Nginx 0.8.46 + PHP 5.2.14 (FastCGI) server PHP program is still fast. The following image shows the status monitoring page for Nginx, with an active connection number of 28457 (for the Nginx Monitor page configuration, as described in the Nginx configuration file that follows):

I production environment of two Nginx + PHP5 (FastCGI) server, running a number of general complex pure PHP dynamic program, single station Nginx + PHP5 (FastCGI) server running PHP Dynamic program processing capacity has exceeded "700 Requests/sec", Equivalent to 60 million (700*60*60*24=60480000) of traffic per day, and the server's system load is not high:

September 3, 2009 2:30, Jinshan game "Swordsman Love Network Edition three" temporary maintenance 1 hours, a large number of players officer net, forum, comment, customer service and other dynamic application Nginx server cluster, The number of Nginx active connections per server reaches 28,000, which is the highest concurrent value of the Nginx production environment that the author encounters.

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.