News for hackers. Stuff that matters.
Re:How we made editing Wikipedia twice as fast by bhauer on Tuesday December 30, 2014 @02:42PM (#8816297)
Great write up. This will be a good point of reference for future debates concerning the value of selecting high-performance platforms for web-applications. A common refrain among advocates of slower platforms is that computational performance does not matter because applications are invariably busy waiting on external systems such as databases. While that may be true in some cases, database query performance is often only a small piece of an overall performance puzzle. Blaming external systems is a too-convenient umbrella to avoid profiling an application to discover where it's actually spending time. What to do once you've made external systems fast and your application is still squandering a hundred milliseconds in the database driver or ORM, fifty milliseconds in a low-performance request router, and another 250 milliseconds in a slow templater or JSON serializer?

Yes, three seconds for a page render is still uncomfortably slow, but it's substantially faster than the original implementation, and unsurprisingly frees up CPU for additional concurrent requests. It's a shame Wikimedia didn't have this platform available to them earlier.

Today web developers have many high-performance platform options that offer moderate to good developer efficiency. Those who use low-performance platforms may do their future selves a service by evaluating (comfortable) alternatives when embarking on new projects.

Re:How we made editing Wikipedia twice as fast by balls187 on Tuesday December 30, 2014 @04:20PM (#8816801)
> This will be a good point of reference for future debates concerning the value of selecting high-performance platforms for web-applications.

Keep in mind, Wikipedia is at scale that most web applications will never, ever get to.

It's important to think about performance and scale, but it's not the only important trade off engineers should concern themselves with.

Re:How we made editing Wikipedia twice as fast by kmavm on Tuesday December 30, 2014 @05:14PM (#8817049)
The win here wasn't about scale, though. A tiny fraction of wikipedia users are logged in.

The win here was about individual page load time. And page load time is just as important, if not more so, for something new trying to vigorously grow as it is for the big sites.

(Disclaimer: HHVM alum.)

Re:How we made editing Wikipedia twice as fast by sbov on Tuesday December 30, 2014 @09:16PM (#8817976)
Yeah, this. We helped my boss' brother out with his wordpress ecommerce site.

His machine could easily handle the traffic thrown at it, but the page load time was slow. 2 seconds at best, with all machines involved being almost 100% idle. With various common tweaks such as caching, we got it down to about 800ms. We eventually replaced it with our own solution and got it to 50ms.

Scale never entered the picture because from our testing, we had the machinery in place to handle enough traffic to be wildly profitable. The user experience at 2 second page load times was vastly different from the user experience at 50ms though.

Re:How we made editing Wikipedia twice as fast by lonnyk on Wednesday December 31, 2014 @01:11AM (#8818418)
Could you describe what your own solution was?
Re:How we made editing Wikipedia twice as fast by sbov on Wednesday December 31, 2014 @04:37PM (#8821213)
It wasn't anything special. We used Java because it's what we knew, with a mix of spring and some home grown framework stuff that we've developed over the last 10 years.

MySQL over Postgres because that's what we had experience with at the time. Redis as both a cache and ephemeral store.

Re:How we made editing Wikipedia twice as fast by _joe on Tuesday December 30, 2014 @05:41PM (#8817151)
The win is _also_ about scale. The server CPU usage went down significantly - see http://bit.ly/1vqp1ki

So, more request can be served with a smaller number of servers.

Re:How we made editing Wikipedia twice as fast by schrodinger on Tuesday December 30, 2014 @09:13PM (#8817967)
Just curious, why did you use bit.ly there?
Re:How we made editing Wikipedia twice as fast by forgotpasswd3x on Tuesday December 30, 2014 @10:14PM (#8818099)
Re:How we made editing Wikipedia twice as fast by _joe on Wednesday December 31, 2014 @03:05AM (#8818586)
... just because I have that saved to use on IRC or anywhere else (like twitter) where a very long url would be inconvenient.

(I should've put a disclaimer there: I am one of the WMF engineers involved in the project).

Re:How we made editing Wikipedia twice as fast by metaprinter on Wednesday December 31, 2014 @04:07AM (#8818672)
Fyi, if you add a + to the end of any bitly URL, you'll see stats about the link. (Logged in users can set it to private but most times they don't)
Re:How we made editing Wikipedia twice as fast by bad_user on Tuesday December 30, 2014 @05:07PM (#8817016)
On the other hand I find that the problems where performance is relevant are the problems that are technically interesting and rewarding to solve.

It's also not necessarily about scale, as in number of users that one needs to serve. There are lots and lots of problems where performance is very relevant, from startups that can't afford to scale horizontally, to projects in an industrial setting that have to be rock solid, to participating in real-time bidding on RTB platforms, to games in which frames being dropped are a disaster, to the platforms on top of which we build stuff.

Quite the contrary, I believe that too many software developers are focusing on building front-ends to a database, but this isn't necessarily because these problems are solving real needs.

Re:How we made editing Wikipedia twice as fast by arenaninja on Tuesday December 30, 2014 @07:33PM (#8817663)
> Keep in mind, Wikipedia is at scale that most web applications will never, ever get to.

As I read the article I thought exactly this. Scaling is a nice problem to have. I keep playing around with Nginx, elasticsearch, and other tech that's supposed to help PHP's performance problem, but from personal experience, missing database indexes for complex joins have been the issue every time. I'm unlikely to get to use the tech I play with unless I switch jobs.

But back to the point, this is a great writeup, and I think a big step forward for both PHP and HHVM

Re:How we made editing Wikipedia twice as fast by davidgerard on Thursday January 01, 2015 @09:41AM (#8823028)
The win here is because the thing it speeds up is hugely CPU-bound.

This will also make tiny MediaWiki installs just as much faster.

Re:How we made editing Wikipedia twice as fast by TazeTSchnitzel on Tuesday December 30, 2014 @06:59PM (#8817517)
Wikipedia faces unique challenges, however, that many web applications do not face. Almost the entirety of the page rendered is user-generated content produced from hand-written wiki markup that must be parsed and rendered, and that uses complex nested templates. MediaWiki is basically a turing-complete applications platform. The wikipedia page for Barack Obama transcludes 199[0] unique templates, with 585 total non-unique invocations, and that's not counting the templates transcluded by those templates. Some of Wikipedia's templates are so complex that they had to be rewritten in Lua.

I don't think Wikipedia is really a typical case. Most websites probably don't have the CPU burden Wikipedia faces.

[0]https://en.wikipedia.org/w/index.php?title=Barack_Obama&acti...

Re:How we made editing Wikipedia twice as fast by eru on Tuesday December 30, 2014 @08:41PM (#8817886)
> MediaWiki is basically a turing-complete applications platform.

Perhaps MediaWiki should figure out how to use a weaker form of computation?

Re:How we made editing Wikipedia twice as fast by TazeTSchnitzel on Wednesday December 31, 2014 @06:56AM (#8819017)
Oh, the turing-completeness is new, it wasn't in the past. Using Lua was to improve template performance.
Re:How we made editing Wikipedia twice as fast by davidgerard on Thursday January 01, 2015 @09:43AM (#8823034)
Actually, it's been around for years - it was accidental. ParserFunctions is a good example of a DSL accidentally achieving Turing-completeness, at which point people start doing awful, awful things in it because they can. So they went to Lua because a proper programming language is superior in every way to an accidental one.
Re:How we made editing Wikipedia twice as fast by eru on Thursday January 01, 2015 @07:38PM (#8824964)
You actually have to be really careful to design a language that's both useful and not Turing-complete. Regular expressions are one example of such a language, but they are not strong enough for templating.
Re:How we made editing Wikipedia twice as fast by davidgerard on Thursday January 01, 2015 @08:42PM (#8825140)
Yeah. It wasn't actually intended to be Turing-complete, but then some excessively creative goddamn lunatic came up with a way to beat MediaWiki syntax with ParserFunctions into yielding a truly hideously inefficient "if" statement. Soooo they gave up and codified that so the CPUs wouldn't melt.
Re:How we made editing Wikipedia twice as fast by ttflee on Tuesday December 30, 2014 @10:38PM (#8818157)
I am afraid that the way those mark-ups have been used is the way they have encouraged.
Re:How we made editing Wikipedia twice as fast by Apofis on Tuesday December 30, 2014 @06:35PM (#8817381)
For our rather heavy Magento installation, we went from up to 6 sec loading times to about 600ms with HHVM without any fancy full page caching solutions. Thankfully Facebook decided to do something about it. It saved us.
Re:How we made editing Wikipedia twice as fast by davidgerard on Thursday January 01, 2015 @09:44AM (#8823038)
Which version of Magento? This is something I'm suspecting we could really do with. (We're running 1.14 Enterprise.)
Re:How we made editing Wikipedia twice as fast by TazeTSchnitzel on Wednesday December 31, 2014 @07:00AM (#8819035)
Six seconds? What were you doing that was so time-consuming?
Re:How we made editing Wikipedia twice as fast by ademarre on Tuesday December 30, 2014 @06:59PM (#8817516)
Is the Magento codebase fully compatible with HHVM?
Re:How we made editing Wikipedia twice as fast by jazzdan on Tuesday December 30, 2014 @08:16PM (#8817809)
The HHVM team runs the tests of popular GitHub PHP repositories on HHVM, it's available here: http://hhvm.com/frameworks/

According to that 99% of magento2 tests are passing.

Re:How we made editing Wikipedia twice as fast by tracker1 on Tuesday December 30, 2014 @03:52PM (#8816677)
I've been very happy with node as a platform for 3+ years now... Though it tends to take the mindset of designing to scale instead of as a monolith... breaking workers up from services, and spreading the data out.

I'd be more interested to see what, if any changes they have made to their other server components. Are they using NGINX vs Apache? What kinds of caching systems are they using? What is their database layout? Is their data sharded? These kinds of things I think are much more interesting, and at their scale at least as impactful.

Re:How we made editing Wikipedia twice as fast by kachnuv_ocasek on Tuesday December 30, 2014 @05:24PM (#8817081)
There are some bits and pieces on https://wikitech.wikimedia.org/wiki/Main_Page
Re:How we made editing Wikipedia twice as fast by tracker1 on Tuesday December 30, 2014 @05:34PM (#8817120)
Thanks for sharing... I'm kind of surprised they are using MariaDB over something like Cassandra.
Re:How we made editing Wikipedia twice as fast by gwicke on Wednesday December 31, 2014 @12:55AM (#8818401)
We are actually working on a storage service called RESTBase (https://www.mediawiki.org/wiki/RESTBase). RESTBase has pluggable table storage backends, starting with Cassandra. Other backends will scale this down for small installations.

The medium-term goal is to store all revisions as HTML, so that views and HTML-based saves can become storage-bound operations with low double-digit ms latencies. This will mostly eliminate the remaining 2-4% of cache misses, and should get us closer to actual DC fail-over without completely cold caches.

There is still a large amount of work to be done until all the puzzle pieces for this are in place, but we are hard at work to make it a reality. A major one, the bidirectional conversion between wikitext and HTML in Parsoid (https://www.mediawiki.org/wiki/Parsoid), is already powering VisualEditor and a bunch of other projects (https://www.mediawiki.org/wiki/Parsoid/Users). Watch this space ;)

Re:How we made editing Wikipedia twice as fast by tracker1 on Monday January 05, 2015 @07:23PM (#8842201)
Thanks for letting me know... I had some exposure to C* while at GoDaddy, and it would seem to be a great fit for what you are talking about...

GD is using it to store user-generated content, and it works very well, most responses (lookup and processing) were sub 20ms consistently under heavy load... (I'm hoping they write a DNS service that does similar).

Re:How we made editing Wikipedia twice as fast by duskwuff on Tuesday December 30, 2014 @06:18PM (#8817315)
They started with MySQL. Replacing that with MariaDB is a whole lot simpler (not to mention, less risky!) than replacing it with something completely different like Cassandra.
Re:How we made editing Wikipedia twice as fast by rimantas on Wednesday December 31, 2014 @07:03AM (#8819043)
They started with PostgreSQL iirc, only later migrated to MySQL.
Re:How we made editing Wikipedia twice as fast by samspenc on Tuesday December 30, 2014 @06:23PM (#8817336)
MariaDB is MySQL compatible. Had they gone with Cassandra, they would have had to replace the PHP-based MediaWiki software with something else. So not only the database, the entire software stack would have to be replaced as well.

Also, speaking from a few years' personal experience with HBase / Cassandra, the support for non-Java languages on these two NoSQL databases is small (though it is getting better.)

Re:How we made editing Wikipedia twice as fast by tracker1 on Monday January 05, 2015 @07:27PM (#8842223)
I worked on a project that used C* with node.js and it worked out very well... cluster of node servers, with minimal processing over a cluster of C* servers... very fast response times under some really big load.

Though node.js tends to be very flexible in terms of wrapping a friendlier interface around a less friendly one.

Re:How we made editing Wikipedia twice as fast by driverdan on Tuesday December 30, 2014 @07:46PM (#8817709)
Why? The vast majority of the requests they serve are cached at multiple layers above the DB. Switching to an entirely different DB would require rewriting a lot of code, a much larger learning curve to contribute (MediaWiki is FOSS), and limit its use to large sites (MediaWiki is widely used by small sites).
Re:How we made editing Wikipedia twice as fast by tracker1 on Monday January 05, 2015 @07:28PM (#8842229)
I'm not familiar enough with their data structure to comment, but the concern would seem to be around write performance... if they have to use sharding in an rdbms like my/mariadb, then it's not too much harder to change databases at that point.. not to mention improvements with distributed reads on a cache miss..
Re:How we made editing Wikipedia twice as fast by gpvos on Wednesday December 31, 2014 @06:23AM (#8818958)
NoSQL databases were still in their infancy when Wikipedia was originally developed.
Re:How we made editing Wikipedia twice as fast by tracker1 on Monday January 05, 2015 @07:29PM (#8842234)
I understand that... but would have assumed they would have changed over time. Plenty of platforms have migrated backends to handle much larger load (twitter, facebook, etc, etc).
Re:How we made editing Wikipedia twice as fast by gpvos on Sunday January 11, 2015 @11:44AM (#8870386)
Wikimedia's resources are over two orders of magnitude smaller than those of the other top-10 web sites. It is only fairly recently that they have more than a handful paid developers. And they have a huge amount of data they would have to convert. In fact, I think they would have been up to it, but there simply were more pressing concerns.
Re:How we made editing Wikipedia twice as fast by jonesnc on Tuesday December 30, 2014 @04:46PM (#8816914)
I would also like to hear more about their infrastructure.

I do know they use Varnish as their cache server.

https://wikitech.wikimedia.org/wiki/Varnish