2013年最后一个月 12月 全球Web服务器份额iis狂升
2013年12月,Netcraft从全球861,023,217家网站调查数据统计 Apache 相比 11月份 下滑 3 个点,占有率跌到 41.26% IIS 上升明显,比 11 月份上升 4 个点, 占有率升到 28.08% Nginx 稳步上升,占有率达到 14.69% Google 下跌至 4.44%
2013年12月,Netcraft从全球861,023,217家网站调查数据统计 Apache 相比 11月份 下滑 3 个点,占有率跌到 41.26% IIS 上升明显,比 11 月份上升 4 个点, 占有率升到 28.08% Nginx 稳步上升,占有率达到 14.69% Google 下跌至 4.44%
原来一直用php-fpm ,但是更新好像不太及时,上次改了半天ports 才通过编译 /usr/ports/www/spawn-fcgi 以后可以用这个了,但重要载入php.ini 要重起
OS & Hardware FreeBSD 7.1 AMD64, dual-core CPU 4GB RAM Purpose Web server & reverse proxy Load description 45K inactive keep-alive connections HTTP request is about 5,000 req/s, mostly small static files, all are cached by VM System config /boot/loader.conf: vm.kmem_size=1844M kern.maxbcache=64M kern.ipc.maxpipekva=4M /etc/sysctl.conf: kern.ipc.nmbjumbop=192000 kern.ipc.nmbclusters=229376 kern.ipc.maxsockets=204800 net.inet.tcp.maxtcptw=163840 kern.maxfiles=204800 kern.ipc.somaxconn=4096 Retrieved from “http://wiki.nginx.org/FreeBSDOptimizations"
#!/bin/sh date today=date +"%Y_%m_%d" logdir=/pub/log daydir=/pub/log/$today expdays=7 if [ ! -d $daydir ] ; then mkdir -p $daydir fi cp /pub/log/wwwlogs.log $daydir/wwwlogs.log #清空当前日志 /usr/bin/true > /pub/log/wwwlogs.log #删除7天前的过期文件 #find $daydir -type d -mtime +$expdays -maxdepth 1 | xargs rm -rf #每天12点运行 #0 0 * * * /cut_nginx_log.sh
从网上搜索到的规则,但不能用,修改了一下, rewrite ^/index.html$ /index.php; rewrite ^/category$ /index.php; rewrite ^/feed-c([0-9]+).xml$ /feed.php?cat=$1; rewrite ^/feed-b([0-9]+).xml$ /feed.php?brand=$1; rewrite ^/feed.xml$ /feed.php; rewrite ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ /category.php?id=$1&brand;=$2&price;_min=$3&price;_max=$4&filter;_attr=$5&page;=$6&sort;=$7ℴ=$8; rewrite ^/category-([0-9]+)-b([0-9]+)-min([0-9]+)-max([0-9]+)-attr([^-]*)(.*).html$ /category.php?id=$1&brand;=$2&price;_min=$3&price;_max=$4&filter;_attr=$5; rewrite ^/category-([0-9]+)-b([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ /category.php?id=$1&brand;=$2&page;=$3&sort;=$4ℴ=$5; rewrite ^/category-([0-9]+)-b([0-9]+)-([0-9]+)(.*).html$ /category.php?id=$1&brand;=$2&page;=$3; rewrite ^/category-([0-9]+)-b([0-9]+)(.*).html$ /category.php?id=$1&brand;=$2; rewrite ^/category-([0-9]+)(.*).html$ /category.php?id=$1; rewrite ^/goods-([0-9]+)(.*).html$ /goods.php?id=$1; rewrite ^/article_cat-([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+)(.*).html$ /article_cat.php?id=$1&page;=$2&sort;=$3ℴ=$4; rewrite ^/article_cat-([0-9]+)-([0-9]+)(.*).html$ /article_cat.php?id=$1&page;=$2; rewrite ^/article_cat-([0-9]+)(.*).html$ /article_cat.php?id=$1; rewrite ^/article-([0-9]+)(.*).html$ /article.php?id=$1; rewrite ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)-(.+)-([a-zA-Z]+).html /brand.php?id=$1&cat;=$2&page;=$3&sort;=$4ℴ=$5; rewrite ^/brand-([0-9]+)-c([0-9]+)-([0-9]+)(.*).html /brand.php?id=$1&cat;=$2&page;=$3; rewrite ^/brand-([0-9]+)-c([0-9]+)(.*).html /brand.php?id=$1&cat;=$2; rewrite ^/brand-([0-9]+)(.*).html /brand.php?id=$1; rewrite ^/tag-(.*).html /search.php?keywords=$1; rewrite ^/snatch-([0-9]+).html$ /snatch.php?id=$1; rewrite ^/group_buy-([0-9]+).html$ /group_buy.php?act=view&id;=$1; rewrite ^/auction-([0-9]+)....
If you’re using NGinx spawn-cgi or FPM with PHP and calling mysql_pconnect, you are likely going to experience frequent database crashes and “Too many connections” errors. This took a while to trace, but once you understand the issue, it all makes sense. mysql_pconnect opens a “persistent” connection to the database. From the documentation: “the connection to the SQL server will not be closed when the execution of the script ends. Instead, the link will remain open for future use (mysql_close() will not close links established by mysql_pconnect())....
记得自己每一次知道nginx 还是在 群里讨论张老师的文章 他的最新文章 Nginx 0.7.x + PHP 5.2.8(FastCGI)搭建胜过Apache十倍的Web服务器(第4版)[原创] http://blog.s135.com/post/366/ 我自己是在 freebsd 7.0服务器上 硬件配置 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz *2 内存 4G sas 146 * 2 raid1 基本和张老师的配置差不多, nginx 配置 user www www; worker_processes 8; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; worker_rlimit_nofile 200000; events { worker_connections 200000; #use kqueue; } php-cgi 开启 128 进程 实际结果, nginx 也许处理静态页面可以达到3W并发,但是如是果php 得估计不行,我自己用 webbench 开起1W连接,本机差点没死,但此时 php页面打开已经相当的慢了,但status 速度仍然很快,说明nginx 的承载能力确实很强,但php处理这块依然是最大的瓶颈,此文只是本人自己测试,也许是本本配置系统有问题,导致达不到3W并发!