门户网站架构设计方案A - 图文 下载本文

默认值75。

公开 内部公开 机密 绝密√

enableLookups: 是否反查域名,默认值为true。为了提高处理能力,应设置为false connnectionTimeout: 网络连接超时,默认值60000,单位:毫秒。设置为0表示永不超时,这样设置有隐患的。通常可设置为30000毫秒。 maxKeepAliveRequests: 保持请求数量,默认值100。 bufferSize: 输入流缓冲大小,默认值2048 bytes。 compression: 压缩传输,取值on/off/force,默认值off。 其中和最大连接数相关的参数为maxThreads和acceptCount。如果要加大并发连接数,应同时加大这两个参数。 web server允许的最大连接数还受制于*作系统的内核参数设置,通常Windows是2000个左右,Linux是1000个左右。 apache服务器优化

加大并发数量和关闭不需要的模块。因为apache非常消耗内存,尽量轻量化。

Apache在配置ContentType的时候可以尽量少支持,尽可能少的LoadModule,保证更高的系统消耗和执行效率

同时配置apache和tomcat的组合使之能作到动静分离,apache处理静态页面,tomcat处理动态页面。 在处理静态页面或者图片、js等访问方面,可以考虑使用lighttpd代替Apache,它提供了更轻量级和更高效的处理能力

Nginx服务器的优化

worker_processes:该参数的值最好跟cpu核数相等,能够发挥最大性能,如果nginx所在服务器为2颗双核cpu,则建议设定为4。

Web服务架构评测

主要对基于tomcat和nginx+tomcat的web服务器的处理性能进行测试,以作为不同性能要求下架构选型的依据

测试环境 网络环境

内网带宽 ? 千M内网。

? 内网ping包延迟:< 0.1ms

8/16/2014

版权所有,侵权必究All rights reserved

公开 内部公开 机密 绝密√

网络拓扑示意

WEB服务高可用测试网络示意图千兆交换机测试服务器WEB服务192.168.131.19test1192.168.131.61test2192.168.131.60:81192.168.131.57Tomcat1Nginx服务端192.168.131.56Tomcat2 服务器配置

设备 Nginx 硬件配置 IBM X3650 CPU: Intel(R) Xeon(R) E5150 2.66GHz 2核*2 内存:4G 千兆网卡 操作系统 Redhat linux as4 Tomcat1 Hp DL580 G4 CPU: Intel(R) Xeon(TM) 3.40GHz 4核*2 内存:8G 千兆网卡 Redhat linux as5 Tomcat2 Hp DL580 G4 CPU: Intel(R) Xeon(TM) 3.40GHz 4核*2 内存:8G 千兆网卡 Redhat linux as5 Test1 Hp DL580 G5 CPU:Intel(R) Xeon(R) E7310 1.60GHz 4核*2 内存:4G 千兆网卡 IBM X3650 CPU: Intel(R) Xeon(R) E5150 2.66GHz 2核*2 内存:4G 千兆网卡 Redhat linux as5 Test2 Redhat linux as4 8/16/2014

版权所有,侵权必究All rights reserved 第

公开 内部公开 机密 绝密√

软件环境

操作系统网络参数优化

用做测试的各台服务器,均在/etc/sysctl.conf配置文件中增加如下内核参数: net.ipv4.tcp_syncookies = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_fin_timeout = 5 Nginx设置 主要配置如下: user www www; worker_processes 4;

error_log /usr/local/nginx/logs/nginx_error.log debug; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events {

use epoll;

worker_connections 51200; } http {

include mime.types;

default_type application/octet-stream; #charset gb2312;

server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k;

sendfile on; tcp_nopush on; keepalive_timeout 1; tcp_nodelay on; #gzip on;

#gzip_min_length 1k; #gzip_buffers 4 16k; #gzip_http_version 1.0;

8/16/2014

版权所有,侵权必究All rights reserved

公开 内部公开 机密 绝密√

#gzip_comp_level 2;

#gzip_types text/plain application/x-javascript text/css application/xml; #gzip_vary on; upstream tomcats {

server 192.168.131.57:8081; server 192.168.131.56:8081; # server 192.168.131.61:8080; } server {

listen 81;

server_name localhost; proxy_redirect off;

location / {

proxy_pass http://tomcats; }

#后端的Web服务器可以通过X-Forwarded-For获取用户真实IP # proxy_set_header X-Forwarded-For $remote_addr; # location / {

# if ($request_uri ~* \ # {

# proxy_pass http://squid.abc.com; # }

# if ($request_uri ~* \ # {

# proxy_pass http://squid.abc.com; # }

# proxy_pass http://web.abc.com; #}

#定义日志格式

log_format access '$remote_addr - $remote_user [$time_local] $request ' '\ '\ #打日志

版权所有,侵权必究All rights reserved

8/16/2014