HHVM vs PHP 7 – The Competition Gets Closer!

Updated on February 12, 2018

The “dynamically typed” programming language presented unprecedented opportunities for Facebook developers to build and rebuild the site, as Mark Zuckerberg puts it,”The Hacker Way”. However, it eventually ended up losing all the knack for rapid-fire development and succumbed to the intense workload of millions of users visiting the site every minute.

Then they invented HipHop, a tool that converts PHP script into C++ prior to compilation and execution on Web servers. This single – and by no means simple – change increased server capacity to accommodate a 500 to 600 percent increase in web traffic. In simple business terms, Facebook saved five to six times on server cost because of changing the way the code was run.

However, the HipHop beat couldn’t last long enough and Facebook needed yet another engineering breakthrough to accommodate its exploding web traffic. The team eventually developed the HipHop Virtual Machine (HHVM), a system that uses Just-In-Time (JIT) compilation to convert PHP code into a machine language to establish a synergy between the PHP code and the underlying hardware that runs it. A recent Kinsta post covers the rise and evolution of HHVM at Facebook.

The virtual machine was eventually made available for the WordPress world as an open source execution engine for PHP code promising similar performance improvements over the traditional PHP execution engine, Zend.

The PHP community is now responding to the HHVM competition with PHP 7, the latest PHP iteration promising 100 percent increase in performance over previous PHP versions. Feature speculations and possible enhancements for PHP 7 include:

Performance Improvements

The art of programming is changing rapidly and business organizations need to tap into the mobile user-base with better value propositions. In this context, PHP 7 will feature a range of execution engine improvements, offer native local threat storage and reduce memory usage.

These advantages serve particularly well for mobile devices with limited Web browsing capabilities. The upcoming PHP version also supports the idea of a greener planet with the ability to handle more traffic within the same server resources.

Zeev Suraski, co-founder of Zend Technologies considers HHVM as a direct competitor to the Zend execution engine and demonstrates how far the next generation PHP version has evolved in terms of performance improvements.

JIT Engine Speculation

The ability to implement JIT execution capabilities for the Zend engine is the prime motivation behind the development of next-generation PHP language version. These capabilities enable dynamic compilation of Zend opcodes into native machine instructions, the key principle driving performance with the HHVM engine.

As things stand, PHP 7 is on par with HHVM without JIT compilation capabilities featuring built-in with the Zend engine. However, PHP 7 is essentially repurposed to support better migration to a JIT compiler and promises even better performance improvements in years to come.

Asynchronous Programming Speculation

PHP 7 is developed in a way that facilitates simultaneous execution of asynchronous tasks. This capability will allow future iterations of PHP to support asynchronous programming and tasks such as access to database, networks, timers and perform events related I/O operations by implementing a single PHP event-loop.

Since the Facebook Hack language for HHVM already supports asynchronous programming, PHP core developers could see the same option made available for PHP 7 or its future iterations. This article covers a range of syntax changes expected for PHP 7.

Similarly, supporting standalone multi-threading further will further allow PHP-based servers to handle simultaneous requests from a single memory pool.

Benchmark Comparisons

The following benchmark results compare the performance of various PHP versions and HHVM conducted across different content management systems:

Text Box Specs:

text box specs

Resource: http://talks.php.net/fluent15#/boxspecs

The test results demonstrates significant performance improvements with PHP 7 over its previous iterations, shrinking the persistent gap between PHP and HHVM. Running on WordPress 4.1.1, PHP 7 allows the system to execute twice as many requests per second in comparison with the PHP 5.6, the latest stable release.

hhvm php7 benchmark

Resource: http://talks.php.net/fluent15#/wpbench

Benchmarks conducted on the Drupal 8 CMS present PHP 7 as a clear winner over HHVM with the ability to handle over 37 percent additional server requests per second. In comparison with PHP 5.4, 5.5 and 5.6 that provided minimal performance through the subsequent iterations, PHP 7 accommodated over 80 percent additional requests per second.

PHP 7 as a clear winner over HHVM

Resource: http://talks.php.net/fluent15#/drupalbench

This tests also presents PHP 7 with Zend execution as a better performing package than HHVM for CMS including WordPress and Drupal

Benchmarks conducted on Ubuntu Utopic package 5.5.12 compared the performance of PHP and HHVM in running a few basic test suites:

next generation php vs hhvm

Resource: http://www.phoronix.com/scan.php?px=MTg3ODY&page=news_item

These benchmark results show interesting difference in between HHVM and PHP. PHP 7 is able to conduct the tests in 164.844 seconds with peak memory consumption of 30.879 MB. In contrast, HHVM performs the test twice as fast (84.759 seconds) but consumes 4.5 times more system memory (134.844 MB).

You can review our recent real-world benchmark comparisons between the latest iterations of PHP and HHVM on this article.


