7 ms·
Handling server load for the Raspberry Pi Zero launch
- cjfont 11y agoFor some reason I thought this was going to have something to do with the Raspberry Pi Zero.
- joosters 11y agoIt's about the people who are hosting the Pi website, and what they did to manage the burst of activity when the Pi Zero was announced.
- cjfont 11y agoRight, but the title strongly implies that the article is talking about executing PHP on the Pi.
- giancarlostoro 11y agoI had the same reaction, I was hoping to hear about a problem solved by the Pi Zero, maybe configuration tweaks or something for PHP, it sounded almost like it was going to give a performance tip as far as the Pi Zero is concerned.
- j_s 11y agoA great example of how a headline can tie barely related content into the latest trend / top-rated HN article to catch a few more page views / front-page votes... marketing!
- tacos 11y agoOne form of this article might be: "Here are some best practices for hosting a high-traffic WordPress site." 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.
- johansch 11y agoThe lenghts people go to in order to run Wordpress never ceases to amaze me.
- tyingq 11y agoReading the article they finally get down to what it is...98 lines of perl that serve as a url specific content cache. 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.
- mfjordvald 11y agoAPCu would not be enough at this level. Simply invoking PHP itself is enough to kill servers here. But yes, using nginx or vanish would have probably been easier and there's plenty of resources on it. In a case at my last job a single nginx instance handled 24k concurrent connections just fine.
- toast0 11y agoPHP can easily handle thousands of requests per second, as long as each request doesn't do much. Fetching from a shared memory cache counts as not doing much. You would need to do before you initialize WordPress though.
- tyingq 11y agoRight, the idea would be to put the logic at the top of the main php file for wordpress, something like: # 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 cache
- stefantalpalaru 11y agoWouldn't it be better to setup a caching reverse proxy like Varnish? I bet there are configuration examples out there to help you run it with Wordpress.
- gsteinb88 11y agoThis was exactly my reaction -- while nice that they could get a solution in a few lines of perl, quotes like > 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.
- jacquesm 11y agoVarnish would do just fine, ditto Nginx, or they could have used cloudflare or some other service. 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.
- gabemart 11y agoI've had 10k concurrent users on a bandwidth-intensive app served statically from 3 $5 digital ocean droplets using nginx. CPU usage and memory usage were not that high. I agree it's not a big deal.
- Udo 11y agoI want to criticize the choice of headline here, which was no doubt the point of having it. It's not about PHP. PHP runs fine on Pis. Not that I would ever advocate running a website with serious traffic on that device, but it could very well serve a 50-100 dynamic requests per second (I just tested this with my Pi B running NginX and my custom home automation software which is web-based, the baseline is 250 static small file requests per second, so not a great starting point for publicly hosting things). 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.
- programminggeek 11y agoBut I really like executing PHP code!
- pmlnr 11y agoThis is a crappy article about realizing the need of cache in front of dynamic websites. 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.
- walshemj 11y agoFortran still beats c though
- TazeTSchnitzel 11y agoEr, so they rolled their own custom caching system? Isn't caching one of the first recommended ways to improve the performance of, well, any mostly-static content site?
- pronoiac 11y agoThere are caching plugins for Wordpress, and you can configure Nginx to serve pages from the cache if no relevant cookies are set. So this feels a little like it's showing lack of knowledge about what's been done before.
- benn_88 11y agoI'm the sole developer and maintainer of raspberrypi.org - we're a small team at the Foundation and I do this alongside outreach, educational resources, teacher training, software development and other projects. We pay Mythic Beasts for a basic hosting service and they kindly provide us with a full support service in running the server and keeping the site and other services on the machine alive. That one machine runs various Raspberry Pi sub-sites, the Raspbian and NOOBS downloads server, the Raspbian apt mirror, MPEG licence key generation and more. 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-wordpress-if-youre-tired-of-tea-then-youre-tired-of-life/ 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.
- 11y ago
- acd 11y agoYou can run Php 7 and Nginx, that would be faster and stable. When running nginx should use the nginx proxy caching features together with Wordpress that is very very fast! Why not benchmark a raspberry pi cluster ?
- rasz_pl 11y agoI was one of the original raspberrypi.org trolls for a couple of months. RS Components scammed me with a "preorded" and kept moving delivery date for HALF A YEAR, while at the same time __already delivering__ to newer customers - they prioritised fresh customers over me, because they already had my money :/ Similar 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 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.