注意:HTTP_X_FORWARDED_FOR如果經(jīng)過(guò)了多個(gè)中間代理服務(wù)器,有何能是逗號(hào)分割的多個(gè)地址, 比如:200.28.7.155,200.10.225.77 unknown,219.101.137.3 因此在很多舊的數(shù)據(jù)庫(kù)設(shè)計(jì)中(比如BBS)往往用來(lái)記錄客戶(hù)端地址的字段被設(shè)置成20個(gè)字節(jié)就顯得過(guò)小了。 經(jīng)常見(jiàn)到類(lèi)似以下的錯(cuò)誤信息:
Microsoft JET Database Engine 錯(cuò)誤 '80040e57' 字段太小而不能接受所要添加的數(shù)據(jù)的數(shù)量。試著插入或粘貼較少的數(shù)據(jù)。 /inc/char.asp,行236
原因就是在設(shè)計(jì)客戶(hù)端訪問(wèn)地址時(shí),相關(guān)用戶(hù)IP字段大小最好要設(shè)計(jì)到50個(gè)字節(jié)以上,當(dāng)然經(jīng)過(guò)3層以上代理的幾率也非常小。 如何檢查目前站點(diǎn)頁(yè)面的可緩存性(Cacheablility)呢?可以參考以下2個(gè)站點(diǎn)上的工具: http://www.ircache.net/cgi-bin/cacheability.py
附:SQUID性能測(cè)試試驗(yàn) phpMan.php是一個(gè)基于php的man page server,每個(gè)man page需要調(diào)用后臺(tái)的man命令和很多頁(yè)面格式化工具,系統(tǒng)負(fù)載比較高,提供了Cache Friendly的URL,以下是針對(duì)同樣的頁(yè)面的性能測(cè)試資料: 測(cè)試環(huán)境:Redhat 8 on Cyrix 266 / 192M Mem 測(cè)試程序:使用apache的ab(apache benchmark): 測(cè)試條件:請(qǐng)求50次,并發(fā)50個(gè)連接 測(cè)試項(xiàng)目:直接通過(guò)apache 1.3 (80端口) vs squid 2.5(8000端口:加速80端口)
測(cè)試1:無(wú)CACHE的80端口動(dòng)態(tài)輸出: ab -n 100 -c 10 http://www.chedong.com:81/phpMan.php/man/kill/1 This is ApacheBench, Version 1.3d <$Revision: 1.2 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2001 The Apache Group, http://www.apache.org/
Benchmarking localhost (be patient).....done Server Software: Apache/1.3.23 Server Hostname: localhost Server Port: 80
Document Path: /phpMan.php/man/kill/1 Document Length: 4655 bytes
Concurrency Level: 5 Time taken for tests: 63.164 seconds Complete requests: 50 Failed requests: 0 Broken pipe errors: 0 Total transferred: 245900 bytes HTML transferred: 232750 bytes Requests per second: 0.79 [#/sec] (mean) Time per request: 6316.40 [ms] (mean) Time per request: 1263.28 [ms] (mean, across all concurrent requests) Transfer rate: 3.89 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max Connect: 0 29 106.1 0 553 Processing: 2942 6016 1845.4 6227 10796
Waiting: 2941 5999 1850.7 6226 10795
Total: 2942 6045 1825.9 6227 10796
Percentage of the requests served within a certain time (ms) 50% 6227 66% 7069 75% 7190 80% 7474 90% 8195 95% 8898 98% 9721 99% 10796 100% 10796 (last request)
測(cè)試2:SQUID緩存輸出 /home/apache/bin/ab -n50 -c5 "http://localhost:8000/phpMan.php/man/kill/1" This is ApacheBench, Version 1.3d <$Revision: 1.2 $> apache-1.3 Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright (c) 1998-2001 The Apache Group, http://www.apache.org/
Benchmarking localhost (be patient).....done Server Software: Apache/1.3.23 Server Hostname: localhost Server Port: 8000
Document Path: /phpMan.php/man/kill/1 Document Length: 4655 bytes
Concurrency Level: 5 Time taken for tests: 4.265 seconds Complete requests: 50 Failed requests: 0 Broken pipe errors: 0 Total transferred: 248043 bytes HTML transferred: 232750 bytes Requests per second: 11.72 [#/sec] (mean) Time per request: 426.50 [ms] (mean) Time per request: 85.30 [ms] (mean, across all concurrent requests) Transfer rate: 58.16 [Kbytes/sec] received
Connnection Times (ms)
min mean[+/-sd] median max Connect: 0 1 9.5 0 68 Processing: 7 83 537.4 7 3808
Waiting: 5 81 529.1 6 3748
Total: 7 84 547.0 7 3876
Percentage of the requests served within a certain time (ms) 50% 7 66% 7 75% 7 80% 7 90% 7 95% 7 98% 8 99% 3876 100% 3876 (last request)
結(jié)論:No Cache / Cache = 6045 / 84 = 70 結(jié)論:對(duì)于可能被緩存請(qǐng)求的頁(yè)面,服務(wù)器速度可以有2個(gè)數(shù)量級(jí)的提高,因?yàn)镾QUID是把緩存頁(yè)面放在內(nèi)存里的(因此幾乎沒(méi)有硬盤(pán)I/O操作)。
小節(jié):
大訪問(wèn)量的網(wǎng)站應(yīng)盡可能將動(dòng)態(tài)網(wǎng)頁(yè)生成靜態(tài)頁(yè)面作為緩存發(fā)布,甚至對(duì)于搜索引擎這樣的動(dòng)態(tài)應(yīng)用來(lái)說(shuō),緩存機(jī)制也是非常非常重要的。
在動(dòng)態(tài)頁(yè)面中利用HTTP Header定義緩存更新策略。
利用緩存服務(wù)器獲得額外的配置和安全性
日志非常重要:SQUID日志缺省不支持COMBINED日志,但對(duì)于需要REFERER日志的這個(gè)補(bǔ)丁非常重要:http://www.squid-cache.org/mail-archive/squid-dev/200301/0164.html
參考資料: HTTP代理緩存 http://vancouver-webpages.com/proxy.html
可緩存的頁(yè)面設(shè)計(jì) http://linux.oreillynet.com/pub/a/linux/2002/02/28/cachefriendly.html 運(yùn)用ASP.NET的輸出緩沖來(lái)存儲(chǔ)動(dòng)態(tài)頁(yè)面 - 開(kāi)發(fā)者 - ZDNet China http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39110239-2,00.htm 相關(guān)RFC文檔:
RFC 2616:
section 13 (Caching) section 14.9 (Cache-Control header) section 14.21 (Expires header) section 14.32 (Pragma: no-cache) is important if you are interacting with HTTP/1.0 caches section 14.29 (Last-Modified) is the most common validation method section 3.11 (Entity Tags) covers the extra validation method
可緩存性檢查 http://www.web-caching.com/cacheability.html 緩存設(shè)計(jì)要素 http://vancouver-webpages.com/CacheNow/detail.html
ZOPE上的幾篇使用APACHE MOD_PROXY MOD_GZIP加速的文檔 http://www.zope.org/Members/anser/apache_zserver/ http://www.zope.org/Members/softsign/ZServer_and_Apache_mod_gzip http://www.zope.org/Members/rbeer/caching
本文鏈接:http://m.95time.cn/tech/program/2004/1803.asp
出處:CheDong
責(zé)任編輯:cjj
上一頁(yè) 可緩存的CMS系統(tǒng)設(shè)計(jì) [1] 下一頁(yè)
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|