5 ms·
> Its application code is still developed using PHP This is surprising since 1) Facebook is most likely using Hack and 2) it could save a lot of money by movin
by pier25 9y ago
> Its application code is still developed using PHP
This is surprising since 1) Facebook is most likely using Hack and 2) it could save a lot of money by moving to Go.
> Facebook’s entire site runs on HHVM (desktop, API and mobile)
Isn't Facebook running mostly on React? I'm guessing HHVM only really powers the API, business logic, etc.
- sgslo 9y agoHHVM is a VM for executing Hack and PHP, used extensively on the backend at Facebook. The majority (all?) of the front end and mobile apps are powered by React and React Native, respectively.
- pier25 9y agoYes, that was why I mentioned it. The article said PHP was powering their web apps, but in fact it's only powering the APIs since their frontends are SPAs.
- pryelluw 9y agoExplain point #2, please.
- pier25 9y agoLet's imagine Facebook spends 2 billion on servers every year. If it could reduce the number of servers by 20% because of the better Go performance it would save 200 million every year. Go outperforms HHVM by a wider margin than 20%. I've seen benchmarks as high as 50%. Sure, benchmarks aren't real world applications, but it's safe to say that generally speaking Go is significantly faster than HHVM.
- dboreham 9y agoIt would need a much higher return than your estimate if 20% to be worthwhile given the downsides (everything breaks, legions of engineers spend years figuring out how to do the migration). Also most systems end up being I/O or memory pressure bound, so the 20% number could easily be 0% or even negative.
- crispytx 9y agoPEOPLE ON THE INTERNET BE LIKE: "Let's rewrite everything in Go."
- cbhl 9y agoI imagine the lifetime savings of having a backend in Go is dwarfed by the one-time cost of such a migration. That's why they invented Hack and HHVM in the first place -- it was a cheap-enough compromise that didn't require rewriting the whole code base.
- tyingq 9y agoI'm not even convinced there's much savings. Hhvm supports an asynchronous pattern, and their proxygen web server (no fixed number of fcgi processes), so the typical PHP bottlenecks may not be an issue for FB. Wouldn't most of the pressure be on whatever the data layer is?
- closeparen 9y agoIIRC, Facebook uses (their derivative of) PHP to collect data from a number of services in different languages over Thrift, which they developed. PHP is the presentation layer. Much of the actual logic is in C++, Java, and maybe even Go by now.
- jsmthrowaway 9y agoThey mentioned exactly that as a talking point during a talk I saw in 2012, so I'd imagine it's even more accurate now. Thrift exists for a reason. Another fun bit from that deck was a newsfeed-related PHP function with something like over 70 arguments across a dozen lines -- basically template data to render that had organically grown over time. It earned its own slide. There was an audible gasp from the room when it was revealed in all its glory, and they talked about the work it takes to refactor stuff like that (which is extensive).
- rbranson 9y ago(Former Facebook employee) The VAST majority of online serving code at Facebook is written in Hack (PHP) and is part of a gigantic codebase called fbwww. Backend services that do heavy lifting (mostly search, feed ranking, ad matching, TAO, various caches, proxies, etc) are fairly light on business logic and written in C++. It isn't a microservices architecture at all: they only move stuff to C++ for latency and efficiency reasons. For instance most of the ad stack is written in Hack, but certain key pieces use C++ for better performance. I'm not aware of any Java or Go code that is part of the online serving stack.
- ot 9y ago> 2) it could save a lot of money by moving to Go. [citation needed]
- deleted 9y ago[deleted]
- pier25 9y agoEven if they reduced their server usage by 10% that would amount to a lot of money, and it's probable the performance benefit would be much higher than that.
- underwater 9y agoFacebook spends more on people than they do on servers. I'm sure they have considered switching languages, but decided against it.
- umanwizard 9y agoWhat is this assertion based on?
- kondro 9y agoHow is replacing their entire engineering staff cheaper?
- luord 9y ago> I'm guessing HHVM only really powers the API, business logic, etc. So "only" everything except UI (which is run by the browser, not FB's servers), then. And that's only for browsers that use it at all, as they still need to render a lot of stuff from the servers both for speed and for people who turn off js or use older or limited browsers. And this is a weird thing to say anyway, nothing runs "on" react; both the framework(s) and the business logic run on something else.