我生产环境下的两台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服务器 | 评论(54) | 引用(0) | 阅读(94399)
xujie777 Email
2012-5-18 16:25
coach outlet has become a popular shopping experience for consumers around the world, and a desirable distribution channel for manufacturer's and retailers.Getting your hands on coach outlet store online can be a hefty investment of hundreds of dollars.But do not despair,the Coach Outlet store could be the answer to your prayers.coach outlet online is your smart choice when you want to get the discount Coach accessory. You can find the exact Coach Bags and other accessory you want at a low price that's right for you. My dear friends, let the coach outlet online pave your way into the world of high fashion with their ultimate fashion factory.
xujie123
2012-5-21 11:16
Our online store offers you discounted Designer louis vuitton replica wallet at present. You could find them in desirable quality and price. If you don't mind high class louis vuitton uk, have a good time here.louis vuitton Store Online Handbags can also bring great accuracy as well as practical applicability and fashionable.Have you ever dreamed of being as charming as Madonna? Have you ever thought of becoming an envy of all your friends? If so, come to louis vuitton outlet.<br/>
xujie555
2012-5-21 13:40
coach factory outlet uses graceful accessories to match the classical logo of coach, which is the best combination of coach. The handmade coach products?can make you more charming and graceful.coach factory online provides people many coach goods. If you wish to snatch the coach handbag, then this best method is made for that you like for coach discount.coach factory outlet online is a fashion brand to ensure its quality. With designer coach shoulder bags, you will always attract people's attention. The bags will emphasize your personal style and taste.<br/>
xujie333
2012-5-21 15:01
coach outlet online Store guarantee that all the coach handbags offered are own high quality. In addition , all of them are sold at an unexpected low price.If you want to purchase, just visit their website.coach factory outlet is really sizzling kinds of shopping way for you. With the usage of the replica designer coach bags, you can surely be able to change your individual looks in a stunning manner.Coach bags on sale from the coach outlet are cheap or discount prices that you certainly will stand out from the crowd on your next camping trip!<br/>
Cheap Coach Bags Email Homepage
2012-7-14 17:36
The most typical spots that individuals go to any time Coach Outlet
coach88888888 Email
2012-8-13 17:47
If you desire to go to Coach Factory Outlet, but have no idea in which to go, you can research online. It is no doubt that there is drastically information and details about it for the reference.Coach Factory Online are loved by many people, when you walk in the street, you could see many people take coach styles.hat experts claim Coach Outlet Online shopping is in the changes they are available in.Coach Outlet will send you a coupon in the post to use in their upon only after you type a achieve. The Coach bags are customarily somewhat many than the ones in the stores.
Bottega Veneta Clutch Email Homepage
2012-8-24 15:00
but incredible providers have gotten to break downwards these obstructions Louis Vuitton Handbags
Coach Email Homepage
2012-11-3 14:47
"The Coach Outletengines that will likely power the J-31 we do know a bit mor.Coach Outlet  Those engines were actually revealed at the Zhuhai showCoach Outlet in 2008," Fisher said referring to an annual China air show. He beCoach Outletlieves the new J-31 engine is undergoing preliminary
ysq Homepage
2012-12-5 09:18
突破口在nginx入口处,关键在php-cgi消耗cpu和ram,解决这两个问题基本就好了,mysql只是php的小帮凶。
磨延城 Email Homepage
2013-10-21 20:54
磨途歌学习了
django Email Homepage
2013-11-30 19:42
Uggs Sale the ideal idea Coach Outlet Online  enough time to search for many of reduction Ugg boot. Like big portions? If you began ready your apartment, Coach Outlet  it's always best to consider the most effective way direct to the stage it could be to utilise your inventory throughout Coach Factory Outlet  concern, or maybe you basically won't destination stuff not enough.we're anti- whitening tray because Coach Outlet Online  i will be enjoy just get germ dog breeders
ADSF
2013-12-31 15:56
买轴承就到:www.jkzhoucheng.cn
夜无眠 Email
2015-11-13 21:36
windows   上的fastcgi是单线程的,比较蛋疼,应付不了高并发
分页: 3/3 第一页 上页 1 2 3 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]