日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
互聯(lián)網(wǎng)創(chuàng)業(yè)的準(zhǔn)備:WebServer

測(cè)試環(huán)境:

分宜網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),分宜網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為分宜上千提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的分宜做網(wǎng)站的公司定做!

vr.org 的 VPS

CPU:2核共享

內(nèi)存:512M獨(dú)立

OS:Ubuntu 12.04 LTS x64

 
 
 
  1. uname -a  
  2.  
  3. u1@www:~$ cat /etc/lsb-release   
  4. DISTRIB_ID=Ubuntu  
  5. DISTRIB_RELEASE=12.04  
  6. DISTRIB_CODENAME=precise  
  7. DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS" 
  8. u1@www:~$ uname -a  
  9. Linux www.shaixuan.org 3.4.0-cloud #1 SMP Thu May 24 04:54:53 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux  
  10. u1@www:~$ top 
  11.  
  12. top - 23:57:39 up  1:38,  2 users,  load average: 0.04, 0.03, 0.16  
  13. Tasks:  55 total,   1 running,  54 sleeping,   0 stopped,   0 zombie  
  14. Cpu(s):  0.7%us,  0.4%sy,  0.0%ni, 97.6%id,  0.1%wa,  0.0%hi,  0.1%si,  1.1%st  
  15. Mem:    506764k total,   125264k used,   381500k free,     7736k buffers  
  16. Swap:   499708k total,        0k used,   499708k free,    70096k cached 

軟件版本:Apache httpd 2.4.3、nginx 1.2.3、lighttpd 1.4.31、php 5.4.6

結(jié)論:

靜態(tài)服務(wù)器:

并發(fā):nginx(17000)> lighttpd(14000)> apache(5000)

注意:lighttpd開(kāi)啟gzip壓縮時(shí),無(wú)法禁用etag……不建議使用。參考:《高性能網(wǎng)站建設(shè)指南》

動(dòng)態(tài)服務(wù)器:

大約并發(fā):nginx + php-fpm(1500)> lighttpd + spawn-fcgi(1000)>apache + php module(400)

注意:web server與fastcgi在同一個(gè)機(jī)器時(shí),建議使用unix domain socket,比tcp socket效果好一點(diǎn)點(diǎn)。

雖然apache httpd 2.4 像 nginx一樣使用了epoll,但是性能還是比nginx低很多。

服務(wù)器OS一定要使用Linux 2.6內(nèi)核及更高,因?yàn)椴拍苤С謊poll。

建議服務(wù)器使用Ubuntu server x64,因?yàn)楣こ處烶C使用Ubuntu x64較多(Ubuntu的顯卡驅(qū)動(dòng)安裝方便),這樣編譯部署都一致。

如果服務(wù)器使用CentOS x64,則工程師PC使用Fedora x64,即可保持一致。

因?yàn)閮?nèi)核都是一樣的,Ubuntu、CentOS等各個(gè)Linux發(fā)行版對(duì)服務(wù)器來(lái)說(shuō)沒(méi)有區(qū)別,所以挑一個(gè)順手的即可。

參考互聯(lián)網(wǎng)公司的web server:

163.com靜態(tài)nginx
t.qq.com靜態(tài)squid,動(dòng)態(tài)nginx
taobao.com靜態(tài)Tengine,動(dòng)態(tài)Tengine(nginx衍生版)
小米論壇靜態(tài)Tengine,動(dòng)態(tài)Tengine
百度靜態(tài)lighttpd,動(dòng)態(tài)lighttpd(有etag)

測(cè)試過(guò)程:

Apache httpd 2.4.3

編譯參數(shù):

 
 
 
  1. ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/home/u1/pcre-8.30 --enable-so --enable-rewrite --enable-deflate --with-module=metadata:expires 

