您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 创业/孵化 > 互联网创业的八个准备
互联网创业的八个准备互联网创业的准备:WebServer互联网创业的准备,WebServer怎么去选择?本文讲解了目前比较流行的webserver搭配分别是Apache+Nginx+Lighttpd与PHP+Module+FastCGI!测试环境:vr.org的VPSCPU:2核共享内存:512M独立OS:Ubuntu12.04LTSx641.uname-a2.3.u1@~$cat/etc/lsb-release4.DISTRIB_ID=Ubuntu5.DISTRIB_RELEASE=12.046.DISTRIB_CODENAME=precise7.DISTRIB_DESCRIPTION=Ubuntu12.04LTS8.u1@~$uname-a9.Linux:54:53EDT2012x86_64x86_64x86_64GNU/Linux10.u1@~$top11.12.top-23:57:39up1:38,2users,loadaverage:0.04,0.03,0.1613.Tasks:55total,1running,54sleeping,0stopped,0zombie14.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%st15.Mem:506764ktotal,125264kused,381500kfree,7736kbuffers16.Swap:499708ktotal,0kused,499708kfree,70096kcached软件版本:Apachehttpd2.4.3、nginx1.2.3、lighttpd1.4.31、php5.4.6结论:静态服务器:并发:nginx(17000)lighttpd(14000)apache(5000)注意:lighttpd开启gzip压缩时,无法禁用etag……不建议使用。参考:《高性能网站建设指南》动态服务器:大约并发:nginx+php-fpm(1500)lighttpd+spawn-fcgi(1000)apache+phpmodule(400)注意:webserver与fastcgi在同一个机器时,建议使用unixdomainsocket,比tcpsocket效果好一点点。虽然apachehttpd2.4像nginx一样使用了epoll,但是性能还是比nginx低很多。服务器OS一定要使用Linux2.6内核及更高,因为才能支持epoll。建议服务器使用Ubuntuserverx64,因为工程师PC使用Ubuntux64较多(Ubuntu的显卡驱动安装方便),这样编译部署都一致。如果服务器使用CentOSx64,则工程师PC使用Fedorax64,即可保持一致。因为内核都是一样的,Ubuntu、CentOS等各个Linux发行版对服务器来说没有区别,所以挑一个顺手的即可。参考互联网公司的webserver:163.com静态nginxt.qq.com静态squid,动态nginxtaobao.com静态Tengine,动态Tengine(nginx衍生版)小米论坛静态Tengine,动态Tengine百度静态lighttpd,动态lighttpd(有etag)测试过程:Apachehttpd2.4.3编译参数: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:expiresMPM:默认event1.httpd-V2.3.root@:Apache/2.4.3(Unix)5.Serverbuilt:Aug26201210:27:046.Server'sModuleMagicNumber:20120211:67.Serverloaded:APR1.4.6,APR-UTIL1.4.18.Compiledusing:APR1.4.6,APR-UTIL1.4.19.Architecture:64-bit10.ServerMPM:event11.threaded:yes(fixedthreadcount)12.forked:yes(variableprocesscount)13.Servercompiledwith....14.-DAPR_HAS_SENDFILE15.-DAPR_HAS_MMAP16.-DAPR_HAVE_IPV6(IPv4-mappedaddressesenabled)17.-DAPR_USE_SYSVSEM_SERIALIZE18.-DAPR_USE_PTHREAD_SERIALIZE19.-DAPR_HAS_OTHER_CHILD20.-DAP_HAVE_RELIABLE_PIPED_LOGS21.-DDYNAMIC_MODULE_LIMIT=25622.-DHTTPD_ROOT=/usr/local/apache223.-DSUEXEC_BIN=/usr/local/apache2/bin/suexec24.-DDEFAULT_PIDLOG=logs/httpd.pid25.-DDEFAULT_SCOREBOARD=logs/apache_runtime_status26.-DDEFAULT_ERRORLOG=logs/error_log27.-DAP_TYPES_CONFIG_FILE=conf/mime.types28.-DSERVER_CONFIG_FILE=conf/httpd.conf默认并发400,MaxRequestWorkers即以前的MaxClients,参考:并发改成40000,提示错误,加上ServerLimit即可:1.u1@~$sudovi/usr/local/apache2/conf/extra/httpd-mpm.conf2.u1@~$sudovi/usr/local/apache2/conf/httpd.conf3.u1@~$sudo/etc/init.d/apache2restart4.AH00515:WARNING:MaxRequestWorkersof40000wouldrequire1600serversand5.wouldexceedServerLimitof16,decreasingto400.6.Toincrease,pleaseseetheServerLimitdirective.nginx1.2.3:编译参数:1../configure--prefix=/usr/local/nginx--with-pcre=/usr/local/pcrelighttpd1.4.31:默认并发1024,server.max-fds最大可修改为65535,server.max-connections最大可修改为32767:1.##2.##Aslighttpdisasingle-threadedserver,itsmainresourcelimitis3.##thenumberoffiledescriptors,whichissetto1024bydefault(on4.##mostsystems).5.##6.##Ifyouarerunningahigh-trafficsiteyoumightwanttoincreasethis7.##limitbysettingserver.max-fds.8.##9.##Changingthissettingrequiresrootpermissionsonstartup.see10.##server.username/server.groupname.11.##12.##Bydefaultlighttpdwouldnotchangetheoperationsystemdefault.13.##Butsettingitto2048isabetterdefaultforbusyservers.14.##15.server.max-fds=204816.17.##18.##Finetuningfortherequesthandling19.##20.##max-connections==max-fds/2(maybe/3)21.##meanstheotherfilehandlesareusedforfastcgi/files22.##23.server.max-connections=10241、静态服务器测试即apache、nginx、lighttpd性能对比。服务器相同配置:开启gzip、关闭etag测试程序和webserver在同一台服务器上,测试命令:1.ab-c1000-n50000://localhost/index.htmlapache:html文件13k,gzip压缩为4.9kheader:apache测试结果:并发httpd子进程数整机512M内存使用率CPU使用率iowait0319%0010001030%38%030001460%38%0500010-3065%-99%20%-40%0-30800010099%3%-50%20-100nginx:html文件13.2k,gzip压缩为5.34kheader:1.nginx2.3.RequestURL::GET5.StatusCode:200OK6.RequestHeadersviewsource7.Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.88.Accept-Charset:UTF-8,*;q=0.59.Accept-Encoding:gzip,deflate,sdch10.Accept-Language:zh-CN,zh;q=0.8,en-US;q=0.6,en;q=0.411.Cache-Control:no-cache12.Connection:keep-alive13.Host:shaixuan.org14.Pragma:no-cache15.User-Agent:Mozilla/5.0(WindowsNT6.1;WOW64)AppleWebKit/537.8(KHTML,likeGecko)Chrome/23.0.1251.2Safari/537.816.ResponseHeadersviewsource17.Connection:keep-alive18.Content-Encoding:gzip19.Content-Type:text/html20.Date:Mon,03Sep201213:19:23GMT21.L
本文标题:互联网创业的八个准备
链接地址:https://www.777doc.com/doc-6430578 .html