Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the advantages of the latest version of PHP 7 vs HHVM

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article focuses on "what are the advantages of the latest version of PHP 7 vs HHVM". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn "what are the advantages of the latest version of PHP 7 vs HHVM?"

What is HHVM?

In 2008, Facebook launched a project to develop a tool to convert PHP scripts into Cellular scripts so that they can be compiled and run on web servers. The goal is to save server resources, which is an important goal because the number of users of Facebook is growing rapidly. In this sense, the project is successful because it allows the server to handle five to six times the previous number of requests.

Back in 2010, Facebook's server demand has increased a lot, and it's time to consider new innovations to improve efficiency. Based on this requirement, Facebook developed HHVM.

HHVM uses Just-In-Time (JIT) compilation to convert PHP code into some kind of bytecode. Then the bytecode is converted into 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 PHP 7 claims to be 100% better than the previous PHP 5.

You might ask that the version of PHP jumped directly from PHP5 to PHP7, and the answer is this: the development of PHP6 started in 2005, but its progress was too slow and there were a lot of problems, so PHP6 had a bad reputation before it was released. So the PHP community decided to name the new version of the language PHP7 directly.

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

Compare the similarities and differences between PHP7 and HHVM:

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

Code parsing:

The basic difference between PHP7 and HHVM is the way they parse PHP code. PHP7 uses the standard PHP parser, which is free software for everyone to use 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 PHP code into HipHop bytecode, which is then translated into machine code and then executed. In this process, HHVM will optimize the code, optimize some of the PHP code that affects the efficiency of execution, the goal is to improve the running speed.

Write code:

Both the PHP parser and HHVM can receive PHP code and run it. The process of writing code in this way is exactly the same. But if you want to use HHVM, you need to install HHVM on your server and invoke it from the command line through the HHVM command.

Performance testing:

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

WordPress: PHP7 running on WordPress4.1.1 can execute more than twice as many requests per second as PHP5.6, but not as many as HHVM3.6.1 provides. In tests, HHVM executes 624 requests per second while PHP7 executes 604 requests per second.

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

Which companies use HHVM?

In addition to FaceBook, which developed HHVM, many other companies have also adopted this scheme, running PHP applications on servers using HHVM, including Wikimedia and e-commerce site Etsy.

Wikimedia:Wikimedia has a lot of educational content, including the famous online encyclopedia Wikipedia. Wikipedia attracts nearly 500 million Internet users every month. In order to meet such advanced requirements, server performance needs to be optimized. Compared with PHP, HHVM has a significant advantage: it can load multiple SPU cores at the same time, while PHP is a single-threaded language and cannot be parallelized. After Wikipedia deployed HHVM, the load of CPU dropped from 50% to 10%, the average response time of users submitting edits was reduced to half, and the average loading time of pages was reduced from 1.3 seconds to 0.9 seconds.

Etsy: Tesy, with 54 million users, also urgently needs to improve server performance. Etsy engineers compared the performance of HHVM with PHP5.4 and found that HHVM can handle 280server requests per second, while for PHP5.4, if the number of requests per second exceeds 190, the server's response time will increase dramatically.

What are the prospects for PHP 7 and HHVM?

Since a stable version of PHP 7 will be released in November 2015, no company has yet used this new language, and because the beta version of PHP 7 performs well in benchmarking, it will attract more companies to use PHP 7 in the future.

The future of PHP is bright, what about HHVM? It may continue to live well. Many companies have used HHVM in their websites to improve performance, and the migration between PHP and HHVM does not happen overnight. It took Etsy at least six months. Since the performance of PHP7 is not much better than that of HHVM, those companies are unlikely to rush to switch to PHP.

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

Why is there a competition between HHVM and PHP 7 for online store owners?

As an online store owner, you need to decide whether to use PHP7 or HHVM according to the platform of your online store. If your site is created in WorldPress, then you can look at the latest version of HHVM and PHP 7 benchmark results, from the test results can see the difference in performance between the two, and then you can choose a solution to minimize page load time, server response time and CPU usage.

Reasons for choosing HHVM

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

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

HHVM developers are steadily increasing the amount of PHP code this engine can run, and it can already run the latest version of WorldPress, as well as other common PHP frameworks and applications.

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

Reasons for choosing PHP 7

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

You do not need to install HHVM to use PHP 7.

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

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

HHVM vs. PHP 7: make your choice

Don't hesitate too long. Kinsta advises online sites to choose between PHP 7 and HHVM as much as possible and start implementing solutions early to optimize your site's performance. An inefficient website will also damage your reputation, which will be difficult to recover.

At this point, I believe you have a deeper understanding of "what are the advantages of the latest version of PHP 7 vs HHVM". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report