当前位置:错新网文章中心服务器安全维护 → 基于反向代理的Web缓存加速现代理服务器

基于反向代理的Web缓存加速现代理服务器

减小字体 增大字体 作者:admin  来源:www.hack50.com  发布时间:2011-11-29 8:06:20

百度权重查询 站长交易 友情链接交换 企业建站Cuoxin建站大师,招分销商

核心提示:文章标题:基于反向代理的Web缓存加速现代理服务器。Linux是中国站长站的一个技术频道。包含桌面应用,Linux系统管理,内核研究,嵌入式系统和开源等一些基本分类


基于Apachemod_proxy的反向代理缓存加速实现
Apache包含了mod_proxy模块,可以用来实现代理服务器,针对后台服务器的反向加速
安装apache1.3.x编译时:
--enable-shared=max--enable-module=most
注:Apache2.x中mod_proxy已经被分离成mod_proxy和mod_cache:同时mod_cache有基于文件和基于内存的不同实现
创建/var/www/proxy,设置apache服务所用户可写
mod_proxy配置样例:反相代理缓存+缓存
架设前台的www.example.com反向代理后台的www.backend.com的8080端口服务。
修改:httpd.conf
<VirtualHost*>
ServerNamewww.example.com
ServerAdminadmin@example.com
#reverseproxysetting
ProxyPass/http://www.backend.com:8080/
ProxyPassReverse/http://www.backend.com:8080/
#cachedirroot
CacheRoot"/var/www/proxy"
#maxcachestorage
CacheSize50000000
#hour:every4hour
CacheGcInterval4
#maxpageexpiretime:hour
CacheMaxExpire240
#Expiretime=(now-last_modified)*CacheLastModifiedFactor
CacheLastModifiedFactor0.1
#defaltexpiretag:hour
CacheDefaultExpire1
#forcecompleteafterprecentofcontentretrived:60-90%
CacheForceCompletion80
CustomLog/usr/local/apache/logs/dev_access_logcombined
</VirtualHost>

基于Squid的反向代理加速实现
Squid是一个更专用的代理服务器,性能和效率会比Apache的mod_proxy高很多。
如果需要combined格式日志补丁:
http://www.squid-cache.org/mail-archive/squid-dev/200301/0164.html
squid的编译:
./configure--enable-useragent-log --enable-referer-log--enable-default-err-language=Simplify_Chinese--enable-err-languages="Simplify_ChineseEnglish"--disable-internal-dns 
make
#makeinstall
#cd/usr/local/squid
makedircache
chownsquid.squid*
vi/usr/local/squid/etc/squid.conf
在/etc/hosts中:加入内部的DNS解析,比如:
192.168.0.4www.chedong.com
192.168.0.4news.chedong.com
192.168.0.3bbs.chedong.com
---------------------cuthere----------------------------------
#visiblename
visible_hostnamecache.example.com
#cacheconfig:spaceuse1Gandmemoryuse256M
cache_dirufs/usr/local/squid/cache102416256
cache_mem256MB
cache_effective_usersquid
cache_effective_groupsquid

http_port80
httpd_accel_hostvirtual
httpd_accel_single_hostoff
httpd_accel_port80
httpd_accel_uses_host_headeron
httpd_accel_with_proxyon
#acceleratermydomainonly
aclacceleratedHostAdstdomain.example1.com
aclacceleratedHostBdstdomain.example2.com
aclacceleratedHostCdstdomain.example3.com
#acceleraterhttpprotocolonport80
aclacceleratedProtocolprotocolHTTP
aclacceleratedPortport80
#accessarc
aclallsrc0.0.0.0/0.0.0.0
#AllowrequestswhentheyaretotheacceleratedmachineANDtothe
#rightportwithrightprotocol
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostA
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostB
http_accessallowacceleratedProtocolacceleratedPortacceleratedHostC
#logging
emulate_httpd_logon
cache_store_lognone
#manager
aclmanagerprotocache_object
http_accessallowmanagerall
cachemgr_passwdpassall

----------------------cuthere---------------------------------
创建缓存目录:
/usr/local/squid/sbin/squid-z
启动squid
/usr/local/squid/sbin/squid
停止squid:
/usr/local/squid/sbin/squid-kshutdown
启用新配置:
/usr/local/squid/sbin/squid-kreconfig
通过crontab每天0点截断/轮循日志:
00***(/usr/local/squid/sbin/squid-krotate)

附:SQUID性能测试试验
phpMan.php是一个基于php的manpageserver,每个man
page需要调用后台的man命令和很多页面格式化工具,系统负载比较高,提供了Cache
Friendly的URL,以下是针对同样的页面的性能测试资料:
测试环境:Redhat8onCyrix266/192MMem
测试程序:使用apache的ab(apachebenchmark):
测试条件:请求50次,并发50个连接
测试项目:直接通过apache1.3(80端口)vssquid2.5(8000端口:加速80端口)

