17 ms·
PHP 7 deployment at Dailymotion
- smegel 10y agoKind of ironic this wasn't a video post.
- agumonkey 10y agoAt least it's not hosted on youtube.
- verelo 10y agoWe did the same thing with HHVM, and had VERY similar results; getting it to work was plain hard, and i had a lot of concerns about our ability to ever go back. Before we ever launched with HHVM completely, PHP7 came out. With only a few weeks of work, we managed to make the switch. The gains were identical to what we saw on HHVM, only the experience of working with PHP7 was so much easier for everyone involved. Having said all this, I think HHVM served a great purpose: It raised the bar and PHP is better because of that. All in all, a great outcome for the people of the Internet.
- nkozyra 10y agoHack's influence is all over PHP7, unsurprisingly. As someone still bound to PHP due to technical debt, I'm thrilled this happened. PHP still has warts, but changes in 7 are tantamount to ES5 :: ES6. The language feels more mature, real, sensical.
- kyriakos 10y agoA much needed overhaul to the utility functions (array, strings etc) should be the next step.
- nkozyra 10y agoOf course, but they won't do that because of backwards compatibility and I get that. It's one of the nice parts of rebranding. Hack could keep and throw out anything they wanted because it was intended for private FB use. At some point, PHP will have to start cutting off the stdlib PHP4.x warts. There's enough about PHP 7 that's good enough to be compelling to anyone working in an interpreted language on the web, but the (well earned) reputation keeps a lot of people away.
- nchelluri 10y ago> It took less than a week to migrate our codebase (a 10 years old PHP monolith)... > And it took 4 hours to migrate our custom extensions. That seems like a very small amount of work; I'm impressed at how smooth a transition that must've been. I'm also quite surprised that > we can handle twice more traffic with same infrastructure. Wow, I didn't think that PHP application code would be such a bottleneck. Maybe it's not that, but if the entire codebase is written in PHP, and you replace it all in one shot, you just get such an improvement. But I thought DBs, etc. would play a bigger role.
- skippyta 10y agoIn the world of PHP 7, blocking I/O will still be a problem (at least, it was when I looked at the proposed feature set over a year and a half ago), but in PHP 5.x, the Zend engine is actually just incredibly inefficient, to the point where it is often the largest bottleneck on the request path.
- geerlingguy 10y agoFor a lot of array-heavy applications (where you store all kinds of data in giant multi-level PHP arrays), the memory usage alone counts for most of the speedup; instead of wading through tens or hundreds of MB of array structures, PHP 7 trimmed things down by a factor of 2 or more. There are a lot of PHP apps/CMSes/etc that gained 30-50% speedups due to just that improvement. Other more optimized apps/scripts saw a much more modest gain.
- mgkimsal 10y agoIIRC, a PHP array entry had 127 bytes of overhead. PHP 7, that went down to 42(?). Also, IIRC, for JVM, it's .. 37? 40? PHP7 got array overhead down a lot, and I do believe that's where a lot of speed improvement came from (though certainly not all of it).
- ucho 10y agoPHP array is equivalent to LinkedHashMap and yes, it has 40 bytes overhead per entry in Java.
- qaq 10y agoWow today is PHP day on HN :)
- toxican 10y agoAt least this one isn't ripping it to shreds (so far). The other discussion...that was rough to read as a PHP dev.
- wyager 10y agoDon't take attacks on your usual tool of choice as an attack on yourself. If you think people are making good arguments against PHP, perhaps consider retooling a bit...
- toxican 10y agoHard to separate yourself from your decisions and your toolset sometimes! I certainly may check out some alternatives at a hobby level and pursue them further if they appeal to me. But for now the money in my rural city is in PHP and to a lesser extend, .NET. Don't think I've ever seen a job asking for Python, Node, etc. that didn't require an hour + commute.
- meritt 10y agoIf you're (or anyone else) interested, my company is hiring senior PHP engineers. Modern tech stack: PHP7, MariaDB (MySQL), Redis, distributed workers, Debian, AWS, Solr, data mining/analysis. Competitive salaries, fully remote, vacation, retirement, etc. Contact me at meritt.hn@gmail.com
- jonaswouters 10y agoIf you jump on a new language early enough and are proficient enough to be productive in it, you have a chance to actually land some jobs with it without having to take a pay cut. Letting people know and engaging in the community is a requirement though. You'll meet other people passionate about it and ultimately network is everything ;) Then again I end up with php jobs anyway because I enjoy sharing my knowledge (coaching, improving way of working, etc) but at the same time surround myself with people who I can learn from. (Be it business, architecture or a different language, all relative knowledge is valuable)
- maxpert 10y agoI used to run one of my site (25K unique visitors a day) on PHP 5.3, when HHVM came out with stable version I shifted to HHVM and I had similar experience. Now I am running it on PHP 7 and I have to say I am more than happy with results. As much as PHP is not cool for today's developers it has served on some really high traffic sites and stayed useful even with the test of time. P.S. Now I wish somebody just implements a good Async IO system and ability to run HTTP right off the PHP engine (I know there is php -S ...; I am talking about a better async system).
- girvo 10y agohttps://icicle.io https://icicle.io We're currently building a pretty large production system in it. It's got a few warts, but it's damned nice, and it's compatibility with ReactPHP (event-loop, not the front-end tool!) is super useful!
- nchelluri 10y agoCan you explain the draw of Async I/O? A single request will not be faster, but you may get more concurrent requests going due to running some while some are waiting for I/O to finish? Is that correct?
- spronkey 10y agoWhen you start talking about multiple concurrent connections, and considering performance of an application as a whole, Async I/O at the application level offers basically no speed benefits over any kind of Sync I/O runtime that can run in parallel. What an Async I/O model can do is allow the amount of resources consumed by parallel execution contexts to be reduced - therefore allowing you to service more concurrent requests in parallel. But not necessarily any faster, if I/O is your bottleneck in the first place. It can also be used to give more predictable performance under loads with i.e. response times, if the responses are not dependent on I/O operations to complete.
- pmilot 10y agoYou may be looking for React PHP (http://reactphp.org http://reactphp.org). No relation to the JS library. It is an asynchronous event loop implementation, and there is a native HTTP stack built on top of it.
- jsamuel 10y agoAt ServerPilot, we decided early on not to support HHVM for similar reasons: we could see PHP 7 was going to offer the same performance benefits without the pain, breakage, and downtime of HHVM. Early on, before PHP 7 was released, we had to explain this to many of our users who use ServerPilot to host WordPress, Magento, Laravel, and other PHP apps. They often thought there was no downside or risk with HHVM, it was as simple as dropping it in as a replacement. Nowadays, with the hype around HHVM dying down, we don't get requests for HHVM support much anymore. For a huge company like Facebook, HHVM makes a lot of sense. And the existence of HHVM really sped up the PHP 7 development efforts and provided a great benchmark for how fast PHP 7 could be. So, the PHP community should be very grateful to Facebook for that even if HHVM isn't the future of PHP.
- nikcub 10y agoHack and HHVM solves what is, IMO, the worst feature of the default PHP runtime environment[0] - and that is the superglobals. It wasn't mentioned in the post from Slack, but default superglobals and the earlier register_globals design decisions are the worst and most impactful wart in PHP. Because it was designed as a templating language, the default web server interface, which is CGI - will auto-expose all variables in global scope, ex. echo $_POST['user_id'] PHP has a horrible reputation with security for this reason - we all know that somehow, somewhere, in almost every project someone is pulling in a user-controlled variable from a superglobal and they aren't escaping or checking it properly (since you can't be warned about it but the feature will work). Worse - and i've seen this a lot, even with Laravel, CodeIgniter, Cake, Symfony/Silex etc. you end up with these well structured projects that declare request classes, methods and variables etc. etc. but then sometime down the road a developer takes a shortcut in a method and pulls in a $_GET or $_POST inside a controller (usually because they don't know how, or aren't bothered to - changing all the related classes) - running around the default exec stack. I've seen this so often - because it's so easy to do it. The most common place is where a designer has built a frontend AJAX form. They now need to build a quick backend check, so they Google "php backend ajax username check" and they'll likely get a result like this one: http://stackoverflow.com/questions/29459183/check-username-availability-using-ajax http://stackoverflow.com/questions/29459183/check-username-a... where the 4th and 5th lines to the solution are: $username=$_POST['username']; $query="SELECT * FROM username_list WHERE username='$username' "; they copy that into a file called ajax_username_check.php and save it to the server - and they've now destroyed all that previous good work by opening up a very blatant and easy to find SQLi vulnerability. Their database will be on pastebin within a month. You can spot this type of vulnerability from the frontend because the URLs used in the AJAX calls don't match the URL router patterns for the rest of the app (ex. GET /user/username_check_ajax.php vs /user/check_user). In other languages you can't get that without using a standard library that will escape the values by default. Any solution you search for will always be a safe method to obtain the variable values by default. Some good news: Hack doesn't expose superglobals in strict mode: http://cookbook.hacklang.org/recipes/get-and-post/ http://cookbook.hacklang.org/recipes/get-and-post/ I'd strongly recommend that this is used in all PHP projects, since it strictly enforces variable access - even in cases where you're using a framework that is supposed to enforce it. IMO PHP missed a big opportunity with not removing superglobals in version 7 and enforcing an explicit safe request object much like other languages do. They likely wanted to avoid it because of the cluster of register_globals and magic_quotes from earlier versions. [0] I think it is important to distinguish PHP the language and PHP the runtime. PHP the language is now decent - having caught up with a lot of features (although I find it very verbose and harder to read) while PHP the runtime is undoubtably still a horrible runtime - hence HHVM
- martin_ 10y agoHad a similar experience deploying HHVM at a previous company, I wrote up a blog post of the issues we ran into / how we worked around them[0]. One thing the dailymotion blog omits is hacklang which has additional features like lambdas, async support (though PHP 7 will soon?), strict typing, collections, generics and more. That said, if you're just trying to squeeze more out of an existing codebase, then PHP7 wins hands down. [0] https://ma.rtin.so/when-hhvm-doesnt-work-quite-right https://ma.rtin.so/when-hhvm-doesnt-work-quite-right
- nodesocket 10y agoWhat tool are they using to show the memory footprint of php processs in https://cdn-images-1.medium.com/max/800/1*bFnYX8NE-V6P2U01Uc3W1A.png https://cdn-images-1.medium.com/max/800/1*bFnYX8NE-V6P2U01Uc....
- vbernat 10y agoIt's Pinba. http://pinba.org/ http://pinba.org/
- tedmiston 10y ago> During few months, this project wasn’t the priority, so we decided to wait the release of PHP 7 to compare performances. I have no idea why the author is choosing to write in such a strange grammatical style.
- skrebbel 10y agoIf you have no idea, why bring it up?
- tedmiston 10y agoOften times other people here do have a different perspective. I also found it very distracting from reading the post.
- Moru 10y agoThis view is pretty common for people reading their first language written by someone using their second or third language. This comes people that just isn't as good at writing and expressing themselves. This does by no means make their thoughts less valuable. Sometimes you just have to open your mind to other people even though the words come out in the wrong order. English is not my first language either but I don't write "I'm sorry for my mistakes, english is not my first language" because that should be pretty obvious. And if it's not obvious, there is no need to say it, right?
- noir_lord 10y agoI just think I'm fortunate that my first language became the de-facto language for technology and that anyone who speaks/writes it well enough to be comprehensible about technical matters in a 2nd language deserves my respect!. My GF finds that I know multiple programming languages impressive while not realising that her ability to speak English, Hungarian and German fluently leaves me in awe.
- noir_lord 10y ago> I also found it very distracting from reading the post. 'from' should be 'while' Annoying is it not? Never assume a posters first language is English and as long as the meaning is clear I don't think it matters.
- kijin 10y ago> In other languages you can't get that without using a standard library that will escape the values by default. Escape for what context? Escaping for SQL is different from escaping for HTML, which in turn is different from escaping for JS. How does your hypothetical Request object know how to escape any given variable? Does it ping every open database handle to figure out how they want their data escaped? Does it use some kind of static analysis to figure out in what format (HTML? XML? JSON? CSV?) the app is going to spit out the value later on? Or does it simply run a bunch of cargo-cult functions like return htmlspecialchars(strip_tags(mysql_real_escape_string(addslashes($_POST['var'])))); and hope that everything will be okay?
- porker 10y agoIt's a shame that HHVM has so many compatibility issues compared to PHP7, as I would love to be able to use Hack.
- LinuxFreedom 10y ago“how to scale without investing too much in people/servers” This exactly is the antisocial and greedy attitude that we have to actively fight if we want peace, freedom and prosperity for all people. Please cancel all your dailymotion accounts and let these disgusting people disappear forever.
- Noony 10y agoHey, I'm the author of this blog post, I'll try to respond to your comment : This is not an antisocial and greedy attitude, every society have this problem. Dailymotion invests a lot in teams, and servers. But sometimes you have to think differently, "is there something to do before I buy new servers / rewrite all our application ?", to let more time for co-worker to implement a new architecture.
- tofupup 10y agoneat