我生产环境下的两台Nginx + PHP5(FastCGI)服务器,跑多个一般复杂的纯PHP动态程序,从Nginx的日志可以统计出,单台Nginx + PHP5(FastCGI)服务器跑PHP动态程序的处理能力已经超过“700次请求/秒”,相当于每天可以承受6000万(700*60*60*24=60480000)的访问量:

  服务器①:DELL PowerEdge 1950(两颗 Intel(R) Xeon(R) 双核CPU 5120 @ 1.86GHz,4GB内存)

  服务器②:DELL PowerEdge 1950(一颗 Intel(R) Xeon(R) 双核CPU 5140 @ 2.33GHz,4GB内存)

  Web服务器:CentOS Linux 4.4 + Nginx 0.5.35 + PHP 5.2.6RC2(300 FastCGI Procees, unix-domain socket, with XCache)

  PHP程序内容:大量Memcached读写、少量MySQL读操作、大量文件队列写操作,然后计算,生成供<script type="text/javascript" src="http://www.domain.com/abc.php?u=1"></script>方式调用的JS代码或XML数据。

  网卡流量:1.5M~3M/秒

  请求数统计方式:从Nginx访问日志中,统计每分钟的第15秒共有多少条日志记录。
引用
grep "25/Mar/2008:15:01:15" /data1/logs/nginx.log | wc -l


  点击在新窗口中浏览此图片

  服务器的系统负载也不算高:

  点击在新窗口中浏览此图片

  总结:
  1、Nginx的处理能力超强,这块不是瓶颈。影响动态程序处理能力的因素主要在于PHP(FastCGI)。PHP(FastCGI)模式适用于执行时间较短的PHP程序,一般复杂的PHP程序执行时间应该在100ms以内,例如我的博客首页执行时间为38ms左右。假设一个PHP程序的执行时间为100ms,那么一个PHP(FastCGI)进程每秒可以处理完毕10个请求,300个FastCGI进程理论上每秒可以处理3000个请求。但是,在生产环境下,还将受到内存、系统负载等多方面的影响,例如300个PHP(FastCGI)进程需要占用2.4GB左右的内存,每秒处理超过1000个请求时,系统负载会飚升到100以上。因此,FastCGI的进程不是越多越好,而是够用就好。

  2、使用PHP的XCache、APC等加速模块会提供速度10倍左右,降低系统负载50倍以上。

  3、修改了spawn-fcgi,使它能够支持250个以上的FastCGI进程。

  4、如果PHP直接对MySQL进行大量读写操作,速度是达不到“700 request/sec”的,PHP与MySQL之间需要一个中间层,这是关键的技术。

  5、CPU的数量(多核算多个CPU,cat /proc/cpuinfo |grep -c processor)越多,系统负载越低,每秒能处理的请求数也越多。

  6、使用PHP 5.2.6RC2,因为它修正了PHP 5.2.5的“zend_mm_heap corrupted”错误BUG。PHP 5.2.5(FastCGI)在高并发请求情况下,经常会出现该错误。

  7、有空我将写一篇针对CentOS Linux环境Nginx + PHP5(FastCGI)安装、配置的最新博文。

Tags: , , , , , ,



技术大类 » Web服务器 | 评论(101) | 引用(0) | 阅读(133917)
komal Email
2021-8-28 16:38
Download System Mechanic Professional for Windows to optimize, repair, and protect your PC against Internet threats. System Mechanic is a quick, simple way to clear unwanted files from your PC .System Mechanic Download enables the users to make your device perform more efficiently and without any issues. Visit iolo system mechanic download Download and get the software for your device.
komal Email
2021-8-28 16:39
Download System Mechanic Professional for Windows to optimize, repair, and protect your PC against Internet threats. System Mechanic is a quick, simple way to clear unwanted files from your PC . System Mechanic Download enables the users to make your device perform more efficiently and without any issues.Visit system mechanic Download and get the software for your device.
komal Email
2021-8-28 16:39
Amazon Prime TV, and MyTV code. To register your device on the Amazon website you go to our website and enter the given code. The program requires the customer to have an Amazon account and a streaming device or TV. Amazon Prime Video is available on almost all streaming devices like Roku, Amazon Fire TV, Chromecast. For this, you just have to go to Amazon amazon.com/mytv with the help of the amazon activation code. You can visit our website for details of the entire process. You can do this by installing the Amazon.com/mytv Video application on your smart TV, or the digital media player or video game console connected to your TV by visiting the link provided by us in the de cription.or more information, you can contact our team at Amazon.com/mytv and get more and more information.
JOHN Email Homepage
2021-10-1 12:48
Are you looking for the best productivity suite, visit office.com/setup. and download Microsoft office products. In order to activate the office setup, use 25 digit office setup product key for office install and activation.
dfgfg Email Homepage
2022-5-18 17:57
The MetaMask login software functions as something of a wallet and a search engine. Purchase, transmit, receive, and trade digital products.metamask login | metamask login
shz Email
2022-7-16 18:22
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well..  online scams
shzz Email
2022-7-16 18:29
Please give some advice on how to achieve this kind of posts.  online scams
shzz Email
2022-7-16 18:35
This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post.  online scams
shz Email
2022-7-16 18:37
Going to graduate school was a positive decision for me. I enjoyed the coursework, the presentations, the fellow students, and the professors. And since my company reimbursed 100% of the tuition, the only cost that I had to pay on my own was for books and supplies. Otherwise, I received a free master’s degree. All that I had to invest was my time.  online scams
shzz Email
2022-7-16 18:39
Your blog provided us with valuable information to work with. Each & every tips of your post are awesome. Thanks a lot for sharing. Keep blogging,  online scams
shz Email
2022-7-16 18:40
I recently came across your article and have been reading along. I want to express my admiration of your writing skill and ability to make readers read from the beginning to the end. I would like to read newer posts and to share my thoughts with you.  online scams
shzz Email
2022-7-16 18:44
I would also motivate just about every person to save this web page for any favorite assistance to assist posted the appearance.  online scams
shz Email
2022-7-16 18:44
This is an excellent post I seen thanks to share it. It is really what I wanted to see hope in future you will continue for sharing such a excellent post.  online scams
shzz Email
2022-7-16 19:32
The blog and data is excellent and informative as well  online scams
shz Email
2022-8-26 00:32
I read that Post and got it fine and informative. Please share more like that...  Abdul Farooqi
SHZZ Email
2022-8-26 00:33
They're produced by the very best degree developers who will be distinguished for your polo dress creating. You'll find polo Ron Lauren inside exclusive array which include particular classes for men, women.  7 Figure Hustle Pro
shz Email
2022-8-26 00:36
This is a great article thanks for sharing this informative information. I will visit your blog regularly for some latest post. I will visit your blog regularly for Some latest post.  Abdul Farooqi
SHZZ Email
2022-8-26 00:36
I like viewing web sites which comprehend the price of delivering the excellent useful resource free of charge. I truly adored reading your posting. Thank you!  7 Figure Hustle Pro
SHZZ Email
2022-8-26 00:41
Welcome to the party of my life here you will learn everything about me.  Rachel Krider
SHZZ Email
2022-8-26 00:46
I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. In fact your creative writing abilities has inspired me to start my own Blog Engine blog now. Really the blogging is spreading its wings rapidly. Your write up is a fine example of it.  Rachel Krider
分页: 5/6 第一页 上页 1 2 3 4 5 6 下页 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]