The peer-to-peer e-commerce giant Etsy having racked up over $108 million in annual revenue with 54 million registered users needed a serious revamp of its underlying technology infrastructure overwhelmed with millions of visits on a daily basis. Etsy engineers needed to improve the online service performance and boost backend data center efficiencies.

The company adopted the open-source HHVM solution to run PHP applications to maximize performance potential of the existing hardware infrastructure without having to invest in additional data center resources.

Etsy was most concerned with their new internal API to handle greater throughput so that servers could process more computing requests, consume less power and shrink operational expenses. Etsy engineers tested HHVM against PHP 5.4 by randomly splaying requests across three API endpoints, starting from 10 requests per second and ramping up to 280.

The benchmark results show how PHP experienced exponential performance degradation from 190 requests per second onward. At the same time, HHVM consistently demonstrated high performance until reaching 280 requests per second.

hhvm response time load increase

Resource: https://codeascraft.com/2015/04/06/experimenting-with-hhvm-at-etsy/

HHVM also optimized CPU time and required half as much CPU cycles as compared to PHP running exactly the same Web traffic profile and was also more efficient at communicating with backend services:

hhvm and php cpu usage

Resource: https://codeascraft.com/2015/04/06/experimenting-with-hhvm-at-etsy/

HHVM at Wiki

Almost half a billion Internet users visit Wikimedia every month. The website embodies the true philosophy of Internet as a means to share information free and accessible to the wider world. Bringing this ideology to life effectively requires the company to serve this information to end-users at reasonable speed.

Operating on a minimal budget and staff, the Wikimedia Foundation was forced to employ innovative solutions to boost backend server performance and capacity. Installing additional servers would only bottleneck performance since PHP as a single-threaded language cannot be parallelized. On the other hand, HHVM can load multiple CPU cores simultaneously to maximize the performance potential of servers.

Wikimedia achieved the following performance advantages by deploying HHVM:

  • CPU load shrunk from 50 percent to 10 percent.
  • Mean Page Save Time halved from six seconds to three seconds. This time is the interval between users hitting the ‘submit’ or ‘preview’ button and the server processing this request. Wikimedia received over 100 million edit requests in 2014 and HHVM will now help save around 10 years of latency every year.
  • Median Page Save Time reduced by two thirds, from 7.5 seconds to 2.5 seconds.
  • Average Page Load Time also dropped, from 1.3 seconds to 0.9 seconds.

HHVM average page load time

Resource: https://blog.wikimedia.org/2014/12/29/how-we-made-editing-wikipedia-twice-as-fast/

Lessons Learned So Far…

Website performance is the crucial element of successful online presence. Progressive business organizations design systems to optimize innovation, which is all about delivering better, intelligent and useful online services faster than ever before.

While we have to wait for the stable release of PHP 7 to true winner in the HHVM vs PHP 7 battle, developers and online businesses can rely on the following key findings based on private benchmark results from various developers and companies:

  • HHVM is significantly faster than PHP-Zend packages for all PHP versions prior to PHP 7 or PHPng (PHP Next Generation).
  • PHP 7 has a slight edge against HHVM for WordPress set-ups. WordPress users should expect PHP 7 to improve and extend this advantage in the near future.
  • The switch to HHVM is not push-button. Large environments such as Etsy and Wikimedia Foundation took over six months to fully switch from the PHP-Zend package to PHP-HHVM package. For self-hosted websites, the complex transition requires in-house expertise and may cause disruptions until thoroughly completed.
  • Online businesses should choose between PHP 7 and HHVM sooner than later, lest they continue to incur significantly higher datacenter OpEx and risk losing valuable brand image due to inadequate website performance.

Performance optimization of PHP-based WordPress websites is an ongoing process yielding small chunks of incremental improvements. Injecting performance enhancing capabilities in the form of add-on plugins and minor code changes eventually fail to improve performance bottlenecked due to limited capabilities of the underlying PHP code-base and infrastructure.

Any further performance improvements – of 100 percent or faster – will be attributed to the server capacity and capabilities to process computing requests at higher rates. Both HHVM hosting and PHP 7 make this possible.

What is your experience with using HHVM? I’d love to hear your thoughts in the comments below.

This article was written by Ali Raza
Ali is a Pro Web Developer and a huge fan of WordPress and BuddyPress. He also covers consumer and enterprise technology issues for major U.S. and international publications. As a racing driver and a stunt master, only cars eclipse his love for technology.

