疯了,Apache+Tomcat负载均衡比单个Tomcat反应慢

卖豆浆不卖油条 发布于 2010/12/11 10:12
阅读 1K+
收藏 1

主机虚拟机,2g内存,一般服务器配置,windows server 2003平台。

因要集成php,而原先的系统是用java开发的,所以考虑使用apache+tomcat(VirtualHost方式)作负载均衡,另外用一个VirtualHost解析php,配置里面用到了mod_deflate,proxy,cache相关模块,静态页面、图片、js文件、css文件等由apache负责,现在各模块都能正常工作了,但唯一的问题就是访问apache提供的静态页面或图片打开速度比直接使用tomcat提供静态页面的要慢一倍以上,几乎没法正常使用。什么优化配置都试过了,还是不行,不知道各位大侠有什么办法,请教一二!以上均在同一台机器上做试验。

相关配置:

 

 

ServerName www.****.com

 

DirectoryIndex index.html index.htm index.jsp

ErrorLog logs/error.log

CustomLog logs/access.log combined

 

ProxyPassMatch ^/$ !

ProxyPassMatch /*.gif$ !

ProxyPassMatch /*.jpg$ !

ProxyPassMatch /*.css$ !

ProxyPassMatch /*.js$ !

ProxyPassMatch /*.htm$ !

ProxyPassMatch /*.php$ !

ProxyPassMatch /index.html$ !

ProxyPassMatch /promotion.html$ !

 

ProxyPass / balancer://example/

ProxyPassReverse / balancer://example/

 

BalancerMember http://127.0.0.1:8180/

BalancerMember http://127.0.0.1:8181/

 

 

 

 

ServerName ts.****.com

DirectoryIndex index.html index.htm index.php

#ServerAdmin webadmin@domian.com.cn

#ErrorDocument 404 /404.html

DocumentRoot "D:/ts"

LogLevel debug

ErrorLog logs/error_php.log

CustomLog logs/domian.log combined

 

http.conf相关:

 

 

 

LoadModule disk_cache_module modules/mod_disk_cache.so

 

CacheRoot /

CacheSize 256

CacheEnable disk /

CacheDirLevels 5

CacheDirLength 3

 

 

LoadModule mem_cache_module modules/mod_mem_cache.so

 

CacheEnable mem /

MCacheSize 4096

MCacheMaxObjectCount 100

MCacheMinObjectSize 1

MCacheMaxObjectSize 2048

 

 

 

 

 

      ExpiresActive on

      ExpiresByType image/gif "access plus 1 month"

      ExpiresByType text/css "now plus 1 month"

      ExpiresDefault "now plus 1 day"

 

 

#CacheForceCompletion 100

CacheDefaultExpire 3600

CacheMaxExpire 86400

CacheLastModifiedFactor 0.1

 

 

#gzip压缩

 

SetOutputFilter DEFLATE

 

# Netscape 4.x has some problems…

BrowserMatch ^Mozilla/4 gzip-only-text/html

 

# Netscape 4.06-4.08 have some more problems

BrowserMatch ^Mozilla/4\.0[678] no-gzip

 

# MSIE masquerades as Netscape, but it is fine

# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48

# the above regex won’t work. You can use the following

# workaround to get the desired effect:

BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

 

AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/x-httpd-php

AddOutputFilter DEFLATE js css

 

# Don’t compress images

SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary

 

# Make sure proxies don’t deliver the wrong content

Header append Vary User-Agent env=!dont-vary

 

 

 

maxkeepaliverequests 100

keepalivetimeout 5

serversignature off

servertokens prod

hostnamelookups off

加载中
返回顶部
顶部