The problem: In general, rationalwiki.org is melting under the strain. We can't quite afford the next step up right this moment, though want to plan for it, and need to keep things from intermittently blowing up as they are.
We live on a 4GB Linode. I don't have a full handle on what we've got on it - it's accreted in an ad-hoc fashion with some horrible bodges - but there's several MediaWikis, only one of which (rationalwiki.org) has any appreciable traffic. There's Lucene search, which is of course huge in memory. rationalwiki.org is running via libphp5, the other wikis are via fastcgi (for no particular reason). The wikis have a huge pile of extensions, e.g. http://rationalwiki.org/wiki/Special:Version , a lot of which are local things.
Whenever an article hits Reddit,[1] the server suffers under the load. Typically it goes into swap and thrashes itself to death. If we're really lucky the oom-killer comes out to play and shoots things randomly (usually Apache, maybe Lucene). The fun bit: sometimes it does this for no visible reason, just tips over into swap and promptly stops talking to the world (my shell session still works slowly).
Per advice from here I've re-enabled keepalive, setting it to 10 requests and 2 seconds. This does speed things up a bit for the users. I haven't put a cache on the front as yet, still letting MediaWiki's file cache do that. apc is running (99.8% cache hit rate, so that's fine) and memcached (90% cache hit rate, upped it from 64MB to 128MB and it's still about 90%).
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers? Distributed how?) - and the first thing we need to work out how not to make the box melt in the meantime.
Clues welcomed!
- d.
[1] usually a joke article, like http://rationalwiki.org/wiki/Scientific_evidence_of_evolution_being_a_hoax ... nothing we've actually worked hard on *hand to forehead* [2] this appears pretty typical pricing for non-crappy hosting
Some thoughts:
* Use a front-end web cache.
The old 'file cache' in MediaWiki probably doesn't work as well as it once did, especially since you're on a recent version of MediaWiki that uses ResourceLoader -- that'll mean dynamic hits happen for styles and scripts even on a cached page -- and even that cached page is going through MediaWiki and requires CPU time and memory.
I'm not sure whether any of the cloud-based CDNs play nicely with MediaWiki these days, but you can certainly set up Squid or Varnish on a second Linode box.
A proper caching setup that covers both article views and ResourceLoader (load.php stuff) should be able to avoid a *lot* of hits to PHP as long as people are just clicking around.
You can also do things like loading static resources (uploaded files, skin images etc) from a separate server, but putting a cache in front should cover much the same requirements as that.
* Consider splitting Lucene search to a separate server.
Particularly since it's memory intensive, splitting it out will leave more RAM on your main server for handling spikes.
* Do some load tests and set maximums appropriately
If you've got a lot of MediaWiki hits going simultaneously, that's going to drive up your memory usage. Make sure that hitting the maximum number of server threads doesn't kill you just from loading up Apache+PHP+MediaWiki!
-- brion
On Wed, Oct 17, 2012 at 3:25 PM, David Gerard dgerard@gmail.com wrote:
The problem: In general, rationalwiki.org is melting under the strain. We can't quite afford the next step up right this moment, though want to plan for it, and need to keep things from intermittently blowing up as they are.
We live on a 4GB Linode. I don't have a full handle on what we've got on it - it's accreted in an ad-hoc fashion with some horrible bodges - but there's several MediaWikis, only one of which (rationalwiki.org) has any appreciable traffic. There's Lucene search, which is of course huge in memory. rationalwiki.org is running via libphp5, the other wikis are via fastcgi (for no particular reason). The wikis have a huge pile of extensions, e.g. http://rationalwiki.org/wiki/Special:Version , a lot of which are local things.
Whenever an article hits Reddit,[1] the server suffers under the load. Typically it goes into swap and thrashes itself to death. If we're really lucky the oom-killer comes out to play and shoots things randomly (usually Apache, maybe Lucene). The fun bit: sometimes it does this for no visible reason, just tips over into swap and promptly stops talking to the world (my shell session still works slowly).
Per advice from here I've re-enabled keepalive, setting it to 10 requests and 2 seconds. This does speed things up a bit for the users. I haven't put a cache on the front as yet, still letting MediaWiki's file cache do that. apc is running (99.8% cache hit rate, so that's fine) and memcached (90% cache hit rate, upped it from 64MB to 128MB and it's still about 90%).
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers? Distributed how?) - and the first thing we need to work out how not to make the box melt in the meantime.
Clues welcomed!
- d.
[1] usually a joke article, like http://rationalwiki.org/wiki/Scientific_evidence_of_evolution_being_a_hoax ... nothing we've actually worked hard on *hand to forehead* [2] this appears pretty typical pricing for non-crappy hosting
MediaWiki-l mailing list MediaWiki-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-l
On Wed, Oct 17, 2012 at 7:03 PM, Brion Vibber brion@pobox.com wrote:
A proper caching setup that covers both article views and ResourceLoader (load.php stuff) should be able to avoid a *lot* of hits to PHP as long as people are just clicking around.
This. The database-backed caches (default for ResourceLoader & L10n) work well enough for out of the box users, but you definitely want something that scales. As long as you're on a single host, something like APC's shared memory cache would probably go a long way towards performance.
-Chad
On Thu, October 18, 2012 00:25, David Gerard wrote:
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers? Distributed how?) - and the first thing we need to work out how not to make the box melt in the meantime.
Clues welcomed!
Have you taken a good look at your database configuration? Are you using InnoDB tables, have you allocated enough memory and threads, etc? http://hackmysql.com/mysqlreport (assuming you're running MySQL) may provide some insight.
Siebrand
On Thu, Oct 18, 2012 at 8:25 AM, David Gerard dgerard@gmail.com wrote:
We live on a 4GB Linode. I don't have a full handle on what we've got on it - it's accreted in an ad-hoc fashion with some horrible bodges - but there's several MediaWikis, only one of which (rationalwiki.org) has any appreciable traffic.
Is there any specific reason in regards to the multiple wiki setup? (every little bit helps remember)
There's Lucene search, which is of course huge in memory. rationalwiki.org is running via libphp5, the other wikis are via fastcgi (for no particular reason). The wikis have a
Standardizing configurations will probably be best in the long run, for no other reason than standardization.
huge pile of extensions, e.g. http://rationalwiki.org/wiki/Special:Version , a lot of which are local things.
I would really look at alot of them, and categorise them as "Must haves" "Nice but not needed" and possibly "Why is this even around?", What are these "local" extensions? are their code bases public anywhere?
Whenever an article hits Reddit,[1] the server suffers under the load. Typically it goes into swap and thrashes itself to death. If we're really lucky the oom-killer comes out to play and shoots things randomly (usually Apache, maybe Lucene). The fun bit: sometimes it does this for no visible reason, just tips over into swap and promptly stops talking to the world (my shell session still works slowly).
PoolCounter may help a tiny bit (One of TimS's extensions) which was designed after the Obama incident bringing down en.wp, But there is only so much you can do with limited resources and configuration setups.
Per advice from here I've re-enabled keepalive, setting it to 10 requests and 2 seconds. This does speed things up a bit for the users. I haven't put a cache on the front as yet, still letting MediaWiki's file cache do that. apc is running (99.8% cache hit rate, so that's fine) and memcached (90% cache hit rate, upped it from 64MB to 128MB and it's still about 90%).
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers?
Not really knowledgeable in this area but 200/month does seem a tad expensive, Have you looked elsewhere apart from linnode?
On 18 October 2012 00:23, K. Peachey p858snake@gmail.com wrote:
On Thu, Oct 18, 2012 at 8:25 AM, David Gerard dgerard@gmail.com wrote:
We live on a 4GB Linode. I don't have a full handle on what we've got on it - it's accreted in an ad-hoc fashion with some horrible bodges - but there's several MediaWikis, only one of which (rationalwiki.org) has any appreciable traffic.
Is there any specific reason in regards to the multiple wiki setup? (every little bit helps remember)
You mean, why do they exist? 'Cos this is where they live :-) Some are active with communities (e.g. http://ru.rationalwiki.org), some are mothballed and read-only (e.g. http://evolutionwiki.org).
In terms of the actual wiki setup - no reason whatsoever, horrible ad-hocracy and stuff bodged into place. Directories with 777 permissions to make stuff work. (I fixed those in short order.) The documentation is whatever notes I write down.
There's Lucene search, which is of course huge in memory. rationalwiki.org is running via libphp5, the other wikis are via fastcgi (for no particular reason). The wikis have a
Standardizing configurations will probably be best in the long run, for no other reason than standardization.
Hell yes. The first bit of calm infrastructure I wanted to do was get rationalbeta.com (the staging site, not up right now) into actually being an accurate copy of rationalwiki.org.
(Before that, I'm tempted to do another admin-only wiki for documentation, 'cos I'm used to scribbling notes to self in a MediaWiki. But that might be overkill.)
huge pile of extensions, e.g. http://rationalwiki.org/wiki/Special:Version , a lot of which are local things.
I would really look at alot of them, and categorise them as "Must haves" "Nice but not needed" and possibly "Why is this even around?",
Well, yes. I suspect we could go on an extension cleanup to some extent.
What are these "local" extensions? are their code bases public anywhere?
Anything by Nx, a previous sysadmin. In general, not. And I'm not sure they were entirely brought up to 1.19 spec from the previous 1.16. This increases my fun factor enormously, of course.
Whenever an article hits Reddit,[1] the server suffers under the load. Typically it goes into swap and thrashes itself to death. If we're really lucky the oom-killer comes out to play and shoots things randomly (usually Apache, maybe Lucene). The fun bit: sometimes it does this for no visible reason, just tips over into swap and promptly stops talking to the world (my shell session still works slowly).
PoolCounter may help a tiny bit (One of TimS's extensions) which was designed after the Obama incident bringing down en.wp, But there is only so much you can do with limited resources and configuration setups.
ooo, worth a look.
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers?
Not really knowledgeable in this area but 200/month does seem a tad expensive, Have you looked elsewhere apart from linnode?
Trent looked into the question on behalf of the RationalWiki Foundation (501(c)3 and all) and decent hosting was on that order. And Linode have been very good. (We were with a cheap host a while ago and they were so great that the hosting moved to Trent's house over his DSL for a time.) The joys of finding funding will doubtless keep the question near the top of his mind, however.
- d.
As one option...
On Wed, Oct 17, 2012 at 4:37 PM, David Gerard dgerard@gmail.com wrote:
So second thing we need to work out what our next stage of evolution is (the 8GB Linode for $200/mo more? [2] or multiple servers?
Not really knowledgeable in this area but 200/month does seem a tad expensive, Have you looked elsewhere apart from linnode?
Trent looked into the question on behalf of the RationalWiki Foundation (501(c)3 and all) and decent hosting was on that order. And Linode have been very good. (We were with a cheap host a while ago and they were so great that the hosting moved to Trent's house over his DSL for a time.) The joys of finding funding will doubtless keep the question near the top of his mind, however.
I assume you're on the Linode 4 GB for about $1,900 / yr?
A reserved high-usage Amazon EC2 Large node is going to run $780 / yr commitment charge and about $600/yr for hourly usage fees, at 7.5 GB RAM, 840 GB local storage, etc. And scaling out some more nodes there is easier and faster. It's also $0.12 / GB for data transfer out, so if you're doing more than $500 / $0.12/gb = 4,000 GB / year or more traffic you would be paying ultimately more, but I somehow doubt that.
http://aws.amazon.com/ec2/#instance
Alternately - actual hosting space is around $50/U/month for noncommercial friend rates in the SF Bay Area (and $100/U for anyone); Go to somewhere like server monkey and get a lightly used Dell or HP or IBM rackmount, load up on RAM, install in datacenter, zoom. You now own the hardware problem that way, though...
A few things we've learned over the years through trial and error that may be helpful to you.
I think your biggest improvement is probably getting a Squid/Varnish cache setup (as recently discussed here). Depending on your traffic (logged in vs anonymous viewers) you could see as much as a x6 drop in Apache requests. It also greatly helps with the Slashdot/Reddit effect as most of the views in such a traffic spike will be anonymous viewers which would be handled entirely by Squid/Varnish. It is possible to squeeze Squid into the same server but you have to juggle ports and memory.
You may also be able to reduce the Apache load significantly by moving all static resources (images, CSS, JS) to be served by a lighter weight server like lighttpd or nginx. I guess recently some CSS/JS was changed from static files to the ResourceLoader but there is still plenty of static content to consider it (our lighttpd server averages x10 more connections than our Apache server). Like Squid you can squeeze this into the same server by juggling ports and will probably actually save memory (a lighttpd/nginx connection uses far, far less memory than Apache would).
The net result of these two changes is to try and minimize Apache connections, which are relatively CPU/memory expensive, for only what is needed. As a point of comparison we're currently averaging 170 req/sec over all servers (Squid + lighttpd + Apache) but Apache is only handling 10 req/sec. We simply couldn't handle the traffic if we tried to get Apache to handle all of it.
One quick setting you can look into is to set $wgCacheDirectory to a local directory. We had huge problems recently upgrading from 1.14 to 1.19 until we set this parameter. It may have just been related to our upgrade but anything that reduces database usage, especially on a single server, is usually a good thing.
The only other significant advice I can think of is to make sure you regularly benchmark/load test as you try to optimize things. There are a bunch of good reasons to do this: 1) Documentation 2) Verification : i.e., did we actually make things faster and if so by how much 3) Load Capacity Planning: how many connections/users can we support and how close are we right now to the limit
I usually just use ApacheBench (ab) which gives good enough results but there are plenty of others and you can get as complex testing as you want.
As for hardware, we use iWeb which has reasonable prices although its support it hit or miss (its either great or terrible it seems). We have a variety of dedicated servers in the $100/month range having gone for a horizontal scaling design (more smaller boxes with some redundancies among them). I don't know what resources (money) you have available and what sort of request rate you you're getting but with some optimization and 1 or 2 boxes I would think you should be able to survive a Slashdot/Reddit effect without completely going under.
Beyond this your next step is either scaling up (faster computer) or out (more servers). For scaling out just look at your process usage (top) and see what is using the most CPU/memory and then split that out to the new server. Chances are a good first step would be getting a dedicated database server or another Apache server.
On 17 October 2012 18:25, David Gerard dgerard@gmail.com wrote:
The problem: In general, rationalwiki.org is melting under the strain. We can't quite afford the next step up right this moment, though want to plan for it, and need to keep things from intermittently blowing up as they are.
On 18/10/12 09:25, David Gerard wrote:
Whenever an article hits Reddit,[1] the server suffers under the load. Typically it goes into swap and thrashes itself to death. If we're really lucky the oom-killer comes out to play and shoots things randomly (usually Apache, maybe Lucene). The fun bit: sometimes it does this for no visible reason, just tips over into swap and promptly stops talking to the world (my shell session still works slowly).
It's funny how everyone is telling you how to use less CPU when your problem is actually memory.
I think you should switch everything to FastCGI, and use a single FastCGI process pool for all wikis. Reduce the maximum number of FastCGI workers severely, until the PHP memory_limit multiplied by the maximum worker count is less than the amount of memory you have available for PHP (i.e. physical RAM minus memcached, lucene, etc.)
The point of this is to decouple Apache's MaxChildren from the maximum memory usage. It's essential to have a high MaxChildren on an Apache installation that's directly serving remote users, because Apache will have a lot of threads just waiting around for communication with the remote users to complete, even if you disable keepalive.
With FastCGI, you can have a tiny PHP process pool, and in the event of high load, client connections will politely queue in Apache waiting for a FastCGI slot, instead of all trying to run PHP at once and sending your server into swap death.
Once you've done that, you should then disable swap. I am generally anti-swap -- having swap means that instead of a single process being killed when the server runs out of memory, the whole server becomes unresponsive instead, often requiring a power-cycle. But it's especially bad to use swap on Linode, where I/O can be so slow that even light swapping can cause the server to be unresponsive.
You can use /proc/[pid]/oom_adj to reduce the chance of oom-killer killing Lucene or some other useful process. oom-killer is weird and buggy and sometimes just does its own thing, but you may as well at least try to teach it some manners. Android uses oom_adj to control memory usage on phones, it seems to work for them.
An interesting thing about FastCGI is that you can run the workers in a chroot. If you have 4GB of memory, then I guess you are using a 64-bit Linux distribution. In the worst case, a 64-bit architecture will have double the memory usage of a 32-bit architecture, due to pointer sizes. It turns out that some things MW does are not very far away from that worst case. The schroot "personality" parameter makes it easy to install a chroot environment for PHP which uses 32-bit binaries on a 64-bit host.
If you reduce MW's typical memory usage to say 2/3 of its current value, then you can reduce the memory_limit by the same factor, which implies that you can increase the FastCGI process pool size by 50% for a corresponding increase in maximum throughput, assuming CPU is not maxed out.
-- Tim Starling
We did the following on our MediaWiki server with 3000 users and 150,000 articles:
- Moved Lucene to a separate server. HUGE HUGE benefit in lowering memory use (a - Installed Extension:APC. 50% speedup in page rendering. - Installed memcached. Another 50% speedup in page rendering. - Code-reviewed our custom-written extensions and optimized them. Another 50% speedup in page rendering.
We also increased physical RAM to 6GB (from 2GB), which may or may not be an option for you.
DanB
On 17 October 2012 23:25, David Gerard dgerard@gmail.com wrote:
The problem: In general, rationalwiki.org is melting under the strain. We can't quite afford the next step up right this moment, though want to plan for it, and need to keep things from intermittently blowing up as they are.
What we've done: Trent's rented a couple more small (512MB) Linodes to experiment with, and put Squid on them. And we've abandoned page counts, to slight angst from the users. So far, just running what we can through a Squid has done *wonders* for the main server. w00t! Now to see how our next burst of popularity goes ...
- d.
What we've done: Trent's rented a couple more small (512MB) Linodes to experiment with, and put Squid on them. And we've abandoned page counts, to slight angst from the users. So far, just running what we can through a Squid has done *wonders* for the main server. w00t! Now to see how our next burst of popularity goes ...
If you're already using FastCGI, go ahead and drop apache in favor of nginx/lighthttpd or something similar. Unless there's some reason you absolutely need to stay with apache, less resource intensive alternatives are out there.
On 19 October 2012 22:43, OQ overlordq@gmail.com wrote:
What we've done: Trent's rented a couple more small (512MB) Linodes to experiment with, and put Squid on them. And we've abandoned page counts, to slight angst from the users. So far, just running what we can through a Squid has done *wonders* for the main server. w00t! Now to see how our next burst of popularity goes ...
If you're already using FastCGI, go ahead and drop apache in favor of nginx/lighthttpd or something similar. Unless there's some reason you absolutely need to stay with apache, less resource intensive alternatives are out there.
rationalwiki.org is still on libphp5, the other wikis are on FastCGI. The server setup is sufficiently crufty that I'm reluctant to mess with stuff unless necessary, and swapping out Apache definitely counts as messing ... but now I'm not worrying as much about the server melting, I can think about making everything saner. Then a lighter server might be worthwhile. Is there any particular reason WMF's stayed with Apache?
- d.
On 19 October 2012 22:29, David Gerard dgerard@gmail.com wrote:
What we've done: Trent's rented a couple more small (512MB) Linodes to experiment with, and put Squid on them. And we've abandoned page counts, to slight angst from the users. So far, just running what we can through a Squid has done *wonders* for the main server. w00t! Now to see how our next burst of popularity goes ...
And we've dropped the hit counters, but the stats.grok.se code is available as GPLv3 (a fact that should be more widely known):
https://github.com/abelsson/stats.grok.se
So we might bend that into shape for our uses, if I'm feeling particularly intrepid or Trent's particularly procrastinating from his thesis defence ...
- d.
On 20/10/12 10:03, David Gerard wrote:
And we've dropped the hit counters, but the stats.grok.se code is available as GPLv3 (a fact that should be more widely known):
https://github.com/abelsson/stats.grok.seSo we might bend that into shape for our uses, if I'm feeling particularly intrepid or Trent's particularly procrastinating from his thesis defence ...
- d.
Remember that you first need to make squids output the page views, and store them! stats.grok.se aggregator won't help you if you have nothing to aggregate.
On 20 October 2012 22:56, Platonides Platonides@gmail.com wrote:
On 20/10/12 10:03, David Gerard wrote:
And we've dropped the hit counters, but the stats.grok.se code is available as GPLv3 (a fact that should be more widely known): https://github.com/abelsson/stats.grok.se So we might bend that into shape for our uses, if I'm feeling particularly intrepid or Trent's particularly procrastinating from his thesis defence ...
Remember that you first need to make squids output the page views, and store them! stats.grok.se aggregator won't help you if you have nothing to aggregate.
We have indeed apparently been taking care to log them, knowing we'd probably want to do something with the results. Trent apparently has quite a rant stored up on the subject.
- d.
On 19 October 2012 22:29, David Gerard dgerard@gmail.com wrote:
On 17 October 2012 23:25, David Gerard dgerard@gmail.com wrote:
The problem: In general, rationalwiki.org is melting under the strain. We can't quite afford the next step up right this moment, though want to plan for it, and need to keep things from intermittently blowing up as they are.
What we've done: Trent's rented a couple more small (512MB) Linodes to experiment with, and put Squid on them. And we've abandoned page counts, to slight angst from the users. So far, just running what we can through a Squid has done *wonders* for the main server. w00t! Now to see how our next burst of popularity goes ...
And by the way, the responsiveness is wonderful. My goodness the site is fast now. Two seconds to load a random page to read, about that to read a random diff or save an edit. So yeah, if you have the symptoms we had, put a small Squid/Varnish in front and see how things go.
- d.
mediawiki-l@lists.wikimedia.org