明輝手游網(wǎng)中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

可緩存的CMS系統(tǒng)設計 [2]

[摘要]注意:HTTP_X_FORWARDED_FOR如果經(jīng)過了多個中間代理服務器,有何能是逗號分割的多個地址,比如:200.28.7.155,200.10.225.77 unknown,219.101.137.3因此在很多舊的數(shù)據(jù)庫設計中(比如BBS)往往用來記錄客戶端地址的字段被設置成20個字節(jié)就顯得...

注意:HTTP_X_FORWARDED_FOR如果經(jīng)過了多個中間代理服務器,有何能是逗號分割的多個地址,
比如:200.28.7.155,200.10.225.77 unknown,219.101.137.3
因此在很多舊的數(shù)據(jù)庫設計中(比如BBS)往往用來記錄客戶端地址的字段被設置成20個字節(jié)就顯得過小了。
經(jīng)常見到類似以下的錯誤信息:Microsoft JET Database Engine 錯誤 '80040e57'
字段太小而不能接受所要添加的數(shù)據(jù)的數(shù)量。試著插入或粘貼較少的數(shù)據(jù)。
/inc/char.asp,行236 原因就是在設計客戶端訪問地址時,相關用戶IP字段大小最好要設計到50個字節(jié)以上,當然經(jīng)過3層以上代理的幾率也非常小。
如何檢查目前站點頁面的可緩存性(Cacheablility)呢?可以參考以下2個站點上的工具:
http://www.ircache.net/cgi-bin/cacheability.py

附:SQUID性能測試試驗
phpMan.php是一個基于php的man page server,每個man
page需要調用后臺的man命令和很多頁面格式化工具,系統(tǒng)負載比較高,提供了Cache
Friendly的URL,以下是針對同樣的頁面的性能測試資料:
測試環(huán)境:Redhat 8 on Cyrix 266 / 192M Mem
測試程序:使用apache的ab(apache benchmark):
測試條件:請求50次,并發(fā)50個連接
測試項目:直接通過apache 1.3 (80端口) vs squid 2.5(8000端口:加速80端口) 測試1:無CACHE的80端口動態(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 gt; 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:
80Document Path:
/phpMan.php/man/kill/1
Document Length: 4655 bytesConcurrency 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] receivedConnnection Times (ms)min mean[+/-sd] median max
Connect: 0
29 106.1 0 553
Processing: 2942 6016
1845.4 6227 10796Waiting:
2941 5999 1850.7 6226 10795Total:
2942 6045 1825.9 6227 10796Percentage 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)測試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 gt; 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:
8000Document Path:
/phpMan.php/man/kill/1
Document Length: 4655 bytesConcurrency 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] receivedConnnection Times (ms)min mean[+/-sd] median max
Connect:
0 1
9.5 0 68
Processing:
7 83 537.4
7 3808Waiting:
5 81 529.1
6 3748Total:
7 84 547.0
7 3876Percentage 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)結論:No Cache / Cache = 6045 / 84 = 70
結論:對于可能被緩存請求的頁面,服務器速度可以有2個數(shù)量級的提高,因為SQUID是把緩存頁面放在內存里的(因此幾乎沒有硬盤I/O操作)。小節(jié):大訪問量的網(wǎng)站應盡可能將動態(tài)網(wǎng)頁生成靜態(tài)頁面作為緩存發(fā)布,甚至對于搜索引擎這樣的動態(tài)應用來說,緩存機制也是非常非常重要的。
在動態(tài)頁面中利用HTTP Header定義緩存更新策略。
利用緩存服務器獲得額外的配置和安全性
日志非常重要:SQUID日志缺省不支持COMBINED日志,但對于需要REFERER日志的這個補丁非常重要:http://www.squid-cache.org/mail-archive/squid-dev/200301/0164.html 參考資料:
HTTP代理緩存
http://vancouver-webpages.com/proxy.html
可緩存的頁面設計
http://linux.oreillynet.com/pub/a/linux/2002/02/28/cachefriendly.html
運用ASP.NET的輸出緩沖來存儲動態(tài)頁面 - 開發(fā)者 - ZDNet China
http://www.zdnet.com.cn/developer/tech/story/0,2000081602,39110239-2,00.htm
相關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
緩存設計要素
http://vancouver-webpages.com/CacheNow/detail.htmlZOPE上的幾篇使用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