MPM:默認(rèn)event

 
 
 
  1. httpd -V  
  2.  
  3. root@www:/usr/local/apache2/bin# ./httpd -V  
  4. Server version: Apache/2.4.3 (Unix)  
  5. Server built:   Aug 26 2012 10:27:04  
  6. Server's Module Magic Number: 20120211:6  
  7. Server loaded:  APR 1.4.6, APR-UTIL 1.4.1  
  8. Compiled using: APR 1.4.6, APR-UTIL 1.4.1  
  9. Architecture:   64-bit 
  10. Server MPM:     event  
  11.   threaded:     yes (fixed thread count)  
  12.     forked:     yes (variable process count)  
  13. Server compiled with....  
  14.  -D APR_HAS_SENDFILE  
  15.  -D APR_HAS_MMAP  
  16.  -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)  
  17.  -D APR_USE_SYSVSEM_SERIALIZE  
  18.  -D APR_USE_PTHREAD_SERIALIZE  
  19.  -D APR_HAS_OTHER_CHILD  
  20.  -D AP_HAVE_RELIABLE_PIPED_LOGS  
  21.  -D DYNAMIC_MODULE_LIMIT=256  
  22.  -D HTTPD_ROOT="/usr/local/apache2" 
  23.  -D SUEXEC_BIN="/usr/local/apache2/bin/suexec" 
  24.  -D DEFAULT_PIDLOG="logs/httpd.pid" 
  25.  -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" 
  26.  -D DEFAULT_ERRORLOG="logs/error_log" 
  27.  -D AP_TYPES_CONFIG_FILE="conf/mime.types" 
  28.  -D SERVER_CONFIG_FILE="conf/httpd.conf" 

默認(rèn)并發(fā)400,MaxRequestWorkers即以前的MaxClients,參考:http://httpd.apache.org/docs/2.4/mod/mpm_common.html#MaxRequestWorkers

 
 
 
  1.  
  2.     StartServers             3     
  3.     MinSpareThreads         75    
  4.     MaxSpareThreads        250   
  5.     ThreadsPerChild         25    
  6.     MaxRequestWorkers      400   
  7.     MaxConnectionsPerChild   0     
  8.  

并發(fā)改成40000,提示錯(cuò)誤,加上ServerLimit即可:

 
 
 
  1. u1@www:~$ sudo vi /usr/local/apache2/conf/extra/httpd-mpm.conf   
  2. u1@www:~$ sudo vi /usr/local/apache2/conf/httpd.conf  
  3. u1@www:~$ sudo /etc/init.d/apache2 restart  
  4. AH00515: WARNING: MaxRequestWorkers of 40000 would require 1600 servers and   
  5.  would exceed ServerLimit of 16, decreasing to 400.  
  6.  To increase, please see the ServerLimit directive. 

nginx 1.2.3:

編譯參數(shù):

 
 
 
  1. ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre 

lighttpd 1.4.31:

默認(rèn)并發(fā)1024,server.max-fds最大可修改為65535,server.max-connections最大可修改為32767:

 
 
 
  1. ##  
  2.  ## As lighttpd is a single-threaded server, its main resource limit is 
  3.  ## the number of file descriptors, which is set to 1024 by default (on 
  4.  ## most systems).  
  5.  ##  
  6.  ## If you are running a high-traffic site you might want to increase this  
  7.  ## limit by setting server.max-fds.  
  8.  ##  
  9.  ## Changing this setting requires root permissions on startup. see  
  10.  ## server.username/server.groupname.  
  11.  ##  
  12.  ## By default lighttpd would not change the operation system default.  
  13.  ## But setting it to 2048 is a better default for busy servers.  
  14.  ##  
  15.  server.max-fds = 2048  
  16.    
  17.  ##  
  18.  ## Fine tuning for the request handling  
  19.  ##  
  20.  ## max-connections == max-fds/2 (maybe /3)  
  21.  ## means the other file handles are used for fastcgi/files  
  22.  ##  
  23.  server.max-connections = 1024 

#p#

1、靜態(tài)服務(wù)器測(cè)試

即apache、nginx、lighttpd性能對(duì)比。

服務(wù)器相同配置 :

開(kāi)啟gzip、關(guān)閉etag

測(cè)試程序和web server在同一臺(tái)服務(wù)器上,測(cè)試命令:

 
 
 
  1. ab -c 1000 -n 50000 http://localhost/index.html  
  2. siege -c 1000 -r 20 http://localhost/index.html 

apache:html文件13k,gzip壓縮為4.9k

header:

apache

測(cè)試結(jié)果:

