72 points · by benn_88 · 11y ago · 45 comments
1. Why PHP?
We all know PHP sucks (we advocate Python in education), but WordPress is ideal for authors and contributors and that's what we had to begin with.
2. Why WordPress?
When I joined the Foundation in 2013 they had a WordPress site Eben set up in 2011 and I wanted to keep the great user experience WordPress provides to authors and contributors so I built a bespoke theme expanding the content beyond the simple blog, keeping all former URLs working despite changes to the URL structure. Some of the newer content, like documentation and learning resources, is outside of WordPress and is pulled in from github and rendered into templates.
3. But why not build your own bespoke framework?
Firstly, if I did that, you'd tell me perfectly good web frameworks already exist. Secondly, WordPress is very mature and it's easy to add functionality quickly. I'm not talking about BS plugins - I hardly use any. I mean it's easy to add stuff into the templates, stuff you're likely to want to do. Finally, I'd rather spend my time and the Foundation's money doing educational projects.
4. WordPress caching plugins exist. Why don't you just use them?
We use WP Super Cache. It does most of what we want, but has some pretty fatal flaws: it doesn't go to cache for "logged in users" (including anyone who's ever made a comment), it recreates the cache after every comment, it does some work to figure out of it can give the user a cached page or not (this slows it down a lot), it doesn't cache the 404 page (more important than you'd think) and it doesn't cache requests with any GET methods params. Mythic created their own static page generating script for the pages with the most hits which updates every minute, and that's what kept us alive this time.
5. Why not use NGINX?
See a full article on this here: http://blog.mythic-beasts.com/2014/11/14/hiphop-and-wordpres...
6. What about hiphop vm?
We tried it. Fast but unreliable. We saw a huge rise in performance but most of that came from the upgrade from Wheezy's PHP 5.3. Compared to Jessie's PHP 5.6 was less impressive.
1. Concise code to express common constructs.
2. Easy for 3rd parties maintaining or extending software to understand what it does.
3. Easy for type system, tests, or static analysis to catch errors before they hit production.
4. CPU or memory efficient during runtime.
5. Higher uptime for interpreter and critical libraries.
6. Lower number of defects and vulnerabilities in both interpreter and common libraries.
7. Ease of writing portable code might matter to some in case they like shopping around for cheaper cloud vendors.
So, there's a start at a list with important metrics for missing-critical, long-term code in web apps. Got a link(s) showing PHP is equivalent to or better than competition in these?
If we're being honest every language has its weak points and things that are disliked even by its proponents. Efforts at improvement are more productively directed towards making things better on your own turf. Taking derivative and uninformed jabs at a language you already dislike and will never use is not a good way to spend your energy, nor is the energy of your opponents well spent in trying to overcome your biases.
It also gets hacked like there is no tomorrow, he he. What a joke! Seriously can you believe that that lolphp sub-reddit that I linked has been adding new entries steadily even after six years! Give me one language that can rival this feat!
Remember; Each one of those is a gotcha that can bite you when you least expect it. Forget everything. This alone should be enough to keep anyone miles away from this language.
Re 5: I found that nginx was way better at static resources, like images, CSS, and super-cached HTML. I imagine you use CDNs for the first two, but being able to selectively bypass Wordpress for the last is something nginx can do but I think Apache can't.
Edit: on re-reading, it's also a downloads server and apt mirror? I'd definitely use nginx, probably as a reverse proxy for Apache, because fewer configuration changes are needed that way.
Is that the official opinion of the Foundation?
Also Python isn't the only language we encourage. We ship Raspbian with Ruby, Java, Mathematica and more and have resources in many, including PHP.
Instead, this should be a critique of Wordpress, which is like almost any other successful software immensely bloated. There is nothing inherent in PHP promoting this verbosity. And even if you are dealing with large code bases, PHP's request-based execution model gives you good tools to just execute the codepaths you need. But in practice, little consideration goes into minimizing execution bloat and overhead. Of course there are reasons why WP is bloated, some of them bad, some good, some subject to debate. Caching and avoiding dynamic code execution will be a big part of optimizing any Wordpress install for the foreseeable future.
We're moving towards more bloat, not less. The best practices of many programming environments actively encourage us to disregard cycles and latencies. This happens in PHP, in Node, even in C++ frameworks.
Another form is "I saved the world from a trillion lines of PHP! And if we did this on AWS it would be many tens of thousands of dollars per month..."
Perhaps I should make sure I'm giving the author the benefit of the doubt:
"... you’d still need to make sure you can effortlessly scale to thousands of cores ..."
10k users peak. Thousands of cores? $30k+ a month? This is blatant misinformation.
A somewhat odd solution for a php driven website. Since you're in php already, a more typical solution would be to use apcu to have the cache in shared memory.
Or, if your needs are more complex, using an already established cache like the one in nginx or varnish, etc.
Whatever they did served their needs, but I'm not clear on why "we made a one-off url+param keyed cache" rates an article.
# oversimplified, but...
$key=md5(http_build_query($_GET));
$content=apc_fetch($key,$success);
if ($success === TRUE) {
echo $content;
return ;# never invoke wordpress
}
# wordpress here
# some logic at the bottom to store what wordpress
# just rendered into the cacheSimilar thing happened again with Zero, all big fat distributors (this includes Adafruit) engaged in scamming early customers by bundling $5 product with $2 of cables and upselling whole thing as a $20-60 pack(!!). They went as far as removing $5 product listing altogether. http://www.adafruit.com/pizero had $5 listed for maybe few hours, then they deleted it. They still list other out of stock products there.
To this day Pee foundation acts shocked, SHOCKED I TELL YOU every time someone complaints about official distributors being scammy. Whole thing would go a lot smoother (from the client perspective) if they didnt shield predatory marketing tactics of those resellers. Today I understand it wasnt rPi fault, but Im sure other people dont, and acting as a PR for element14 will never work if you promise X and element14 silently delivers X+super cheap piece of crap at 4x the price (before taxes) behind your back.
Wow.
PHP haters: yes, PHP is crap, and we should all code in C, because nothing beats C in speed. ( Except for Perl in regex land. )
WordPress hater: the WP core itself is not that bad. The themes and the plugins, those are the real monsters.
Article owner & WordPress users: there are pretty good cache plugins already for WP, you needn't have to write another.
Isn't caching one of the first recommended ways to improve the performance of, well, any mostly-static content site?
Why not benchmark a raspberry pi cluster ?
The funny thing for me is that they make it seem as if 10K concurrent users is a 'big deal' for a bunch of static pages. If you're not interacting in real time a little bit of caching or page generation will go a long way towards being able to serve up a huge number of viewers / participants.
> During the day we improved and deployed this same code to the MagPi site including some horrid hackery to cache popular GET request combinations.
make me think they would have been much better served using a pre-existing solution (probably Varnish) that's built to do exactly this. This article reads like a major case of reinventing the wheel.