Welcome to Centmin Mod Community
Register Now

WebPerf PHP 7 vs HHVM – Which One Should You Use?

Discussion in 'All Internet & Web Performance News' started by eva2000, Dec 16, 2016.

  1. eva2000

    eva2000 Administrator Staff Member

    30,961
    6,918
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,420
    Local Time:
    11:06 PM
    Nginx 1.13.x
    MariaDB 5.5
    PHP is still considered the favorite scripting language of many web developers, and its newest version greatly outperforms its predecessor; however, a little virtual tool capable of executing PHP code called HHVM has been turning heads for the last half-decade thanks to its superior performance over PHP 5. Now that PHP 7 has been out for almost a year, why is the PHP 7 vs HHVM debate still ongoing?


    Most of the discussion surrounding PHP 7 vs HHVM has focused on performance speed, which seems like a straightforward metric, but there are circumstantial factors that need to be taken into account when looking at comparisons between both.

    Ardent supporters of PHP 7 or HHVM will undoubtedly argue that their language of choice is the best for everyone. Ultimately, the right choice for you will depend on your familiarity with PHP vs HHVM and the types of projects you’re working on. Below is a primer on each option with charts comparing their capabilities.

    About HHVM


    [​IMG]

    HHVM, which stands for HipHop Virtual Machine, was developed by Facebook in 2010 and released publicly the following year. It was designed to reduce server resources in order to deliver a faster web experience for Facebook users. Thanks to its Just in Time (JIT) compiler, HHVM can quickly convert PHP code into machine code.

    HHVM Pros

    • The JIT compiler gives HHVM a massive performance boost over PHP 5.
    • Because Facebook uses HHVM, they are constantly working to improve it, so developers have dependable community support.
    • Dynamic translation allows websites to run faster in many situations.
    • An internally developed language called Hack lets programmers use dynamic and static typing to further improve compilation speed.
    • HHVM requires little memory space to execute requests.
    • Any developer can install and work with HHVM.
    HHVM Cons

    • While you may add custom extensions, you must first convert them.
    • In the unlikely event that Facebook discontinues support for HHVM, the large development and support community would cease to exist.
    • HHVM doesn’t support all WordPress themes and plugins; however, you may be able to hack them to function with HHVM.
    • HHVM was made by and for high-end machines, so it isn’t supported any 32 bit operating systems.
    • HHVM requires more memory overall than PHP 7, which can constrain server selection. For this reason, it’s not recommended to use HHVM on servers that have less than 2 GB RAM.
    About PHP 7


    [​IMG]

    After a long and tumultuous development period, PHP 6 was completely scrapped and replaced by a new version. Before it was released in 2015, PHP 7 promised a 100 percent performance boost over PHP 5. Its advantage over the previous versions is indisputable, so discussion has now turned to how PHP 7 stacks up against HHVM.

    When analyzing PHP 7 vs HHVM, it’s important to first note their similarities. Since the PHP interpreter and HHVM both execute PHP code, the actual code writing process is essentially the same. Of course, before you can use HHVM, you must install it on the server and call it using the HHVM command.

    The biggest difference when looking at PHP 7 vs HHVM is how both interpret PHP code. PHP 7 directly interprets and executes code on the server using the standard PHP interpreter, which is free for everyone. The generated HTML code is transmitted to the client and then displayed to the web user.

    HHVM, on the other hand, converts PHP code into Hip Hop bytecode before translating it into machine code and executing it. During this translation, inefficiencies in the PHP code get ironed out, resulting in quicker performance.

    PHP 7 Pros

    • The request handling limit for PHP 7 is double that of PHP 5.6, and it responds to each request quicker.
    • New programming language features include uniform variable syntax, return type hinting, and new operators.
    • By altering how it internally handles data, PHP 7 is 3.5 times more memory efficient than PHP 5.6.
    • Many established communities exist that can assist developers with PHP troubleshooting and other technical support.
    PHP 7 Cons

    • Some features of PHP 4 are no longer supported.
    • PHP is outmatched by HHVM in many, but not all, performance metrics.
    • Some application themes and plugins are not yet compatible with PHP 7.
    • Because of its limitations, PHP 7 isn’t ideal for extremely high-traffic websites such as Facebook.
    PHP 7 vs HHVM: Speed Comparisons


    If you search the internet for performance comparisons regarding PHP 7 vs HHVM, you might be dismayed to find conflicting reports, which is why it’s important to pay attention to methodology when looking at benchmarks. No one can dispute that both PHP 7 and HHVM vastly outperform older versions of PHP; however, there are some instances in which PHP 7 is faster than HHVM, and there are some cases in which the opposite is true.

    Dozens of PHP 7 vs HHVM benchmark charts have been published for a number of applications and frameworks. For example, “The Definitive PHP 7.0 & HHVM Benchmark” from Kinsta compares the performances of PHP 5.6.16, PHP 7.0 and HHVM 3.10.1 on a few popular software suites. Below are a couple of excerpts (for WordPress and Drupal) outlining the results from Kinsta’s post that show the comparison metrics between PHP 7 and HHVM.

    HHVM vs PHP7: WordPress 4.4


    Utilizing dummy content from wptest.io, Kinsta benchmarked the home page for 60 seconds with 15 concurrent users. They also used HHVM’s Repo Authoritative mode for this test, but the authors note that using this mode in other applications may require extensive modifications, so the benefit of extra speed may not always be worth the time it takes to make all of the necessary changes. Either way, HHVM appears to respond faster than PHP 7 as shown in the diagram below.

    [​IMG]Image Src: kinsta.com

    Note that omitting opcache in PHP 7 results in a drastic drop in performance. When Kinsta ran the same PHP 7 vs HHVM performance tests in WordPress 4.3.1 under the same circumstances, they got almost identical results.

    However, a contributor at WPOven Blog has attested that PHP 7 can execute more queries per second according to the WP Performance Tester Plugin:

    [​IMG]Image Src: wpoven.com

    The same blogger ran various other speed comparisons between PHP 7 and HHVM on WordPress using their own methods.

    HHVM vs PHP7: Drupal 8.0.1


    Following the same Kinsta post, they also compared PHP 7 vs HHVM using the Drupal CMS. Benchmarking a standard Drupal page for 60 seconds with 15 concurrent users yielded the following results:

    [​IMG]Image Src: kinsta.com

    This report has received some criticism for not telling a complete story. Blogger Jeff Geerling notes that the standard installation for Drupal 8 has cache enabled as a default setting. Disabling the cache can give different results. See his blog post for more PHP 7 vs HHVM performance comparisons in different situations.

    Kinsta also tested PHP 7 vs HHVM on a few other CMS’s including the Magento 2 community edition, October CMS, and Pyro CMS. Their findings for these three additional tests resulted in HHVM performing better than PHP 7.

    The one performance test that resulted in PHP 7 being faster than HHVM was for Laravel 5.1 which resulted in PHP 7 being able to deliver 1363.24 transactions per second whereas HHVM delivered 1128.41 transactions per second.

    PHP 7 vs HHVM: Which One Wins?


    Anyone accustomed to PHP 5 will notice the steep improvements made for PHP 7. Nonetheless, HHVM WordPress sites consume fewer CPU resources, which allows for more transactions per second for a high number of concurrent requests. PHP 7 and HHVM perform about equally on site load time tests.

    The best choice for you will depend on your capacity and your requirements. If you manage a Website that receives a large volume of concurrent hits, HHVM may be a better option provided you have a multi-core server that can handle it. Otherwise, PHP 7 should be sufficient for most users who are looking for significantly higher performance than PHP 5. With continued support, PHP 7 could conceivably surpass HHVM in performance eventually.

    As we can see PHP7 is still very popular in terms of Google search trends while compared with HHVM.

    [​IMG]

    From the perspective of a typical web user, the differences in speed between both PHP7 and HHVM are barely noticeable. However, while the speed of delivery is an important factor in the user experience, it’s not the only thing that matters.

    For developers who have been using PHP for years, PHP 7 will feel very familiar, so there’s little to no learning curve to overcome. If you’re considering switching an existing website from PHP 5 to PHP 7 or HHVM, the process might go quicker if you choose PHP 7 because experienced developers will know how to set it up and configure it.

    Another benefit of PHP 7 is that the PHP Group has existed for a long time, and its purpose is to support developers. HHVM is much newer and was designed to support Facebook, and what works best for Facebook isn’t necessarily best for everyone else. Some developers have expressed frustration with HHVM and find themselves having to “work around it” to get their job done. On the other hand, anyone who takes the time to learn HHVM will have a very powerful tool at their disposal.

    The Case for HHVM

    • Thanks to dynamic translation, HHVM can perform faster in terms of transactions per seond than PHP 7 on many applications, including WordPress.
    • When bombarded by multiple requests, HHVM consumes less memory than PHP 7 needs to process each request.
    • Developers are continually releasing PHP code bases to make HHVM more accessible and compatible with PHP frameworks and applications.
    • Despite being an internal Facebook creation, HHVM is open source, so anyone can use or alter the source code.
    The Case for PHP 7

    • Under the right circumstances, PHP 7 can actually outperform HHVM when running on certain applications.
    • Many developers consider PHP 7 to be easier to setup, install, and use.
    • Code that was written in PHP 5 should work properly after a transition to 7, so anything written in the past decade should be easy to convert.
    • The PHP community has a steady record of stable and reliable releases.
    HHVM vs PHP 7: The Choice is Yours


    Don’t be paralyzed by indecision. Picking a side is the first step toward achieving your development goals, and the sooner you take the first step, the sooner you’ll have a finished product. Leaving a poorly performing website languishing on the internet can irreparably damage a brand’s reputation, which is why you should ensure optimal performance as soon as possible. No matter which side you take in the PHP 7 vs HHVM debate, everyone agrees that both are a major step up from PHP 5, so start converting to one or the other.

    The post PHP 7 vs HHVM – Which One Should You Use? appeared first on KeyCDN Blog.

    Continue reading...
     
    • Informative Informative x 1
  2. eva2000

    eva2000 Administrator Staff Member

    30,961
    6,918
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,420
    Local Time:
    11:06 PM
    Nginx 1.13.x
    MariaDB 5.5
  3. Revenge

    Revenge Active Member

    289
    64
    28
    Feb 21, 2016
    Portugal
    Ratings:
    +228
    Local Time:
    1:06 PM
    1.9.x
    10.1.x
    • Informative Informative x 4
  4. eva2000

    eva2000 Administrator Staff Member

    30,961
    6,918
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,420
    Local Time:
    11:06 PM
    Nginx 1.13.x
    MariaDB 5.5
    wow PHP 8 looking very good so far !
     
    • Agree Agree x 2