并發(fā) httpd子進(jìn)程數(shù)整機(jī)512M內(nèi)存使用率CPU使用率iowait
0319%00
10001030%38%0
30001460%38%0
500010-3065%-99%20%-40%0-30
800010099%3%-50%20-100

nginx:html文件13.2k,gzip壓縮為5.34k

header:

 
 
 
  1. nginx  
  2.  
  3. Request URL:http://shaixuan.org/index.html  
  4. Request Method:GET  
  5. Status Code:200 OK  
  6. Request Headersview source  
  7. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
  8. Accept-Charset:UTF-8,*;q=0.5  
  9. Accept-Encoding:gzip,deflate,sdch  
  10. Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4  
  11. Cache-Control:no-cache  
  12. Connection:keep-alive  
  13. Host:shaixuan.org  
  14. Pragma:no-cache  
  15. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1251.2 Safari/537.8  
  16. Response Headersview source  
  17. Connection:keep-alive  
  18. Content-Encoding:gzip  
  19. Content-Type:text/html  
  20. Date:Mon, 03 Sep 2012 13:19:23 GMT  
  21. Last-Modified:Mon, 03 Sep 2012 12:33:45 GMT  
  22. Server:nginx/1.2.3  
  23. Transfer-Encoding:chunked 

測(cè)試結(jié)果:

并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowait
029%00
100035%40%0
300046%43%0
500055%42%0-1
800065%45%0
1500088%45%0
1700097%47%0

lighttpd:html文件13k,gzip壓縮為4.96k

header:

 
 
 
  1. lighttpd  
  2.  
  3. Request URL:http://shaixuan.org/  
  4. Request Method:GET  
  5. Status Code:200 OK  
  6. Request Headersview source  
  7. Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 
  8. Accept-Charset:UTF-8,*;q=0.5 
  9. Accept-Encoding:gzip,deflate,sdch  
  10. Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.4 
  11. Cache-Control:max-age=0 
  12. Connection:keep-alive  
  13. Host:shaixuan.org  
  14. Pragma:no-cache  
  15. User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.8 (KHTML, like Gecko) Chrome/23.0.1251.2 Safari/537.8 
  16. Response Headersview source  
  17. Accept-Ranges:bytes  
  18. Content-Encoding:gzip  
  19. Content-Length:4819 
  20. Content-Type:text/html  
  21. Date:Tue, 04 Sep 2012 12:51:42 GMT  
  22. ETag:"1028714895" 
  23. Last-Modified:Tue, 04 Sep 2012 12:29:10 GMT  
  24. Server:lighttpd/1.4.31 
  25. Vary:Accept-Encoding 

測(cè)試結(jié)果:

并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowait
029%00
1000  0
300046%41%0-6
500060%40%0-1
800075%45%0
1200081%35%0
1400087%36%0
1600099%40%0

#p#

2、動(dòng)態(tài)服務(wù)器測(cè)試

即apache + php module、nginx + php-fpm、nginx + php-cgi、lighttpd + spawn-fcgi對(duì)比。

測(cè)試命令:

 
 
 
  1. siege -c 1200 -r 20 http://localhost/phpinfo.php  
  2. /usr/local/apache2/bin/ab -c 100 -t 50 http://localhost/phpinfo.php 

php版本 5.4.6,測(cè)試代碼phpinfo();

apache + php module:php文件63.57k,gzip壓縮為11.21k

測(cè)試結(jié)果:

并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowait
029%00
10068%8%0
20072%10%0
40095%10%0
60099%15%1-15

nginx + php-fpm(多個(gè)php-fpm子進(jìn)程):php文件57.41k,gzip壓縮為10.84k

phpinfo顯示Server API:FPM/FastCGI

fastcgi的socket方式:tcp socket

php編譯參數(shù):

 
 
 
  1. ./configure --prefix=/usr/local/php-fpm --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-curl --with-mcrypt --enable-mbstring --enable-pdo --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-zip 

測(cè)試結(jié)果:

 并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowaitsiege成功率
033%00 
10037%8%0100%
200    
40045%10%099.96%
80055% 14個(gè)php-fpm,每個(gè)5.9M12%096.31%
100060%10%090.77%
120069%,Linux file限制,測(cè)試出錯(cuò)30%  