测试1:无CACHE的80端口动态输出:
ab-n100-c10http://www.chedong.com:81/phpMan.php/man/kill/1
ThisisApacheBench,Version1.3d<$Revision:1.2$>apache-1.3
Copyright(c)1996AdamTwiss,ZeusTechnologyLtd,
http://www.zeustech.net/
Copyright(c)1998-2001TheApacheGroup,http://www.apache.org/

Benchmarkinglocalhost(bepatient).....done
ServerSoftware: 
Apache/1.3.23
ServerHostname:localhost
Server
Port: 
80

DocumentPath:
/phpMan.php/man/kill/1
DocumentLength:4655bytes

ConcurrencyLevel: 5
Timetakenfortests: 63.164seconds
Completerequests: 50
Failedrequests:0
Brokenpipeerrors:0
Totaltransferred: 245900bytes
HTMLtransferred: 232750bytes
Requestspersecond:0.79[#/sec](mean)
Timeperrequest: 6316.40[ms]
(mean)
Timeperrequest: 1263.28[ms]
(mean,acrossallconcurrentrequests)
Transferrate:
3.89[Kbytes/sec]received

ConnnectionTimes(ms)

min mean[+/-sd]median max
Connect:0 
29 106.1 0 553
Processing: 2942 6016
1845.4 622710796

Waiting:
2941 59991850.7 622610795

Total: 
2942 60451825.9 622710796

Percentageoftherequestsservedwithinacertaintime(ms)
 50% 6227
 66% 7069
 75% 7190
 80% 7474
 90% 8195
 95% 8898
 98% 9721
 99% 10796
100% 10796(lastrequest)

测试2:SQUID缓存输出
/home/apache/bin/ab-n50-c5
"http://localhost:8000/phpMan.php/man/kill/1"
ThisisApacheBench,Version1.3d<$Revision:1.2$>apache-1.3
Copyright(c)1996AdamTwiss,ZeusTechnologyLtd,
http://www.zeustech.net/
Copyright(c)1998-2001TheApacheGroup,http://www.apache.org/

Benchmarkinglocalhost(bepatient).....done
ServerSoftware: 
Apache/1.3.23
ServerHostname:localhost
Server
Port: 
8000

DocumentPath:
/phpMan.php/man/kill/1
DocumentLength:4655bytes

ConcurrencyLevel: 5
Timetakenfortests: 4.265seconds
Completerequests: 50
Failedrequests:0
Brokenpipeerrors:0
Totaltransferred: 248043bytes
HTMLtransferred: 232750bytes
Requestspersecond:11.72[#/sec](mean)
Timeperrequest: 426.50[ms](mean)
Timeperrequest: 85.30[ms](mean,
acrossallconcurrentrequests)
Transferrate:
58.16[Kbytes/sec]received

ConnnectionTimes(ms)

min mean[+/-sd]median max
Connect: 
01 
9.5 068
Processing:
783 537.4
7 3808

Waiting: 
581 529.1
6 3748

Total:
784 547.0
7 3876

Perce

本文引用网址:

在下列搜索引擎中搜索“基于反向代理的Web缓存加速现代理服务器”的相关信息:

谷歌搜索 百度搜索 雅虎搜索 搜狗搜索 搜搜搜索 必应搜索 有道搜索
你可能还喜欢以下文章
  • 1雨后小故事完整版 雨后的小故事...
  • 2四川美院女生遭前男友发艳照报...
  • 3林晨钰爆奶门照片ed2k 林晨钰爆...
  • 4王婷不雅视频 王婷全裸艳照 王...
  • 5雨后小故事、雨后小故事01动态...
  • 1Dedecms会员注册验证邮箱的实现...
  • 2Z-Blog去掉文章评论的 邮箱 验...
  • 3说说"电视棒"为什么卖得这么火...
  • 4纵观国内美女网站十年发展历程...
  • 510 个提供免费域名搜索建议服务...
  • 1日本AV六级试卷 (附标准答案)
  • 2中国女大学生的淫靡生活
  • 3武汉十七中教室门种子 教室门q...
  • 4林晨钰爆奶门视频qvod 林晨钰爆...
  • 5空姐制服写真@天津外国语学院美...
  • 1加密无痕Win7系统让U盘成为个人...
  • 224日预警:将感染电脑变成FTP服...
  • 3熊猫烧香、威金的解决办法
  • 4vsftp配置大全---超完整版
  • 5服务器技巧 关于虚拟机管理重要...
  • 赞助商广告

    图片文章导读