PS: I work for cloud computing company and have insight on how much costs increase with scale.
edit: fixed typos.
PS: I work for cloud computing company and have insight on how much costs increase with scale.
edit: fixed typos.
It does not significantly use cloud services, and as you can see by the picture of their racks, they use standard 1 RU pizzaboxes. Their workload is highly scalable horizontally, and doesn't even need much in the way of expensive "enterprise" hardware such a SAN arrays: https://upload.wikimedia.org/wikipedia/commons/thumb/c/ca/Wi...
If you buy beige box rackmount hardware with basic compute and CPU, it's pretty easy to spend less than $250K per rack, and the hardware can be kept for 5+ years. That's about 50K per rack per year. Double that for opex, and assume twenty racks distributed across a a handful of sites for capacity and availability. That's just $2M per annum.
Keep in mind they're a high-profile charity, so they get discounts and tax breaks.
(I'm not saying that's all there is to Wikipedia! There's software development, management, finance, etc... I'm just saying that the infrastructure alone is probably less than you think.)
PS: English Wikipedia gets about 250M page views per day, which is only about 3,000 per second. If they used an efficient language instead of PHP, that's well within the capability of a single modern server! There have been comments along these lines made in other forums, and the response was that it would cost more to rewrite the software than the maintain the hardware required for PHP. I don't remember the numbers, but I vaguely remember tens of millions for a rewrite, a high risk of breaking issues, and a significantly lower hardware cost.
They do host their own private "cloud", mostly used for research and project development.
> English Wikipedia gets about 250M page views per day, which is only about 3,000 per second. If they used an efficient language instead of PHP, that's well within the capability of a single modern server!
Nitpicking, page views from outside users are not supposed to hit PHP at all - those requests should be served by their caching layer. But yes, you're correct that they're relying on quite a bit of legacy tech from their early days, not just PHP but MariaDB as well even though many enterprises would now rely on Postgres wrt. these use cases. I suppose that they could rewrite the stuff piecemeal, and recent developments in PHP itself would make it easier. (Some things have been rewritten already, notably the wikitext parser. That's clearly one thing where you would want to avoid breakage at all costs, but they did get it done.)
Postgres is great and all, but there’s really nothing wrong with relying on MariaDB or MySQL for what Wikipedia is doing.
The new parser is being rewritten in php in order to be integrated with the rest of the php code.
Hm, since Wikipedia dumps are public, has anybody tried? Moving wikipedia itself might be a large endeavor, but seeing some submissions on HN I think a very dedicated dev or two could possibly manage a rewrite to have a proof of concept.
For any attempt at porting over MW, you will need to re-implement the whole parse/include stuff... and that is a lot of work, even for a proper team.
MediaWiki repository size is about 1.4 GB and according to phploc it has closer to a million lines of PHP code. Sounds like fools errand to rewrite it.
The wiki staff themselves admitted that the current parser is inefficient, partly because of PHP, partly because the underlying grammar was not designed to be efficient, and partly because the parser itself was built up over time and wasn't easy to optimise.
My approach was to write the parser and a matching "markdown inspired" format at the same time, optimised for speed. Just a handful of small tweaks to the syntax were all that was required to largely eliminate backtracking and achieve a nearly linear parsing time in most cases. If I remember correctly, I had it down to about 1-5ms for a typical 64 KB page, and then HTML generation was another 5-10ms depending on various factors.
What a lot of people are missing here is that Wikis are not at all like typical "ERP" applications. The latter sometimes requires dozens of API calls and thousands of database queries to generate just one kilobyte of output HTML. Wiki is very linear, with a single 1-100KB blob of text as input, a matching 1-100KB blob of HTML as output. It all boils down to the parsing and HTML generation efficiency, nothing else matters!
You can parse grammar on save and make an optimized compiled format where static content is already resolved. Next step is to substitute semi-static content (like author name) to a runtime format, this last format can handle dynamic data substitution like current date & time, but probably going to be rare that any substitution is needed for the runtime format (how much truly dynamic data does a wiki have?), most of the time just print it with readfile or similar. Only difficult part here is cache invalidation for the runtime format (I know, it is one of the three difficult things you can do in programming).
3000 request/second in PHP is not hard, especially if you plan for it.
This is why it amuses me that people seem to think that Wikipedia "requires" tens of millions of dollars of infrastructure to host. It doesn't require it. It's just that some things are better/easier with more kit, such as maintenance.
This type of comment betrays a complete lack of knowledge about how large scale internet systems operate (which is something I've worked on for the last 10+ years) and comes across as incredibly naive. I can immediately point out huge flaws in your thinking:
* You're assuming that traffic is constant through the day (that you can divide daily traffic rate to get a sense of daily peak; or, in other words, you provision for mean usage, not peak)
* You're ignoring the problems of unpredictable hotspots (single articles suddenly becoming orders of magnitude more popular than the median in relatively unpredictable and spikey ways; think World Cup final or major earthquake)
* You're not reserving any safety margins for unexpected traffic growth, so you'd likely run into cascading failures
* You're assuming that the entirety of Wikipedia can be held in ram. Including all the history and such. Or, if not, that a single server has enough drives that spindle capacity won't be a problem.
* You're not even considering networking/bandwidth costs. How many network cards would your server need?
* You're ignoring any problems with replication/redundancy (e.g., no backups?) so your site would be a nightmare in reliability terms. Of course, once you do that, you'll need to reason about consistency problems.
I think your logical fallacy is that you're thinking that because your can't understand something (that running Wikipedia could cost so much), it must mean that the thing you can't understand isn't true. Instead, I'd suggest that you'd get further by focusing on discovering the limits of your understanding and genuinely asking yourself: "How could it be that it costs so much? What may I be missing?"
Also, don't assume I'm speaking from a position of ignorance here, I know more than a little about how Wikipedia works. I've perused the source, played with the database dumps, etc...
I find comments like yours amusing, because I hear similar things in the industry all the time! People like you are not wrong, it's just that correct knowledge is very rapidly outdated in this industry. It's shocking what exponential growth really means! As a random example, I once had an engineer going on and on about their "powerful" email server that cost them six figures. I pointed out that it was slower than the Blackberry phone it was synchronising the email to. (No, really!)
You really underestimate the spec of a modern, 2021 era server!
You really are.
You can buy, right now, for "normal" money, a server with two 64-core AMD EPYC CPUs. That's 128 cores that are the fastest individually of pretty much any server CPU. This platform provides 256 hardware threads. Right there, you're looking at something like 12 requests per second per thread. As long as you can serve them in under 85 milliseconds each on average, that's plenty!
I've written a Wikipedia clone for an in-house CMS. The content generation was so fast that for laughs I compiled it to javascript and had it run per keystroke for a live preview in the browser. This worked fine for content up to about 64 KB. This was in 2008, by the way. Things have moved on in terms of performance. Try this with Rust and some judicious use of high-performance AVX-enhanced parsers, and you could generate a typical Wikipedia page in under 10 ms, no sweat. Then there's output caching to get it even lower...
That server can have something like 4 TB of memory in it. The entire Wikipedia database is just 5.6 TB uncompressed.
Yes, you really can fit most of Wikipedia in memory!
Bandwidth? Mellanox makes 200 Gbps Ethernet cards. They're dual port, so that's 400 Gbps. That's enough to handle the bandwidth of a decent sized regional telecommunications company through a single box. I should know, I've seen the network diagram of mine, and they have only 100 Gbps inter-city links!
Spindles!? Are you kidding me? There are gaming PCs being built right now with 2 TB NVMe drives in them that can individually put out 7 GB/s and 1M IOPS! Who the hell puts servers on spinning rust in this day and age? That lone, single NVMe drive is putting out 56 Gbps by itself. Throw in a smidge of caching, and it could saturate those aforementioned 2x200 Gbps ports.
So no, I would not put the entirety of Wikipedia on just one server, that would be silly.
I would put it on two.
Okay, maybe three, for redundancy. Just in case.
This is incorrect. Many of the numbers you throw out ignore that in order to serve its content a server must do some work, which requires both CPU time and memory. Assuming you were able to eliminate hard drives and fit everything into RAM, you still have the problem that to serve requests and do that work you need RAM.
>That server can have something like 4 TB of memory in it. The entire Wikipedia database is just 5.6 TB uncompressed. >Yes, you really can fit most of Wikipedia in memory!
This is incorrect. According to Wikimedia[2], the entire uncompressed size of Wikipedia is 19TB as of 2019, and the site has grown since.
Talking specifically about hard drives:
> Spindles!? Are you kidding me? There are gaming PCs being built right now with 2 TB NVMe drives in them that can individually put out 7 GB/s and 1M IOPS! Who the hell puts servers on spinning rust in this day and age? That lone, single NVMe drive is putting out 56 Gbps by itself. Throw in a smidge of caching, and it could saturate those aforementioned 2x200 Gbps ports.
Firstly, gaming PCs are almost always ahead of the curve when it comes to performance on everything.
Secondly, to your question about who puts servers on spinning rust -- Pretty much everyone. Backblaze even releases HDD reliability ratings[1] based on what they observe in terms of the spinning platter drives.
Also, your 2TB NVMe drive is going to cap out at around a quarter of what the large-spindle raid controller can, and you can have a few of those in each system if you want. Sure, a PCIe 4.0 NVMe drive is going to get you 7.88GB/s in your motherboard slot but a PCIe 4.0 raid controller can have four times that bandwidth available to it.
But for argument's sake let's say you decided to swap out your raid controller for a PCIe 4.0 card that does NVMe and has onboard raid (these don't exist for purchase yet that I can find at my usual suppliers but I imagine they're coming). Now you have a size problem. The largest current best available SSDs are Sabrent's 8TB PCIe 3.0 drives. This will cut the performance considerably but is probably the sweet spot for size & speed. You need 4 of them just to host current Wikipedia, limiting any growth, and certainly without factoring in any other parts of the system that may take away from the operation.
For comparison's sake to the 2TB NVMe drive in your example, my old homelab can hit 5 GB/s on five spindles that I bought in ~ 2011-12 and they're all old and cheap, not enterprise-grade gear.
> So no, I would not put the entirety of Wikipedia on just one server, that would be silly.
> I would put it on two.
> Okay, maybe three, for redundancy. Just in case.
Then you have issues of bandwidth by having so few connections, as well as the poor user experience of trying to visit a site that exists and is served in only three places (hopefully around the globe). It's also bad for reliability because if any one site loses its connection suddenly your 200GB/s traffic is pushed onto the other servers. If you want a sense for how reliability engineering works you should look at how Netflix does testing and why they've managed to withstand regional AWS outages despite being hosted on AWS[3].
Wikimedia lays out their system set up pretty well on their own page[4].
Could you technically host wikipedia on your own systems? Sure, lots of people do, go visit Reddit's r/datahoarders and I'm sure you can find more than a few who have their own local copies. Could you actually replace production wikipedia on the Internet with the setup you describe? No, you cannot.
I also suspect you haven't costed out the server setup you describe, as it seems incongruous to say that they spend too much while advocating replacing their entire server stack with cutting edge hardware (and will they need to do so annually in order to keep up?).
[1]: https://www.backblaze.com/blog/backblaze-hard-drive-stats-fo...
[2]: https://meta.wikimedia.org/wiki/Data_dumps/Dumps_sizes_and_g...
[3]: https://netflixtechblog.com/lessons-netflix-learned-from-the...
Who cares if Blackblaze -- a backup company -- uses hard drives? Of course they do! They're not hosting Wikipedia though. My point was by using current-generation COTS hardware, it is entirely possible to host a huge website on a single box. It is. It really is. This is not about what other people generally do. This is about what is possible!
You keep getting bogged down by the practicalities of real-world site management. For the sake of argument, if I were to engineer a serious solution for this problem, I would be looking at hardware more like what Cloudflare uses for their edge cache boxes. They did the legwork to find the sweet spot for price/performance. This is typically a single-socket server with a 48-core AMD EPYC processor and 100 Gbps Ethernet. This CPU model is much cheaper than the 64-core flagship, but has the same amount of cache. (They're made from the same 8-core chiplets, but with 2 cores fused of due to defects.)
In these servers I would use PCI-e quad port NVMe adapters, as you said. The capacity requirements aren't as high as you think either, because the content can be sharded. The 5.6 TB number is for english Wikipedia, not all of Wikipedia + Wikimedia as a whole! So those 4x 8 TB cards are more than sufficient. Heck, even 4x 2 TB is enough for a while. The trick here is to apply some sort of lightweight compression on the text. That 5.6 TB compresses down to just 100 GB! In practice, you could easily get better than 3:1 ratios even with a very fast compressor set to "light" compression.
Then I would distribute these servers around the globe, with about 3 per location. One for english, with the other two for all the other languages. Each server would have a local, read-only replica of the language-specific databases with asynchronous streaming from the master copy.
I'd distribute this to about 5 regional locations, and nominate one server per language as the "write master" where updates occur. So for each language you'd have 1x read/write and 4x read-only. These would be at different locations, so for example German wikipedia would have the read/write replica in Germany. English would be at some US east-coast location. Etc...
Then you'd need some boxes for nonproduction test, dev, etc...
All of the remote edge servers would be load balanced using a DNS-based method, with no local load balancers. The servers' 100 Gbps ports would be directly connected to the peering routers, the same way Cloudflare and the like does it. This would add up to 1.5 TBps of traffic that you really could physically serve (5 x 3 x 100 Gbps).
Overall, the entire platform could be handled by something like 20-25 servers. That's it.
Now, I tell a small lie: Wikipedia hosts only the text! WikiMedia has the pictures, which don't compress well and requie much more disk space. This is best served with technology similar to AWS S3, which can be replicated with open source software and some boxes packed with hard drives. But again, you're probably overestimating the capacity required, and underestimating how much you can pack into a server these days.
Just to reiterate: the above is predicated upon having an efficient codebase, and Wikipedia isn't currently efficient enough to make this possible. It would take a rewrite of the code to achieve this, and that would cost more than their current hardware, so it doesn't make financial sense. Most web sites are in a similar situation, which is perhaps why your perspective is skewed: Your expectations of software performance capability might be off by a few orders of magnitude!