HHVM’s Threading Difference – Not The Same as PHP-FPM

Mattias Geniar, Monday, April 6, 2015

I'm glad Etsy found this before the rest of us had to.

Most PHP SAPIs are implemented such that each request is handled by exactly one process, with many processes simultaneously handling many requests.

HHVM is a threaded SAPI. HHVM runs as a single process with multiple threads where each thread is only handling exactly one request. When you call setlocale(3) in this context it affects the locale for all threads in that process. As a result, requests can come in and trample the locales set by other requests as illustrated in this animation.
Code as Craft -- Etsy blog

HHVM pays of. It's more than twice as fast as PHP 5.4 in my benchmarks. But, it's not a drop-in replacement for PHP-FPM.

As with everything: testing, testing & testing.

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


Johnny Robeson Monday, April 6, 2015 at 22:47 - Reply

that will be fixed when this lands https://reviews.facebook.net/D35451

Pavel Petrov Thursday, January 12, 2017 at 11:07 - Reply

the article is outdated — HHVM works as FCGI very well now in 2016-2017

Leave a Reply

Your email address will not be published. Required fields are marked *