microsearchのブログ -14ページ目
<< 前のページへ最新 | 10 | 11 | 12 | 13 | 14

squidの「refresh_pattern」について

refresh_pattern: determines how long one cache object can still be in squid cache space.





Grammar:


refresh_pattern [-i] regexp min percent max [options]





Definitions:


resource_age = cached_in_time - last_modified_time of this object in the real resource server


response_age = current_time(i.e. response time) - cached_in_time of this object





Then:


LM-factor = (response_age) / (resouce_age)





Example: refresh_pattern 20%


Given: last_modified time of an object in real server is 2009-04-10 02:00:00 www.example.com/index.html


in squid cache.example.com/index.html the cached_in_time of "/index.html" is 2009-04-10 03:00:00





So,





1) if current_time is 2009-04-10 03:00:00 , then


resource_age = (3 - 2 )(hours) = 60 mins


response_age = 3 - 3 = 0


and "/index.html" can still be in cache space for resouce_age * 20% = 60*20% = 12 mins.


i.e. "/index.html" will not be refreshed untill 12 mins later(namely remain_time).





2) if current_time is 2009-04-10 03:05:00, then


response_age = 5 mins


and "/index.html" can still be in cache space for (resource_age * 20% - response_age) = (12 - 5)mins = 7 mins.


LM-factor = 5 / 60 * 100% = 8.3 % < 20 %





"/index.html" becomes stale when LM-factor == 20 % , which means if at that moment there is a request for "/index.html", squid server will send a check-request to the original resource server for this object and if the response indicates nothing were changed before, squid server will send the client the object cached in squid space even though it is stale and reset the cached_in_time of this object. If changes happened, squid server will reload the latest object to squid space and reset related parameters.





Conclusion:





When there comes a request for an object , squid server will do:


1. calculate the response_age of the requested object;


2. if (response_age < min)


object is fresh;


else if (response_age > max)


object is stale;


else if (response_age < remain_time)


object is fresh;


else


object is stale.








Note:

1) you can also refer to http://blog.chinaunix.net/u/15315/showart_324467.html



2) refresh_patter applies only to those data without explicit Expire filed

初めてのSquid

1.ミッション: 今回、ウェブ加速のために使う







2.コマンドの基本:



①コマンド 名前 タイプ ソース



例:



   acl Localhost src 127.0.0.1/32



②ポート番号----サービスの受付窓



   http_port 80



③ログパスの設定--三つのログが大切。(cache.log, access.log, store.log)



1) cache_access_log /squid/logs/access.log



2) cache_store_log /squid/logs/store.log



3) cache_log /squid/logs/cache.log



④visible_hostname設定しなくても大丈夫



⑤rootユーザでSquidを起動する場合、cache_effective_userが設定されている場合は設定しているユーザに変更、otherwise「nobody」で起動する。







3.起動オプション:



①-k 機能



  機能:reconfigure, rotate, shutdown, interrupt, kill, debug, check, parse.



②-z



  初期化キャッシュ







4.Tips



①Squid起動前、「squid -k parse」でコンッフィグファイルが正しいかどうかを確認する。何も出なければ、正しい。



②キャッシュサービスとしてのSquidは、もちろんリアルタイム的にSquidの状態が確認できるようにするほうがよいので、監視シェルプログラムをDaemonとして実行する。





5.設定例:


① 機能実現


http_port 80 defaultsite=lupcs.microsearch.jp vhost


cache_peer cache.microsearch.jp parent 80 0 no-query originserver name=cache


cache_peer_domain cache lupcs.microsearch.jp


② データ


cache_dir COSS /var/spool/squid/COSS 100 max-size=1048576 block-size=512 membufs=10





注:


Squidを用いてハイパフォーマンスウェブキャッシュシステムを構築する説明文でございます。中国語ですよ!!!







(まだ続けます。今度、cache_peer, cache_peer_domainとhttp_portを詳細的に説明する)



関連リンク:
http://blog.cnw.com.cn/index.php/20937/viewspace-70587
http://blog.c1gstudio.com/archives/130

<< 前のページへ最新 | 10 | 11 | 12 | 13 | 14