Changeset 898 for trunk/PublicCacheAddOn/twpc/PublicCacheAddOn.txt
- Timestamp:
- 11/24/08 01:10:49 (4 years ago)
- File:
-
- 1 edited
-
trunk/PublicCacheAddOn/twpc/PublicCacheAddOn.txt (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PublicCacheAddOn/twpc/PublicCacheAddOn.txt
r878 r898 1 1 ---+ Public Cache Add-On 2 2 <table align='right'><tr><td bgcolor='#eeeeee'>%TOC%</table> 3 Makes TWiki surviving being3 Makes Foswiki surviving being 4 4 [[http://en.wikipedia.org/wiki/Slashdot_effect][Slashdotted]] 5 5 - serves pages 100 times faster. 6 6 ---++ Goals 7 7 I made this addon for people (like me) wanting to have their personal (or 8 small group) *public web site* on a TWiki. The problems I want to address are8 small group) *public web site* on a Foswiki. The problems I want to address are 9 9 thus the ones important for this scenario: 10 10 * many *more reads* and readers than edits and authors 11 11 * extreme *performance*, serving a page in few 100th of a second. 12 12 * huge *spikes* of visitors, being able to survive a slashdot effect. It 13 should handle 10000 simultaneous requests on a TWiki topic on a 1Ghz13 should handle 10000 simultaneous requests on a Foswiki topic on a 1Ghz 14 14 machine. It does this by locking to ensure only one process tries to 15 15 build a page at a time, reducing tremendously the load on the server, even … … 30 30 cycle: you must not have to have to 31 31 refresh manually a page to see the edits you just did to it. 32 * *compatible* should work with all TWiki features, options and plugins32 * *compatible* should work with all Foswiki features, options and plugins 33 33 (or most of them: not the ones trying to show 34 34 different things to different people). Most important are features … … 43 43 just fast). 44 44 45 This caching system has thus different goals than TWiki:Codev/TWikiCache that45 This caching system has thus different goals than Foswiki:Development.FoswikiCache that 46 46 will accelerate even page builds, in an exact and optimal way, but will be 47 47 less slashdot-resistant, and the mod_perl, speedycgi, persistent perl perl … … 86 86 force refresh of pages or webs that change without human editing (for instance 87 87 blog pages showing "Edited N days ago"), you must position the 88 =PUBLIC_CACHE_EXPIRE= TWiki variableto the number of seconds after which the88 =PUBLIC_CACHE_EXPIRE= Foswiki macro to the number of seconds after which the 89 89 cache will be automatically cleared. Note that as this will be performed by the 90 90 next run of the crontab job =pccl=, normally each 3 minutes. … … 101 101 =%<nop>INCLUDE{http://some.site/external}%= automatically sets a 102 102 =PUBLIC_CACHE_EXPIRE= of the default value, if not already set by an 103 explicit declaration. This variable is a normal TWiki variable, so you can use103 explicit declaration. This variable is a normal Foswiki macro, so you can use 104 104 it in a web preferences to set a cache policy to a whole web. 105 105 … … 108 108 __Note:__ You do not need to install anything on the browser to use this 109 109 add-on. The following instructions are for the administrator who installs the 110 add-on on the server where TWiki is running.110 add-on on the server where Foswiki is running. 111 111 112 112 * Download the TGZ file from the Add-on Home (see below) … … 116 116 * if you are *upgrading from a version before 4.0*, 117 117 * first do a =./uninstall TWIKI_DIR/bin= 118 * in your TWiki site, search for all occurences of =PCACHEEXPTIME= vars,118 * in your Foswiki site, search for all occurences of =PCACHEEXPTIME= vars, 119 119 and replace them with declarations 120 120 <br> =* Set PUBLIC_CACHE_EXPIRE = 1= (1, or the previous value =NNN= of … … 130 130 clean duty every 3 minutes, as 131 131 <br> =*/3 * * * * test -x TWIKI_DIR/bin/pccl && TWIKI_DIR/bin/pccl= 132 * the install script will install small patches to the TWiki code, in133 =lib/ TWiki.pm=, =lib/TWiki/Func.pm=, and =lib/TWiki/UI/View.pm=. The132 * the install script will install small patches to the Foswiki code, in 133 =lib/Foswiki.pm=, =lib/Foswiki/Func.pm=, and =lib/Foswiki/UI/View.pm=. The 134 134 patches are clearly surrounded by =#TWikiPublicCacheAddOn_Patch...= 135 135 comments 136 * If you *update your TWiki* install, or install afterwards the137 Foswiki:Extensions/NewsPlugin or TWiki:TagMePlugin (or any future plugin138 calling the = TWiki::Func::saveFile= function,you must re-do an136 * If you *update your Foswiki* install, or install afterwards the 137 Foswiki:Extensions/NewsPlugin or System:TagMePlugin (or any future plugin 138 calling the =Foswiki::Func::saveFile= function,you must re-do an 139 139 =install -u= in order to apply the patches above. 140 140 * To be sure people notified of changes by email will actually see the … … 146 146 <br /> to check every hour for uncached pages and build them 147 147 148 Note that the argument can just be TWIKI_DIR if your TWiki perl scripts148 Note that the argument can just be TWIKI_DIR if your Foswiki perl scripts 149 149 dir is in the standard place (as a =bin/= subdirectory), otherwise you must 150 give the actual path of your TWiki perl scripts directory.150 give the actual path of your Foswiki perl scripts directory. 151 151 152 152 To update, or change options, just redo install. This will clear the cache. type =./install -h= to see options, i.e: … … 160 160 * =-eseconds= default value for %<nop>PUBLIC_CACHE_EXPIRE% (defaults to 3600) 161 161 * -wWebList= make pcad build menu and pcge default mode not rebuild 162 these webs. List is comma-separated. (defaults to -wMain, TWiki,Sandbox,Trash)162 these webs. List is comma-separated. (defaults to -wMain,System,Sandbox,Trash) 163 163 * =-v= verbose: logs a lot of things in data/twpc-debug.txt 164 164 … … 237 237 238 238 ---+++ Tips 239 * Use robots.txt on your site to prevent browsing the TWikiweb. e.g,240 <br> =Disallow: /bin/view/ TWiki=239 * Use robots.txt on your site to prevent browsing the System web. e.g, 240 <br> =Disallow: /bin/view/System= 241 241 <br> You may want to also disallow access to Main, Sandbox, and Trash. 242 Why? The TWikiweb represent often an important (more than 500 pages)243 part of a TWiki web site. This has the drawback of242 Why? The System web represent often an important (more than 500 pages) 243 part of a Foswiki web site. This has the drawback of 244 244 * Making search engines produce less relevant results for your site 245 (your personal contents will be diluted into the TWiki docs)245 (your personal contents will be diluted into the Foswiki docs) 246 246 * Google has a time limit for browsing a site. He may thus only crawl 247 part of your TWiki site on first run and not index your actual content248 * As the cache will be totally cleared on edits, it means that the TWiki247 part of your Foswiki site on first run and not index your actual content 248 * As the cache will be totally cleared on edits, it means that the Foswiki 249 249 cache will be re-computed over and over on crawling by search 250 250 engines, consuming needless CPU and bandwidth 251 * Use a perl accelerator: TWiki:Codev/ModPerl, TWiki:Codev/SpeedyCGI or 252 TWiki:Codev/PersistentPerl 251 * Use a perl accelerator: Mod-Perl, Speedy CGI or Persistent Perl 253 252 254 253 ---++ Implementation … … 268 267 without caching it. 269 268 * the "cache builder", *pcbd* (shell) calls the copy of the original 270 TWiki view script (named *vief*) to make it build the page, and save269 Foswiki view script (named *vief*) to make it build the page, and save 271 270 it in normal and gzipped versions. If it cannot get it (read-protected 272 271 page) it saves a marker to remember not trying to build it and 273 272 directly delegate to vief. 274 * an automatically installed TWiki plugin *PublicCachePlugin* (perl)273 * an automatically installed Foswiki plugin *PublicCachePlugin* (perl) 275 274 installs just an afterSaveHandler hook to track the changes in topics, 276 275 and save the IP Adress of the client browser that edited the page as a … … 305 304 * Cached pages have ETags so that the browser will not even re-download 306 305 them if they have not changed. 307 * TWiki code is slightly patched (some lines in TWiki.pm, to set306 * Foswiki code is slightly patched (some lines in Foswiki.pm, to set 308 307 =%<nop>PUBLIC_CACHE_EXPIRE%= on inclusion of external urls). 309 308 The patch consists of the lines between 310 309 =#TWikiPublicCacheAddOn_PatchInclude_START= and 311 310 =#TWikiPublicCacheAddOn_PatchInclude_END= . 312 After a TWiki update,311 After a Foswiki update, 313 312 just reinstall this addon. This patch work with 4.x versions, and 314 313 probably newer ones. But it is just for convenience to avoid putting 315 314 =Set PUBLIC_CACHE_EXPIRE= by hand on all topics using 316 315 =%<nop>INCLUDE{external-url}% 317 * If you use TWiki:Codev/ModPerl, TWiki:Codev/SpeedyCGI or TWiki:Codev/PersistentPerl, check that you enable316 * If you use mod-perl, Speedy CGI or Persistent Perl, check that you enable 318 317 it also for =bin/vief= for better performance, and *disable it for view*, as it 319 318 no more a perl file and will crash your server … … 335 334 * linux (or any unix with GNU utilities, but untested) 336 335 * TWiki Cairo, Dakar, Edinburgh, Freetown, ... (3.0 -> 4.2). Should work on 337 any version at it is very disconnected from TWiki perl code. Warning:336 any version at it is very disconnected from TWiki/Foswiki perl code. Warning: 338 337 Cairo(3.0) is only supported in the version 3.1 of this plugin 339 338 * Changes to pages not resulting from an edit will not be shown … … 366 365 ---++ Performance, benchmarks 367 366 Current performance: (celeron 1Ghz, 512M RAM, Apache 1.3, 150 max processes) 368 for 20 simultaneous requests for the same TWiki page:367 for 20 simultaneous requests for the same Foswiki page: 369 368 |*Configuration*|*First run, empty cache*|*2nd run, cache built*| 370 369 | Normal 4.2 | 143s load 20 | 143s load 20 | 371 | TWiki:Codev/TWikiCache | 66s load 12 | 65s load 11 |370 | Foswiki:Development.FoswikiCache | 66s load 12 | 65s load 11 | 372 371 | Cairo+mod_perl+koalaskin | 28s load 8 | 18s load 9 | 373 372 | Cairo+speedy+koalaskin | 20s load 6 | 17s load 8 | … … 394 393 <br> =i=1000;while let 'i-->0';do curl -s --compressed <nop>http://mytwiki/bin/view/System/Macros >/dev/null& done; time wait= 395 394 396 Note that it does *not* mean this cache is better that TWiki:Codev/TWikiCache395 Note that it does *not* mean this cache is better that Foswiki:Development.FoswikiCache 397 396 for all uses. If you just look at the time to load a single page: 398 397 |*Configuration*|*1rst time*|*2nd time*| … … 400 399 | Normal+speedy | 6s | 5.5s | 401 400 | publiccache | 6s | 0.06s | 402 | TWiki:Codev/TWikiCache | 4.3s | 3.3s |403 | TWiki:Codev/TWikiCache + speedy | 4.5s | 3s |404 You can see that ! TWikiCache will be better suited for intranet sites, and the401 | Foswiki:Development.FoswikiCache | 4.3s | 3.3s | 402 | Foswiki:Development.FoswikiCache + speedy | 4.5s | 3s | 403 You can see that !FoswikiCache will be better suited for intranet sites, and the 405 404 only option if you use access control or have personalized views anyways. And 406 405 my "benchmark" is really braindead and do not model typical use. And it only … … 412 411 * Set SHORTDESCRIPTION = Fast cache geared for public site usage 413 412 414 | Add-on Author: | TWiki:Main.ColasNahaboo |415 | Copyright: | © 2008, TWiki:Main.ColasNahaboo |413 | Add-on Author: | Foswiki:Main.ColasNahaboo | 414 | Copyright: | © 2008, Foswiki:Main.ColasNahaboo | 416 415 | License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) | 417 416 | Add-on Version: | 12 Apr 2008 (V4.006) | … … 438 437 | 29 Jan 2008: | algorithm v2, beta, autoconfig | 439 438 | 13 Jan 2008: | Initial version, v1, alpha | 440 | TWiki Dependency: | $TWiki::Plugins::VERSION 1.020 (TWiki 3.0) |439 | Foswiki Dependency: | $Foswiki::Plugins::VERSION 1.020 (TWiki 3.0) | 441 440 | CPAN Dependencies: | LWP::Simple File::Path | 442 441 | Other Dependencies: | bash, sed, wget, grep, crontab, cc (optional), ... | … … 448 447 __Related Topic:__ %SYSTEMWEB%.ContributedAddOns 449 448 450 -- TWiki:Main/ColasNahaboo449 -- Foswiki:Main/ColasNahaboo
Note: See TracChangeset
for help on using the changeset viewer.