Hand-picked related articles

  1. Gravatar for this comment's author
    scamo May 26, 2015 at 4:03 pm

    Nice article. Just for the record, PHP has been “threadable” for some time. It’s just that not many people really use it, as it means a new way to think while developing software. Hopefully, PHP7 will start to change minds to the new paradigm of asynchronous programming.

    1. Gravatar for this comment's author
      Dominik Wurm May 27, 2015 at 10:32 am

      Nice article and comparison! Really looking forward to use PHP 7.
      Btw. PHP 5 supports multi-threading and here is how to install it: https://blog.flowl.info/2015/compile-php-5-6-pthreads-mongo-ubuntu/

  2. Gravatar for this comment's author
    myfrenchcity May 26, 2015 at 6:42 pm

    hi HHVM is really fast but for me still unstable crash many many times and no way to really fix it so obviously we are eagerly waiting for php 7 to see if much better faster and reliable

    1. Gravatar for this comment's author
      tomzur June 10, 2015 at 10:40 am

      We are all looking forward to PHP 7 :-)

  3. Gravatar for this comment's author
    Dominik Wurm May 27, 2015 at 10:32 am

    Nice article and comparison! Really looking forward to use PHP 7.
    Btw PHP 5 supports multi-threading and here is how to install it: https://blog.flowl.info/2015/compile-php-5-6-pthreads-mongo-ubuntu/

  4. Gravatar for this comment's author
    Richard4k June 1, 2015 at 11:29 pm

    Great article. We are really happy with HHVM for http://4k.com Without HHVM our backend was so slow it was unusble. Looking forward to PHP 7 and seeing the benefits that come with it.

    1. Gravatar for this comment's author
      tomzur June 10, 2015 at 10:39 am

      Hi Richard, good to hear that HHVM works for you!

    2. Gravatar for this comment's author
      justin December 1, 2016 at 10:18 am

      hey Richard, It’s Justin, we worked together at Gigasavvy, Can’t believe I found you on some random internet article. lol
      I am using NodeJS/MySQL/Redis a ton lately, I also use PHP/HHVM to serve some frontend pages that require some minor internal logic. Glad I didn’t upgrade to PHP 7!

  5. Gravatar for this comment's author
    Thomas Zickell July 12, 2015 at 1:04 am

    I have four unique stable environments all on each HHVM I tried PHP7 and was unbelievably disappointed.

    Unfortunately were talking about software that is not actually going to run every day sites when it comes to PHP 7

    Do you really think that HHVM will not take advantage of PHP 7 improvements?

    I am headed my bets on yes. And so is Facebook.

    Magento configs WordPress stacks and nothing is beating HHVM

    I hope that server side code gets much faster for PHP-based applications and I’m not a fan boy if either one I simply want whatever’s fastest.

    1. Gravatar for this comment's author
      Nikola B. September 2, 2015 at 10:35 am

      HHVM has one interesting trait – namely, it doesn’t work as advertised. It crashes. It’s unfinished. It’s CLI is far from done so one can’t use PHP via HHVM for small, yet useful daemon scripts due to no GC (meaning memory goes up and up). HHVM needs time for JIT to kick in so it’s not as quick immediately. Many php extensions don’t work with HHVM (ZeroMQ pops to mind as one) and you instantly get tied to Facebook and their development cycle. Small differences that are in range of 10% or so between PHP 7 and HHVM are sufficient to deduce that it’s much smarter to use PHP 7 than HHVM. PHP 7 has room for improvement, its first iteration shows that it’s as fast as HHVM is, which uses JIT to achieve its performance. To me, it seems that PHP 7, lead by PHP team, will get even faster in the future – without deviations in the language (such as Hack). So, if you think that it’s better to use an unstable, unfinished product coming from a company with questionable authority when it comes to software engineering – then that’s great, it works for you. For others, who have more at stake and don’t want to get screwed over or taken by the hipster train to a joy ride – PHP 7 is obvious and the only sane choice.

      1. Gravatar for this comment's author
        tomzur September 2, 2015 at 12:11 pm

        PHP 7 has definitely room for improvement, but at this time its performance is far from HHVM. We are testing them all the time and HHVM seems a lot more faster. You are right, it’s unfinished, has bugs and crashes but only on not so well-coded sites. At Kinsta we are running HHVM on sites with millions of visits and its working like a charm, but I have to mention that the code base of these sites is top notch.
        Looking forward to the PHP 7 improvements.

        1. Gravatar for this comment's author
          Nikola B. September 2, 2015 at 1:21 pm

          How is plus minus 10% in performance “far” from HHVM? It just doesn’t make sense really. There are so many factors that affect the speed, and current benchmarks are so poor and misleading that they can’t be relied upon (they usually just siege/ab/wrk a URL and that’s how “speed” is measured – quite ridiculous if you think about it). Stability, support, roadmap – quite important features if you ask me. Seeing you haven’t had issues with HHVM – great for you, I do believe you cut down your costs and improved user experience. The only problematic thing is that you can’t be sure there’s a piece of code in your sites that might cause HHVM to go nuts and crash. Sadly, it’s quite difficult to test for such a thing, and that alone would make me steer away from HHVM. On the other hand, PHP scaling is quite trivial these days – a pool of php-fpms can be added to nginx and it round-robins the requests – voila, http fronted is scaled horizontally now. If you rely on sessions, it’s trivial to make sessions available to all machines (encrypted cookie, fast shared in-memory store etc.) so I would never use performance as an argument if you run a proper business using PHP. Stability outweighs performance and as mentioned – performance can be achieved if you’re ready to invest a bit more money into making your business stable. Everything else, by every logic, is subpar and that makes HHVM a bad choice. Also, servers are quite cheap, for a few bucks one can get a decent number of servers and have speed + failover + stability at the same time.

          1. Gravatar for this comment's author
            TechZilla December 16, 2015 at 9:47 pm

            Agreed, which is why I prefer PHP hands down, but then again… The main reason that is pushing PHP aside is the terrible Apache Pre-fork how to guides. It also means anyone who wants to “prove” how horrible PHP is can do so easily by default. Zend should apply pressure to get default configurations done as the modern scalable ones. (php-fpm)

          2. Gravatar for this comment's author
            Sebastian Kleine December 29, 2015 at 2:04 pm

            I do not agree. Stability is important. But what you say about that peace of code making HHVM crash might happen with PHP as well. You never can be sure. We use HHVM for a while and it works flawless. And it has an error log. So if something went wrong, we will know it. As far as I can say hhvm is as stable as php. And if we could save a few hundred bucks each month, we are happy (yes, there are cheap servers, but then do not argue about stability. If they crash, how fast are the damaged parts replaced? You will pay more than a few bucks for a fast and reliable server and the hosting environment.)

      2. Gravatar for this comment's author
        Thomas Zickell September 22, 2015 at 4:31 pm

        I agree there is a lot of work to be done. However as stated below my Kinsta VPS is much faster than any configuration I have built on PHP 7 the other thing that I think is extremely important to remember is HHVM will take advantage of many of PHP 7’s improvements.

        Right now the better choice is HHVM that is even running on FireHost / Armor configurations.
        That are HIPPA & PCI compliant and this is being used on many Fortune 500 configurations.

        If you can figure out what you want from HHVM like any tuning process you must build it for you or need. For all of my needs so far nothing beats HHVM.

        Not saying that you don’t make some good points what I’m saying is there a relevant for 70% people wanting to run wishing to run WordPress.

  6. Gravatar for this comment's author
    Mangap August 1, 2015 at 11:33 pm

    I hope zend and other PHP supporter working thir best to make PHP 7 win. I believe Facebook preparing new hhvm which is better and faster now. But please keep the compatibility with PHP 5.6 code.

    1. Gravatar for this comment's author
      Anonymate August 12, 2015 at 6:20 am

      As you can read in hhvm.com, “[…] The HHVM team, along with many wonderful community members, has made it a stated, high priority goal to run all existing PHP code existing out in the wild.”. They are working on that. It’s not they aren’t keeping compatibility. It’s just they are STILL working to make it fully compatible. And it will be.

      HHVM is relatively new. They are starting only now to work on optimizations. Until not long ago, they were just trying to make it work… PHP7 may win by a slight percentage in the beginning, but HHVM will certainly get much better over time. HHVM isn’t a world-class VM yet.

      I hope PHP7 gets much better than HHVM, because that means the HHVM team will need to work hard to make HHVM even better. And with that, we all win =P.

  7. Gravatar for this comment's author
    Mark Bayazit October 8, 2015 at 6:54 pm

    Please fix your blog. This article looks dated but I have no way of verifying — where on earth is the post date? It should be prominently displayed beneath the title.

    1. Gravatar for this comment's author
      tomzur October 10, 2015 at 11:20 pm

      Hi Mark, we have fixed this issue. You can find the post date beneath the author’s name. Sorry about this. Cheers Tom from Kinsta.

  8. Gravatar for this comment's author
    Praneed December 30, 2015 at 6:38 am

    I love to know about this PHP 7. I am interested in reading php related articles since last two months and I bookmarked those in which are makes me feel nice one. I am gonna do the same here. Interesting comparison with HHVM. I didn’t even know about HHVM before. After I’ve got this article, I bit learned about what is HHVM and its working. Thanks for such a nice one mate. I still searching article that related to this like PHP 7 vs HHVM, many peoples have written articles about these two.

  9. Gravatar for this comment's author
    Sonal Sinha September 7, 2016 at 5:14 am

    Litespeed server with PHP 7 for a WordPress website you have a winner straightaway without any need to go into HHVM or any other technical ones.

Leave a Reply to Dominik Wurm Cancel reply

Use WordPress?

Join 20,000+ others who get our FREE weekly newsletter with WordPress tips on how to drive more traffic and revenue to your business!

You have Successfully Subscribed!

Send this to a friend