Latest Version PHP 7 vs HHVM Multi-angle comparison _php instance

Source: Internet
Author: User
Tags benchmark hhvm versions drupal

PHP is one of the most popular scripting languages for Web development. The latest version of PHP, PHP 7 has done a lot of performance optimization. However, PHP also has a competitor HHVM (HipHop virtual Machine)-a virtual tool that runs PHP code. The direct comparisons are heating up, so let's take a look at their direct performance comparisons.

What is HHVM?

In 2008, Facebook started a job that planned to develop a tool to convert PHP scripts into C + + so that it could be compiled and run on a Web server. The goal is to conserve server resources, which is a very important goal because Facebook's user capacity is growing fast. In this sense, the project is successful because it allows the server to process requests from five to six times times before.

As time goes back to 2010, Facebook's server needs have increased a lot, and it's time to consider new innovations to boost efficiency. Based on this demand, Facebook has developed HHVM.
HHVM uses a Just-In-Time (JIT) compilation to convert the PHP code to a byte code. Next, the bytecode is converted to machine code and optimized to make it run as fast as possible.

What is PHP 7?

PHP 7 is the response of the PHP community to HHVM. The preview version of the PHP 7 release boasts a 100% increase in performance over the previous PHP 5.

You may ask the PHP version to jump directly from PHP5 to PHP7, and the answer is this: PHP6 's development began in 2005, but its progress was too slow and a lot of problems, so PHP6 had a bad reputation before it released the official version. So the PHP community decided to name the new version of the language directly as PHP7.

The real problem is not the comparison between PHP5 and PHP7, as it is already clear that PHP7 provides faster speed. But what we want to compare is PHP7 and HHVM. Many experts have used these two methods to process PHP code, and have revealed some interesting conclusions.

Compare the similarities and differences between PHP7 and HHVM:

Before we answer which is better, let's take a look at the key differences and similarities between them.

Code resolution:

The basic difference between PHP7 and HHVM is the way they parse the PHP code. PHP7 uses the standard PHP parser, which is a free software that can be used by everyone, and can be parsed and run directly on the server. It generates HTML code and sends it to the client, which displays what the user expects.

By contrast, HHVM first converts the PHP code into a HipHop byte code, which is then translated into machine code and executed. In this process, HHVM will optimize the code, optimize some of the PHP code that affects execution efficiency, and the goal is to improve the speed of the operation.

Write code:

Both PHP parsers and HHVM can receive PHP code and then run. The process of writing code is exactly the same. But if you want to use HHVM, you need to install HHVM on your server and then call it via the HHVM command at the command line.

Performance test:

HHVM can provide faster performance than previous versions of PHP. But recent performance tests suggest that at least in some cases PHP7 is slightly faster than HHVM. Let's take a look at the performance test results from Kinsta:

WordPress: The PHP7 that runs in WordPress4.1.1 can perform more than twice times more than PHP5.6 per second, but no HHVM3.6.1 offers more, and in tests HHVM executes 624 requests per second and PHP7 only executes 604.

DRUPAL:PHP7 can provide Drupal users with more obvious advantages than HHVM. The response efficiency of PHP7 on Drupal8 is more than 37% than that of HHVM.

Those companies use HHVM?

In addition to developing HHVM's FaceBook company, there are many other companies that have adopted this program to run PHP applications on the server with HHVM, including Wikimedia and ecommerce website Etsy.

Wikimedia:wikimedia has a wealth of educational content, including the famous online encyclopedia, Wikipedia. Wikipedia attracts nearly 500 million of internet users each month, to meet such advanced requirements, the need to optimize the performance of the server, and PHP compared to HHVM has a significant advantage, it can load multiple SPU core, and PHP is a single-threaded language, can not be parallelization. After Wikipedia deployed the HHVM, the CPU load dropped from 50% to 10%, and the average response time when the user submitted the edit was reduced to half the original, and the average load time of the page dropped from 1.3 seconds to 0.9 seconds.

Etsy: With 54 million users, Tesy also desperately needs to improve server performance, Etsy engineers compared HHVM and PHP5.4 performance, found that HHVM can handle 280 server requests per second, but for PHP5.4, if the number of requests per second exceeds 190 times, the response time of the server increases dramatically.

What are the prospects for PHP 7 and HHVM?

Since the stable version of PHP 7 will be released in November 2015, no company has yet used the new language because the PHP 7 Beta has done well in the benchmark and will attract more companies to use PHP 7 in the future.

The future of PHP is bright, so what about HHVM? It may continue to live very well. Many companies have used HHVM to improve performance in their Web sites, and migration between PHP and HHVM is not an overnight move. Etsy spent at least 6 months. Because PHP7 and HHVM have little performance improvements, those companies are unlikely to be eager to switch to PHP.

Facebook will still continue to develop HHVM. It recently announced support for Apple's operating system, enabling developers working in the Apple development environment to use the technology. HHVM's developers believe that in many cases HHVM is faster than PHP7, including worldpress.

Why HHVM and PHP 7 have a competitive relationship with shop owners?

As an online shop owner, you need to decide whether to use PHP7 or HHVM according to the platform where your shop is located. If your site is created with worldpress, then you can look at the latest version of HHVM and PHP 7 benchmark results, from the test results can find the difference in performance, then you can choose the solution to minimize the page load time, server response time and CPU Use rate.

Reasons to choose HHVM

HHVM uses dynamic translation techniques, which in most cases (including WordPress) can provide higher performance.

HHVM when processing a large number of requests, you can guarantee that only a small amount of memory is used for each request.

HHVM developers are steadily increasing the number of PHP code that the engine can run, which can already run the latest version of Worldpress, as well as other common PHP frameworks and applications.

HHVM is open source, although HHVM was developed by Facebook, but it is open source, meaning anyone can use and modify its source code.

Reasons to choose PHP 7

PHP 7 is faster than HHVM in some cases, including running Drupal 8.

You do not need to install setup HHVM using PHP 7.

Although many PHP 4 features are no longer supported in the new version, the code written in PHP 5 will work as expected after converting to PHP 7.

PHP 7 is developed by the PHP community, a group of people who have a reputation for developing stable and reliable PHP versions.

HHVM vs. PHP 7: Make your choice

Don't hesitate too long, Kinsta suggested that those online sites try to make a choice between PHP 7 and HHVM, and start implementing solutions early to optimize your site's performance. A inefficient website can also damage your reputation, which will be hard to undo.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.