一、平台结构
1、服务器操作系统组成:
1, OS: Ubuntu
8.04.1
hardy
2, Kernel: Linux
2.6.24
-16-server #1 SMP i686 GNU/Linux
3, GCC:
root@ftp:/var/www# gcc –v
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --enable-languages=c,c++,fortran,objc,obj-c++,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.2 --program-suffix=-4.2 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --enable-targets=all --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version
4.2.4
(Ubuntu 4.2.4-1ubuntu1)
|
|
2、服务器软件组成:
1, APACHE
2.2.8
-1+PHP5.2.4 (采用aptitude方式安装LAMP)
2, NGINX
0.7.20
+PHP5.2.6(均采用源代码安装, 以fastcgi方式安装php), 其它附加软件包括eaccelerator-0.9.5.3/libevent-1.2/libiconv-1.12/libmcrypt-2.5.8/mcrypt-2.6.7/memcache-3.0.2/mhash-0.9.9/ncurses-5.6/pcre-7.7/php-5.2.6-fpm-0.5.9.diff.
3、服务器硬件信息:
1, MEMORY:
2G
, Swap:
2G
2, CPU: Intel(R) Xeon(R) CPU 3065 @ 2.33GHz (总2颗)
3, DISK: SCSI
160G
二、安装配置说明:
1、NGINX
0.7.20
+PHP5.2.6(均采用源代码安装):
1)Nginx
0.7.20
安装配置:
A)安装编译参数:
./configure --user=www-data --group=www-data /
> --prefix=/usr/local/webserver/nginx /
> --with-http_stub_status_module --with-http_ssl_module
|
B) 配置文件nginx.conf:
root@ftp: ~#cd /usr/local/webserver/nginx/
root@ftp: nginx# grep -v "#" conf/nginx.conf
user www-data www-data;
worker_processes 5;
error_log logs/error.log info;
pid logs/nginx.pid;
worker_rlimit_nofile 50000;
events {
worker_connections 2024;
use epoll;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'"$gzip_ratio"';
access_log logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
output_buffers 1 32k;
postpone_output 1460;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
client_header_timeout
3m
;
client_body_timeout
3m
;
large_client_header_buffers 4 32k;
client_max_body_size
10m
;
client_body_buffer_size 128k;
send_timeout
3m
;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain application/x-javascript text/css application/xml text/xml;
gzip_vary on;
server {
listen 81;
server_name ftp.jbird.jb;
access_log logs/nginx.access.log main;
location / {
index index.html index.htm index.php;
root /var/www/nginx/test;
}
location ~ .*/.(php|php5)$ {
root /var/www/nginx/test;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ .*/.(gif|jpeg|jpg|png|bmp|swf|asf|wmv|avi)$ {
root /var/www/nginx/test;
expires 1d;
}
location ~ .*/.(js|css)$ {
root /var/www/nginx/test;
expires 1h;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 82;
server_name ftp.jbird.jb localhost 192.168.3.254
10.10.10
.5;
location / {
stub_status on;
access_log off;
allow 192.168.3.0/24;
}
}
}
|
|
C) nginx.conf文件所include的fastcgi_params配置文件:
root@ftp: ~#cd /usr/local/webserver/nginx/
root@ftp: nginx#cat conf/fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
|
|
2) PHP
5.2.6
安装配置:
A) PHP安装编译参数:
./configure '--prefix=/usr/local/webserver/php' '--with-config-file-path=/usr/local/webserver/php/etc' '--with-mysql=/usr/local/webserver/mysql' '--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config' '--with-iconv-dir=/usr/local/' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-discard-path' '--enable-safe-mode' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--with-curlwrappers' '--enable-mbregex' '--enable-fastcgi' '--enable-fpm' '--enable-force-cgi-redirect' '--enable-mbstring' '--with-mcrypt' '--enable-gd-native-ttf' '--with-openssl'
|
B)php.ini文件配置(以下是修改和添加部分):
root@ftp: etc#cd /usr/local/webserver/php/etc
root@ftp:etc#egrep 'output_buffer|extens' php.ini |grep -v "^;"
output_buffering = On
extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
| root@ftp: etc# tail -n 16 php.ini
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/webserver/php/eaccelerator_cache/"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
|
|
C) php-fpm.conf文件(红色部分是修改部分):
root@ftp: etc#cat php-fpm.conf
/usr/local/webserver/php/logs/php-fpm.pid
/usr/local/webserver/php/logs/php-fpm.log
notice
10
1m
5s
yes
default
127.0.0.1:9000
-1
0666
/usr/sbin/sendmail -t -i
0
www-data
www-data
static
128
20
5
35
0s
0s
logs/slow.log
50000
0
yes
10240
127.0.0.1
$HOSTNAME
/usr/local/bin:/usr/bin:/bin
/tmp
/tmp
/tmp
$OSTYPE
$MACHTYPE
2
|
|
D) 以下是http://192.168.3.254:81/info.php (nginx服务器)(内容是:
)显示的内容:
PHP Version
5.2.6
|
System
| Linux ftp.jbird.jb
2.6.24
-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
|
Build Date
| Nov 11 2008 14:05:01
|
Configure Command
| './configure' '--prefix=/usr/local/webserver/php' '--with-config-file-path=/usr/local/webserver/php/etc' '--with-mysql=/usr/local/webserver/mysql' '--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config' '--with-iconv-dir=/usr/local/' '--with-freetype-dir' '--with-jpeg-dir' '--with-png-dir' '--with-zlib' '--with-libxml-dir=/usr' '--enable-xml' '--disable-rpath' '--enable-discard-path' '--enable-safe-mode' '--enable-bcmath' '--enable-shmop' '--enable-sysvsem' '--enable-inline-optimization' '--with-curl' '--with-curlwrappers' '--enable-mbregex' '--enable-fastcgi' '--enable-fpm' '--enable-force-cgi-redirect' '--enable-mbstring' '--with-mcrypt' '--enable-gd-native-ttf' '--with-openssl'
|
Server API
| CGI/FastCGI
|
PHP API
| 20041225
|
PHP Extension
| 20060613
|
Zend Extension
| 220060519
|
Thread Safety
| disabled
|
Zend Memory Manager
| enabled
|
Registered PHP Streams
| php, file, data, tftp, ftp, telnet, dict, ldap, ldaps, http, https, ftps, compress.zlib
|
Registered Stream Socket Transports
| tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
|
Registered Stream Filters
| string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, zlib.*
|
Directive
| Local Value
| Master Value
|
cgi.check_shebang_line
| 1
| 1
|
cgi.fix_pathinfo
| 1
| 1
|
cgi.force_redirect
| 1
| 1
|
cgi.nph
| 0
| 0
|
cgi.redirect_status_env
| no value
| no value
|
cgi.rfc2616_headers
| 0
| 0
|
fastcgi.error_header
| no value
| no value
|
fastcgi.logging
| 1
| 1
|
php-fpm
| active
| |
php-fpm version
|
0.5.9
| |
<!--[if !supportMisalignedColumns]-->
<!--[endif]-->
eAccelerator support
| enabled
| |
Version
|
0.9.5
.3
| |
Caching Enabled
| true
| |
Optimizer Enabled
| true
| |
Memory Size
| 134,217,692 Bytes
| |
Memory Available
| 134,213,128 Bytes
| |
Memory Allocated
| 4,564 Bytes
| |
Cached Scripts
| 1
| |
Removed Scripts
| 0
| |
Cached Keys
| 0
| |
Directive
| Local Value
| Master Value
|
eaccelerator.allowed_admin_path
| no value
| no value
|
eaccelerator.cache_dir
| /usr/local/webserver/php/
/eaccelerator_cache/
| /usr/local/webserver/php/
/eaccelerator_cache/
|
eaccelerator.check_mtime
| 1
| 1
|
eaccelerator.compress
| 1
| 1
|
eaccelerator.compress_level
| 9
| 9
|
eaccelerator.debug
| 0
| 0
|
eaccelerator.enable
| 1
| 1
|
eaccelerator.filter
| no value
| no value
|
eaccelerator.log_file
| no value
| no value
|
eaccelerator.name_space
| no value
| no value
|
eaccelerator.optimizer
| 1
| 1
|
eaccelerator.shm_max
| 0
| 0
|
eaccelerator.shm_only
| 0
| 0
|
eaccelerator.shm_prune_period
| 120
| 120
|
eaccelerator.shm_size
| 128
| 128
|
eaccelerator.shm_ttl
| 300
| 300
|
memcache support
| enabled
|
Version
|
3.0.2
|
Revision
| $Revision: 1.83.2.28 $
|
Directive
| Local Value
| Master Value
|
memcache.allow_failover
| 1
| 1
|
memcache.chunk_size
| 32768
| 32768
|
memcache.default_port
| 11211
| 11211
|
memcache.hash_function
| crc32
| crc32
|
memcache.hash_strategy
| consistent
| consistent
|
memcache.max_failover_attempts
| 20
| 20
|
memcache.protocol
| ascii
| ascii
|
memcache.redundancy
| 1
| 1
|
memcache.session_redundancy
| 2
| 2
|
2、APACHE
2.2.8
-1+PHP5.2.4 (采用aptitude方式安装LAMP)
1)Apache
2.2.8
安装配置:
A)安装采用aptitude方式安装LAMP;
B) Apache配置文件:
root@ftp:~# grep -v "^#" /etc/apache2/apache2.conf | uniq
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 30
KeepAlive On
MaxKeepAliveRequests 300
KeepAliveTimeout 10
StartServers 5
MinSpareServers 5
MaxSpareServers 10
ServerLimit 2000
MaxRequestsPerChild 0
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
Order allow,deny
Deny from all
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%h %l %u %t /"%r/" %>s %b /"%{Referer}i/" /"%{User-Agent}i/"" combined
LogFormat "%h %l %u %t /"%r/" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
ServerTokens Full
ServerSignature On
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
NameVirtualHost *
ServerAdmin webmaster@localhost
ServerAlias *.192.168.3.254
DocumentRoot /var/www/
Options FollowSymLinks
AllowOverride FileInfo Options
Options Indexes FollowSymLinks MultiViews
AllowOverride FileInfo Options
Order allow,deny
allow from all
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
| root@ftp:~# apache2 -l
//启用prefork.c这个MPM
Compiled in modules:
core.c
mod_log_config.c
mod_logio.c
prefork.c
http_core.c
mod_so.c
|
|
2) PHP
5.2.4
安装配置 :
A) 安装采用aptitude方式安装LAMP;
B) php.ini文件采用默认配置.
C) 以下是http://192.168.3.254/info.php (apache服务器)(内容是:
)显示的内容:
PHP Version
5.2.4
-2ubuntu5.3
|
System
| Linux ftp.jbird.jb
2.6.24
-16-server #1 SMP Thu Apr 10 13:58:00 UTC 2008 i686
|
Build Date
| Jul 23 2008 06:28:41
|
Server API
| Apache 2.0 Handler
|
Virtual Directory Support
| disabled
|
Configuration File (php.ini) Path
| /etc/php5/apache2
|
Loaded Configuration File
| /etc/php5/apache2/php.ini
|
Scan this dir for additional .ini files
| /etc/php5/apache2/conf.d
|
additional .ini files parsed
| /etc/php5/apache2/conf.d/gd.ini, /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini
|
PHP API
| 20041225
|
PHP Extension
| 20060613
|
Zend Extension
| 220060519
|
Thread Safety
| disabled
|
Zend Memory Manager
| enabled
|
IPv6 Support
| enabled
|
Registered PHP Streams
| zip, php, file, data, http, ftp, compress.bzip2, compress.zlib, https, ftps
|
Registered Stream Socket Transports
| tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
|
Registered Stream Filters
| string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, bzip2.*, zlib.*
|
三、测试
1、启动apache、nignx:
root@ftp:~# cat ./startapache+nginx.sh
// 启动脚本
#!/bin/sh
#
ulimit -SHn 50000
echo 134217728 > /proc/sys/kernel/shmmax
# 因为在php.ini文件中有eaccelerator.shm_size="128"的设定, 故134217728bytes/1024/1024 = 128MB
echo 30 > /proc/sys/net/ipv4/tcp_fin_timeout
echo 300 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
echo "5000 65000" > /proc/sys/net/ipv4/ip_local_port_range
# start php5+nginx
/usr/local/webserver/php/sbin/php-fpm start
/usr/local/webserver/nginx/sbin/nginx
# start apache2
/etc/init.d/apache2 start
| // 开始启动
root@ftp:~# source ./startapache+nginx.sh
//查看状态
root@ftp:~# netstat -an | egrep '80|81|9000'
tcp 0 0 127.0.0.1:9000
0.0.0
.0:* LISTEN
tcp 0 0
0.0.0
.0:80
0.0.0
.0:* LISTEN
tcp 0 0
0.0.0
.0:81
0.0.0
.0:* LISTEN
| //查看进程
root@ftp:~# ps aux | egrep 'nginx|apache'
root 14959 0.0 0.0 4472 648 ? Ss 12:33 0:00 nginx: master process /usr/local/webserver/nginx/sbin/nginx
www-data 14961 0.0 0.0 5044 1736 ? S 12:33 0:00 nginx: worker process
www-data 14962 0.0 0.0 4884 1352 ? S 12:33 0:00 nginx: worker process
www-data 14971 0.0 0.0 4884 1352 ? S 12:33 0:00 nginx: worker process
www-data 14972 0.0 0.0 4884 1352 ? S 12:33 0:00 nginx: worker process
www-data 14975 0.0 0.0 4884 1352 ? S 12:33 0:00 nginx: worker process
root 15006 0.0 0.3 24964 7244 ? Ss 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15013 0.0 0.2 25004 6192 ? S 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15019 0.0 0.2 25004 4264 ? S 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15021 0.0 0.2 25004 4264 ? S 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15023 0.0 0.2 25004 4264 ? S 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15025 0.0 0.2 25004 4264 ? S 12:33 0:00 /usr/sbin/apache2 -k start
www-data 15133 0.0 0.2 25004 4264 ? S 12:34 0:00 /usr/sbin/apache2 -k start
| root@ftp:~# ps aux | egrep 'php-cgi'
root 14946 0.0 0.1 150464 2804 ? Ss 12:33 0:00 /usr/local/webserver/php/bin/php-cgi --fpm --fpm-config /usr/local/webserver/php/etc/php-fpm.conf
......
www-data 15104 0.0 0.1 149484 2600 ? S 12:33 0:00 /usr/local/webserver/php/bin/php-cgi --fpm --fpm-config /usr/local/webserver/php/etc/php-fpm.conf
| root@ftp:~# ps aux | egrep 'php-cgi' |grep -v "egrep" |wc -l
|
2、测试 : php测试
A) 测试方法:我们的测试采用webbench1.5这个软件来模拟clients,分别以200、500、1000、2000个clients去运行30秒;另外采用sar工具来采集数据;
B)采集数据:包括sar工具的cpu、memory、swap输出,sar以每隔5秒的频率共采集3组;
C)采集的页面均是info.php,内容是
root@ftp: report# cat info.php
|
第一组php测试:200clients数据:
<!--[if !supportLists]-->1) <!--[endif]-->Apache200clients数据
//首先是webbech采集数据:
root@ftp: ~#webbench -c200 -t30 http://192.168.3.254/info.php
Speed=49450 pages/min, 40113860 bytes/sec.
Requests: 24725 susceed, 0 failed.
| //说明:apache在200个clients时,响应速度是
40.1M
/s,824pages/s,共接收请求24725个,没有失败。
//下面是sar采集数据 :
root@ftp: report#sar -ur 5 3
16:09:26 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:09:30 all 90 0 7 0 3 0 0
0 90 0 7 0 3 0 0
1 90 0 8 0 2 0 0
16:09:26 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:09:30
2024M
1502M
8M
334M
31M
2000M
2000M
16:09:30 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:09:35 all 88 0 9 0 3 0 0
0 87 0 9 0 3 0 0
1 90 0 8 0 3 0 0
16:09:30 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:09:35
2024M
1488M
8M
334M
32M
2000M
2000M
16:09:35 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:09:40 all 91 0 6 0 3 0 0
0 91 0 6 0 3 0 0
1 91 0 6 0 3 0 0
16:09:35 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:09:40
2024M
1479M
8M
334M
33M
2000M
2000M
| //说明:apache在200个clients时, CPU利用率usr占用到90%,内存使用
535M
,软件中断3%, swap没有使用。
|
2)Nginx200clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench -c200 -t30 http://192.168.3.254:81/info.php
Speed=56014 pages/min, 44434882 bytes/sec.
Requests: 28007 susceed, 0 failed.
| //说明: nginx在200个clients时, 响应速度是
44.4M
/s,933pages/s,共接收请求28007个,没有失败。
//下面是sar采集数据 :
root@ftp: ~#sar -ur 5 3
16:12:36 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:12:40 all 88 0 8 0 4 0 0
0 87 0 8 0 4 0 0
1 88 0 8 0 4 0 0
16:12:36 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:12:40
2024M
1450M
9M
337M
30M
2000M
2000M
16:12:40 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:12:45 all 86 0 8 0 5 0 0
0 85 0 8 0 7 0 0
1 87 0 9 0 4 0 0
16:12:40 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:12:45
2024M
1449M
9M
338M
30M
2000M
2000M
16:12:45 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:12:50 all 87 0 8 0 4 0 0
0 86 0 9 0 4 0 0
1 88 0 7 0 4 0 0
16:12:45 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:12:50
2024M
1448M
9M
338M
30M
2000M
2000M
| //说明:nginx在200个clients时, CPU利用率usr占用到87%,内存使用
576M
,软件中断3.7%, swap没有使用。
|
第二组php测试:500clients数据:
<!--[if !supportLists]-->1) <!--[endif]-->Apache500clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c500 -t30 http://192.168.3.254/info.php
Speed=49946 pages/min, 40376572 bytes/sec.
Requests: 24875 susceed, 98 failed.
| //说明:apache在500个clients时,响应速度是
40.3M
/s,832pages/s,共接收请求24876个,失败98。
//下面是sar采集数据 :
root@ftp: report#sar -ur 5 3
16:15:35 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:15:39 all 71 0 7 0 3 0 19
0 71 0 6 0 4 0 19
1 71 0 8 0 3 0 19
16:15:35 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:15:39
2024M
1456M
9M
341M
42M
2000M
2000M
16:15:39 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:15:44 all 88 0 8 0 3 0 0
0 90 0 6 0 4 0 0
1 87 0 10 0 3 0 0
16:15:39 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:15:44
2024M
1441M
9M
341M
44M
2000M
2000M
16:15:44 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:15:49 all 88 0 8 0 4 0 0
0 88 0 8 0 4 0 0
1 89 0 7 0 4 0 0
16:15:44 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:15:49
2024M
1429M
9M
341M
45M
2000M
2000M
| //说明:apache在500个clients时, CPU利用率usr占用到83%,内存使用
582M
,软件中断3.3%, swap没有使用。
|
2)Nginx500clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c500 -t30 http://192.168.3.254:81/info.php
Speed=56238 pages/min, 44480931 bytes/sec.
Requests: 28039 susceed, 80 failed.
| //说明: nginx在500个clients时, 响应速度是
44.4M
/s,937pages/s,共接收请求28039个,失败80。
//下面是sar采集数据 :
root@ftp: ~#sar -ur 5 3
16:23:54 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:23:58 all 86 0 9 0 4 0 0
0 85 0 11 0 4 0 0
1 87 0 8 0 5 0 0
16:23:54 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:23:58
2024M
1401M
11M
349M
40M
2000M
2000M
16:23:58 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:24:03 all 87 0 8 0 4 0 0
0 88 0 9 0 3 0 0
1 87 0 8 0 5 0 0
16:23:58 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:24:03
2024M
1400M
11M
349M
40M
2000M
2000M
16:24:03 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:24:08 all 86 0 8 0 6 0 0
0 85 0 8 0 7 0 0
1 86 0 8 0 6 0 0
16:24:03 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:24:08
2024M
1400M
11M
350M
41M
2000M
2000M
| //说明:nginx在500个clients时, CPU利用率usr占用到86%,内存使用
624M
,软件中断4.5%, swap没有使用。
|
第三组php测试:1000clients数据:
<!--[if !supportLists]-->2) <!--[endif]-->Apache1000clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c1000 -t30 http://192.168.3.254/info.php
Speed=48496 pages/min, 38980372 bytes/sec.
Requests: 24011 susceed, 237 failed.
| //说明:apache在1000个clients时,响应速度是
38.9M
/s,808pages/s,共接收请求24011个,失败237。
//下面是sar采集数据 :
root@ftp: report#sar -ur 5 3
16:26:54 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:26:58 all 87 0 7 0 3 0 3
0 85 0 7 0 5 0 3
1 89 0 6 0 2 0 3
16:26:54 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:26:58
2024M
1383M
11M
360M
59M
2000M
2000M
16:26:58 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:27:03 all 90 0 7 0 3 0 0
0 90 0 7 0 3 0 0
1 90 0 7 0 3 0 0
16:26:58 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:27:03
2024M
1361M
12M
360M
60M
2000M
2000M
16:27:03 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:27:08 all 90 0 8 0 3 0 0
0 89 0 8 0 3 0 0
1 91 0 7 0 2 0 0
16:27:03 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:27:08
2024M
1347M
12M
361M
62M
2000M
2000M
| //说明:apache在1000个clients时, CPU利用率usr占用到88%,内存使用
664M
,软件中断3%, swap没有使用。
|
2)Nginx1000clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c1000 -t30 http://192.168.3.254:81/info.php
Speed=56608 pages/min, 44287607 bytes/sec.
Requests: 27917 susceed, 387 failed.
| //说明: nginx在1000个clients时, 响应速度是
44.2M
/s,943pages/s,共接收请求27917个,失败387。
//下面是sar采集数据 :
root@ftp: ~#sar -ur 5 3
16:32:11 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:32:15 all 87 0 9 0 4 0 0
0 87 0 9 0 3 0 0
1 86 0 9 0 5 0 0
16:32:11 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:32:15
2024M
1330M
12M
370M
57M
2000M
2000M
16:32:15 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:32:20 all 88 0 9 0 4 0 0
0 89 0 8 0 3 0 0
1 87 0 9 0 5 0 0
16:32:15 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:32:20
2024M
1328M
12M
371M
57M
2000M
2000M
16:32:20 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:32:25 all 85 0 10 0 5 0 0
0 86 0 10 0 5 0 0
1 85 0 11 0 5 0 0
16:32:20 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:32:25
2024M
1328M
12M
371M
58M
2000M
2000M
| //说明:nginx在1000个clients时, CPU利用率usr占用到86%,内存使用
697M
,软件中断4.3%, swap没有使用。
|
第四组php测试:2000clients数据:
<!--[if !supportLists]-->3) <!--[endif]-->Apache2000clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c2000 -t30 http://192.168.3.254/info.php
Speed=47904 pages/min, 38329354 bytes/sec.
Requests: 23649 susceed, 303 failed.
| //说明:apache在2000个clients时,响应速度是
38.3M
/s,798pages/s,共接收请求23649个,失败303。
//下面是sar采集数据 :
root@ftp: report#sar -ur 5 3
16:40:33 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:40:37 all 87 0 9 0 4 0 0
0 87 0 8 0 5 0 0
1 87 0 10 0 3 0 0
16:40:33 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:40:37
2024M
1255M
13M
386M
91M
2000M
2000M
16:40:37 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:40:42 all 89 0 8 0 3 0 0
0 91 0 7 0 2 0 0
1 88 0 10 0 3 0 0
16:40:37 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:40:42
2024M
1249M
13M
386M
92M
2000M
2000M
16:40:42 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:40:47 all 89 0 7 0 4 0 0
0 89 0 7 0 4 0 0
1 89 0 7 0 4 0 0
16:40:42 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:40:47
2024M
1242M
13M
386M
92M
2000M
2000M
| //说明:apache在2000个clients时, CPU利用率usr占用到88%,内存使用
775M
,软件中断4%, swap没有使用。
|
2)Nginx2000clients数据:
//首先是webbech采集数据:
root@ftp: ~#webbench –c2000 -t30 http://192.168.3.254:81/info.php
Speed=56150 pages/min, 43946270 bytes/sec.
Requests: 27698 susceed, 377 failed.
| //说明: nginx在2000个clients时, 响应速度是
43.9M
/s,935pages/s,共接收请求27698个,失败377。
//下面是sar采集数据:
root@ftp: ~#sar -ur 5 3
16:44:06 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:44:10 all 88 0 8 0 4 0 0
0 88 0 9 0 3 0 0
1 88 0 7 0 5 0 0
16:44:06 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:44:10
2024M
1228M
14M
391M
88M
2000M
2000M
16:44:10 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:44:15 all 86 0 11 0 3 0 0
0 85 0 11 0 4 0 0
1 86 0 11 0 3 0 0
16:44:10 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:44:15
2024M
1227M
14M
392M
89M
2000M
2000M
16:44:15 cpu %usr %nice %sys %irq %softirq %wait %idle _cpu_
16:44:20 all 85 0 10 0 5 0 0
0 85 0 10 0 6 0 0
1 85 0 10 0 5 0 0
16:44:15 memtot memfree buffers cached slabmem swptot swpfree _mem_
16:44:20
2024M
1225M
14M
392M
89M
2000M
2000M
| //说明:nginx在2000个clients时, CPU利用率usr占用到86%,内存使用
797M
,软件中断4%, swap没有使用。
|
四、最终总结:
总结见下表:
clients
| sar -
ur
5 3
| webbench -c<clients> -t30 url
|
CPU(%)
| Memory(M)
| pages/s
| susceed
| failed
|
apache
| nginx
| apache
| nginx
| apache
| nginx
| apache
| nginx
| apache
| nginx
|
200 Clients
| 90
| 87
| 535
| 576
| 824
| 933
| 24725
| 28007
| 0
| 0
|
500 Clients
| 83
| 86
| 582
| 624
| 832
| 937
| 24876
| 28039
| 98
| 80
|
1000 Clients
| 88
| 86
| 664
| 697
| 808
| 943
| 24011
| 27917
| 237
| 387
|
2000 Clients
| 88
| 86
| 775
| 797
| 798
| 935
| 23649
| 27698
| 303
| 516
|
<!--[if !supportLists]-->1、 <!--[endif]-->nginx的pages/s比apache在500client以下的情况下快大约100, 但是1000以上后, 差距则越来越小;
<!--[if !supportLists]-->2、 <!--[endif]-->而failed率在clients数500以下没有太大差别, 当client越来越多的时候, 则nginx的failed率要比apache多出50%强.
<!--[if !supportLists]-->3、 <!--[endif]-->nginx比apache在memory使用上似乎要多一些, 但是因为有FastCGI即ph-cgi的进程存在, 所以就不显得多了.
<!--[if !supportLists]-->4、 <!--[endif]-->在请求数量中, nginx的成功数(susceed)要明显多于apache(每次多约4000).