nginx + php-fpm(多個(gè)php-fpm子進(jìn)程):php文件54.57k,gzip壓縮為9.16k

phpinfo顯示Server API:FPM/FastCGI

fastcgi的socket方式:unix domain socket

測(cè)試結(jié)果:

并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowaitsiege成功率
032%00 
10035%7%0100%
20040%12%0100%
40043%14%0100%
80055%14%096.70%
100060% 21個(gè)php-fpm,每個(gè)5.9M14%092.02%
120050%,Linux file限制,測(cè)試出錯(cuò)50% 049%

nginx + 一個(gè)php-cgi:php文件64.65k,gzip壓縮為11.89k 

sudo /usr/local/php-fpm/bin/php-cgi -b 9000 -q

php-cgi可以常駐(long-live)監(jiān)聽(tīng)一個(gè)端口,所以是fastcgi,但是由于沒(méi)有進(jìn)程管理器,只能啟動(dòng)一個(gè)進(jìn)程,并發(fā)承受力低。

phpinfo顯示Server API:FPM/FastCGI

測(cè)試結(jié)果:

并發(fā)100時(shí),經(jīng)過(guò)5秒,php-cgi崩潰退出。

lighttpd + lighttpd自帶的spawn-fcgi進(jìn)程管理器(多個(gè)php-cgi子進(jìn)程):php文件58.68k,gzip壓縮為9.83k 

phpinfo顯示Server API:CGI/FastCGI

fastcgi的socket方式:unix domain socket

lighttpd的fastcgi.conf配置:

 
 
 
  1. fastcgi.server  
  2.  fastcgi.server = ( ".php" => 
  3.                     ( "php-local" => 
  4.                       (  
  5.                         "socket" => socket_dir + "/php-fastcgi-1.socket",  
  6.                         "bin-path" => "/usr/local/php-fpm/bin/php-cgi",  
  7.                         "max-procs" => 2,  
  8.                         "broken-scriptfilename" => "enable",  
  9.                         "bin-environment" => (  
  10.                           "PHP_FCGI_CHILDREN" => "16",  
  11.                           "PHP_FCGI_MAX_REQUESTS" => "500",  
  12.                         ),  
  13.                       )  
  14.                     ), 

測(cè)試結(jié)果:

 并發(fā)整機(jī)512M內(nèi)存使用率CPU使用率iowaitsiege成功率
053% 34個(gè)php-cgi進(jìn)程,每個(gè)3M00 
10065% 每個(gè)5.3M10%0 
20065% 每個(gè)5.7M10%0100%
40072% 每個(gè)5.7M11%0100%
80084% 每個(gè)5.7M10%099.49%
100090% 每個(gè)5.7M12%097.41%
1200Linux file限制,測(cè)試出錯(cuò)   

 

參考資料:

http://www.cnblogs.com/killkill/archive/2010/04/14/1711810.html

http://httpd.apache.org/docs/2.4/mod/mpm_common.html#MaxRequestWorkers

http://www.php.net/manual/zh/install.fpm.php

http://www.niutian365.com/blog/article.asp?id=263

http://redmine.lighttpd.net/projects/1/wiki/Docs_ModCompress

http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_PerformanceFastCGI

http://php.net/manual/zh/install.unix.lighttpd-14.php

http://www.361way.com/mpm/1052.html

http://blog.chinaunix.net/uid-13939710-id-2861331.html

http://www.yylib.com/blog/?p=70

http://kb.cnblogs.com/page/95605/

http://www.dbanotes.net/web/lighttpd_spawn-fcgi.html

http://www.mike.org.cn/articles/what-is-cgi-fastcgi-php-fpm-spawn-fcgi/

http://www.php.net/manual/zh/install.unix.apache2.php

http://ferreousbox.iteye.com/blog/196212

http://nigelzeng.iteye.com/blog/1197339

http://blog.csdn.net/tujiyue/article/details/7027134

原文鏈接:http://www.cnblogs.com/sink_cup/archive/2012/09/14/web_server.html


網(wǎng)頁(yè)題目:互聯(lián)網(wǎng)創(chuàng)業(yè)的準(zhǔn)備:WebServer
網(wǎng)頁(yè)地址:http://www.5511xx.com/article/ccdisgp.html