On 27/08/12 03:53, Dan Fisher wrote:
For most cases, the vast majority of a wiki's
traffic is from non-logged in
users. All kinds of caches should then work in a way where the page does
not have to be rendered again with PHP. An example is Mediawiki's File
caching system:
http://www.mediawiki.org/wiki/Manual:File_cache
It's commonly known that PHP files take a lot more CPU than static content
and this is also the concept behind MW's File caching system.
My situation: I'm on a shared server where they don't want me to go above
certain CPU limits (cpu seconds/per hour). I'm not able to install Squid,
APC or memcached. Lately I've been having problems with CPU usage due to
traffic surges and malicious bots. I don't want to spend more money on
hosting if I don't have to but that option is open if the server company
thinks I should upgrade. I want to be a good client and not effect other
users on the server.
When we designed ResourceLoader, we were aware that there would be
increased server CPU for some shared host users, however there was no
easy way to avoid it, and there were clear performance benefits to the
scheme for users in less constrained server environments.
Serving JS and CSS from PHP allows MediaWiki to control the caching
headers, particularly the Expires header. This gives improved
performance for clients, since they no longer have to continually
re-request server-side resources.
To confirm this, I have seen the static HTML file
generated by the cache,
and these lines are present in the HTML code that is viewed from the
browser or an HTML editor. So load.php is being made to run at least 4
times during each page load.
Only with a cold client cache. Subsequent page views will not need to
fetch all those load.php objects, because of the Expires header.
Some objects are served with a short (5 minute) expiry time. You may
be able to reduce CPU usage slightly by increasing that expiry time,
at the expense of delayed updates to JS and CSS:
$wgResourceLoaderMaxage['unversioned']['server'] = 3600;
$wgResourceLoaderMaxage['unversioned']['client'] = 3600;
Any CDN should be able to read the Expires headers MediaWiki sends,
and use them to offload your webserver. You could even use CoralCDN
(
http://coralcdn.org/), which is a free caching proxy service:
$wgLoadScript = 'http://mywikisite.com.nyud.net/w/load.php';
-- Tim Starling