10 ms·
Experimenting with HHVM at Etsy
- yc1010 11y agoI would love to move onto HHVM and since mostly run own PHP code 3rd party code compatibility is not a problem, BUT unfortunately the editor I use (PHP Storm) doesn't yet support HHVM :( what editors do people that are using HHVM use?
- tunesmith 11y agobespoke endpoints sound like a good compromise, but I wonder why they stick with php for the general apis that the bespoke endpoints consume? Wouldn't they get better scalability if they moved that backend logic to something like Play, which would give you NIO on a jvm? EDIT: Removed mention of "shared-nothing", which I misunderstood.
- datashovel 11y agoIsn't shared nothing a scalable architecture? http://en.wikipedia.org/wiki/Shared_nothing_architecture http://en.wikipedia.org/wiki/Shared_nothing_architecture
- tunesmith 11y agoOk, I hadn't seen that phrase to describe that kind of architecture before, thanks. Still though, it seemed they were describing each node's "build-the-world" process as onerous. Is HHVM thread-per-request?
- Sanddancer 11y agoYes. It's why they had problems with certain non-thread safe routines like locale.
- cdnsteve 11y agoI was also curious about this. If the main traffic interface is bespoke, I'm sure Esty would investigate other solutions. It would make the most sense to also experiment with Bespoke since it's just an interface that talks to other APIs, likely without any business logic and a huge codebase. It orchestrates other APIs into 'views' for the consumer so you have one consolidated endpoint. I'd personally be curious if they experimented with Go lang for this. Low memory, fast startup, fast at run. It makes more sense to use another language for bespoke than anywhere else in their stack, at least from my limited external viewpoint that is :)
- Xorlev 11y agoIt does mean that every tool they've written to work with their stack now needs to have a Go equivalent. For some things, that'll be easy. It also means they now need people who know Go, which means any of their engineers can't just work on the code without learning. It also means deployment will be different. While the technology might make more sense, there's often enough reasons to not use it if you've specialized into a certain ecosystem.
- ck2 11y agoThe good news about hhvm is that with the newest builds from the past few months you can finally run it longer than a week without memory leaks and crashing under high loads. If you look at the changelog, you can see it really is a beta product that people use in production anyway https://raw.githubusercontent.com/facebook/hhvm/master/NEWS https://raw.githubusercontent.com/facebook/hhvm/master/NEWS "Ditko" 26-Feb-2015 finally solved me having to restart it every several days I'm very eager to compare PHP7 in production
- hootener 11y agoThis is what caused me to abandon HHVM for plain ol' PHP around a year ago. I was running it in Docker containers and the memory leaks would regularly crash my containers if left unattended for more than a couple of days. It was quite frustrating because I noticed some definite performance gains (e.g., ~2x faster page loads, etc.), but ultimately opted for PHP's stability. The benefit to running all this in Docker is that I can swap HHVM back in relatively easily (unless it's changed really dramatically over the past 10 months or so). Your comment has me tempted to give it another shot!
- ck2 11y agoUpdate: we had an hhvm install today that crashed after 15 days or so. Apparently this still happens but instead of several times per month, it is now a couple times per month. Sigh, well PHP7 is right around the corner.
- datashovel 11y agoThis is a great write up. I have been skeptical of converting to HHVM for a while because of a bad experience I had several years ago. I've been following the HHVM project off and on for a while now, but it really sounds like it may be ready for some smaller projects who don't have the resources of an Etsy to try it out.
- steakejjs 11y agoThe new stuff happening in the PHP space is really really awesome. HHVM + HACK + XHP is an entirely different experience compared to writing PHP. Code can actually be very clean and lots of bugs can be found that may have previously gone unnoticed + performance benefits. Just wanted to say FB is doing an exceptional job with these projects.
- caipre 11y agoShameless self promotion: I wrote hussar[0], a tool that uses HHVM for PHP static analysis in projects that can't run HHVM directly. Etsy says "getting [their] code to run on HHVM was relatively easy", but my experience has been the opposite. Previous discussion on HN here: https://news.ycombinator.com/item?id=9071854 https://news.ycombinator.com/item?id=9071854 [0]: https://github.com/wayfair/hussar https://github.com/wayfair/hussar
- farresito 11y agoAnd later this year, PHP 7 is coming, which should bring huge performance improvements.
- madaxe_again 11y agoBeyond HHVM, in fact, has oob compiler. We've opted to hold off until 7 is out - HHVM extension support is still patchy.
- dingdingdang 11y agoPlus the whole "warm-up" procedure just seems immensely patchy to me - hopefully no such thing will be needed in PHP7.
- jszymborski 11y agoI guess the question I've been having is that if I want to begin a new project with performance as a main priority, should I use HHVM+PHP or HHVM+Hack over something like Java or Go, or is it more for making existing PHP codebases more performant.
- cyri 11y agoGo or Java is still faster than HHVM/PHP7. I'm writing my new project (Magento Go (wordplay) ;-) ) in GoLang.
- navs 11y agoI work with Magento a lot lately. Very interested in hearing about this!
- MAGZine 11y agoDepends on what you're building, honestly. I think that it's easy enough to get a site running entirely on PHP--well tested, well supported, architecturally sound, and rewrite services into <noninterpreted-language-of-choice> as you hit performance bottlenecks. If performance is absolutely critical to your app, then you may consider writing everything in Java/Go/C++, but it's pretty brutal for doing templating and whatnot. Besides, once you generate the page, there's a good chance you're going to cache a good part of it anyhow!
- sauere 11y agoIMHO: HHVM/Hacklang are cool and i appreciate Facebooks contributions to building a better PHP enviroment... but at the end of the day, it feels like someone trying to put a V12 engine in a golf cart. It's cool if you are already driving a golf cart, otherwise it's weird. So if you have the chance to start fresh: choose Java or Go. Or anything else... (define "performance"?)
- fennecfoxen 11y agoI'm a little surprised that HHVM would make or break anyone's decision to use PHP, since I'd think that there are more important language design concerns and features that ought to figure before it came down to that... at least in a PHP-vs-Java sort of fight, anyway. Big questions like your preferred form of typing (strong/weak, dynamic/static/Hindley-Miller inference, etc), threading, ease of writing list comprehensions, whether you need to have functions as first-class objects, et cetera et cetera. Or the ability to hire developers who use that language.
- icelancer 11y agoThis is great. After being one of the early contributors to documentation and clearing up the (admittedly ridiculous) on-ramping guides for what was then HipHopPHP, I'm really happy to see it get more traction. I deploy it in production for a webapp that is more or less simple CRUD on the outside but does some relatively expensive scheduled batch processing of number crunching. The differences are huge and allow me to keep it to a single - albeit big - dedicated machine. It's come a long way and I'm excited to see further improvements.
- revelation 11y agoCalling setlocale because the user you're currently processing has a different locale? What the..? Notice: what works in UNIX utilities is not what works for web apps serving many users simultaneously. In fact, I'm pretty sure this doesn't work for UNIX utilities either and is just something you should never touch with your libc. It's like calling non-reentrant strtok, some of this stuff just doesn't exactly fit into todays world.
- josegonzalez 11y agoIt ends up changing the output of icu-based libraries, localizing stuff like number formatting. Otherwise you're re-implementing that in userland code, which is likely to be much slower.
- zerocrates 11y agoThe PHP library is (surprise!) sort of a mess when it comes to things that use the libc locale (which tend to offer no other way of switching locale or encoding), things that use the locale settings from the intl extension, things that respect the default_charset setting (and/or the input_encoding setting, output_encoding setting, or internal_encoding setting), and things that actually take one or more of these settings as arguments.
- aikah 11y agoBe aware that while HHVM is more or less compatible with PHP now, there is no guarantee it will be in the future,and Hack is definitely not backward compatible with PHP. Not even talking about PHP C extensions.
- lsof1 11y agoPorted 200k+ line app to Go over a year ago. Happiest day of my life removing any traces of PHP from my systems.
- ZeroGravitas 11y agoIs a comprehensive test suite for PHP a byproduct if this? Last time I checked PHPs own tests only had about 30% coverage, and with a famously idiosyncratic language like PHP, which apparently needs a massive internal overhaul to increase speed, that seems less than optimal. I thought the test suite was one of the best things to come our of multiple ruby implementations, though I read recently that core Ruby ignore it and so regularly introduce bugs that it would catch.
- Kabacaru 11y agoThere's a talk Dan gave on this same topic at PHP UK 2015 that's worth watching. https://www.youtube.com/watch?v=75j1RRxxARI https://www.youtube.com/watch?v=75j1RRxxARI