PHP 7 vs HHVM 比较 已翻译 100%

oschina 投递于 2015/10/10 11:59 (共 9 段, 翻译完成于 10-12)
阅读 23131
收藏 54
4
加载中

PHP is one of the most popular scripting languages used for web development. The latest version of PHP, PHP 7 is a new version of the language that is been optimized for fast performance. However, PHP has a rival in HHVM (HipHop Virtual Machine) — a virtual tool that executes PHP code. The competition between these two options is heating up, so let’s take a look at the performance that each can offer.

What is HHVM?

In 2008, Facebook started working on a tool to convert PHP script into C++ so it could be compiled and executed on web servers. The aim was to conserve server resources, an important goal, as Facebook’s user base was growing rapidly. In this sense, the project was a success; it allowed the server to accommodate between five and six times more traffic than it had managed before.

已有 2 人翻译此段
我来翻译

Fast-forward a couple years to 2010. Facebook’s server needs had grown even more, placing it in a position to require another innovation to allow it to operate more efficiently. In response to this demand, Facebook developed the HipHop Virtual Machine (HHVM).

HHVM uses Just-In-Time (JIT) compilation to convert PHP code into a type of bytecode. It then converts this bytecode into machine code and optimizes it so that it runs as quickly as possible.

What is PHP 7?

PHP 7 is the PHP community’s response to HHVM. Early announcements of the launch of PHP 7 claimed that it would offer better than 100 percent performance improvements over the previous version of the language, PHP 5.

已有 1 人翻译此段
我来翻译

You might be wondering why PHP skipped version 6. The answer is that development on PHP 6 began in 2005, but it went on so long and ran into so many problems that PHP 6 had developed a bad reputation long before it was ready for release. As a result, the PHP community decided to skip the name PHP 6 and go straight to PHP 7 for the new working version of the language.

The real question is not how PHP 7 compares to PHP 5, as it is pretty clear that PHP 7 offers speedier performance. Instead, the consideration is how PHP 7 compares to HHVM. Many experts have conducted tests on the two ways of handling PHP code, which have revealed some interesting results.

已有 1 人翻译此段
我来翻译

PHP 7 vs. HHVM: Similarities and Differences

Before answering the “which is better” question, let’s take a look at the key differences between PHP 7 and HHVM, as well as the ways in which they are similar.

Code Interpretation

The fundamental difference between PHP 7 and HHVM is the way in which each one interprets PHP code. PHP 7 uses the standard PHP interpreter, free software that is available for anyone to use, to directly interpret and execute PHP code on the server. This generates HTML code, which is then sent to the client. The client then displays the desired content to the web user.

In contrast, the Hip Hop Virtual Machine first converts PHP code into HipHop bytecode. This code is then translated into machine code and executed. Some optimization takes place during this translation, ironing out inefficiencies in PHP code with the aim of delivering faster performance.

已有 1 人翻译此段
我来翻译

Writing Code

Both the PHP interpreter and HHVM take PHP code and execute it. Therefore, the process of writing the code is pretty much the same in each case. However, if you want to use HHVM, you need to install it on your server and then call it using the hhvm command on the command line.

Benchmark Testing

HHVM has offered much faster performance than previous versions of PHP. However, recent benchmark tests suggest that PHP 7 is slightly faster than HHVM, at least in some situations. Let’s take a look at the results of some benchmark testingconducted by Kinsta.

  • WordPress: Running on WordPress 4.1.1, PHP 7 allows more than twice as many requests to be executed per second as PHP 5.6. However, it still doesn’t process quite as many as HHVM 3.6.1, which executed 624 requests per second in the test compared to just 604 executed each second by PHP 7.

  • Drupal: PHP 7 offers a distinct advantage over HHVM for Drupal users. PHP 7 can handle 37 percent more server requests per second compared to HHVM on Drupal 8.

已有 1 人翻译此段
我来翻译

Which Companies Use HHVM?

In addition to Facebook, which developed HHVM, many other businesses have adopted this solution to running PHP applications on their own servers. These include Wikimedia and the e-commerce site Etsy.

  • Wikimedia: Wikimedia hosts a huge range of educational content, including the famous Wikipedia online encyclopedia. Attracting nearly half a billion Internet users each month, Wikimedia needs to optimize server performance to cope with its high level of demand. HHVM poses a significant advantage over PHP in that it can load multiple SPU cores simultaneously whereas PHP is a single-threaded language that can’t be parallelized. According to Wikimedia, deploying HHVM shrank CPU load from 50 to just 10 percent, halved the mean time taken to respond to users submitting edits and reduced the average page load time from 1.3 seconds to just 0.9 seconds.

  • Etsy: With 54 million users, Etsy’s servers also face significant demands. Etsy engineers compared HHVM to PHP 5.4 and found that HHVM could cope with up to 280 server requests per second whereas the response time of PHP 5.4 started to dramatically increase once the number of requests grew beyond 190 per second.

已有 1 人翻译此段
我来翻译

What Does the Future Hold for PHP 7 and HHVM?

PHP 7 is due for stable release in November 2015. Therefore, companies are not yet using the new language, but promising benchmark test results of the performance of the beta version of PHP 7 could tempt more companies to adopt the new version of the language.

The future looks bright for PHP 7, but what about HHVM? It is likely that it is far from dead. Many businesses are already using HHVM to increase performance on their sites. The transition between PHP and HHVM is not instantaneous. It took Etsy more than six months to complete the transition. With the speed benefits of PHP 7 compared to HHVM being only very slight, it is unlikely that businesses will rush to switch back to PHP.

Facebook is continuing to develop HHVM. It has recently announced support for Mac OS X, making the technology accessible for developers who prefer to work in the Apple development environment. HHVM developers are convinced thatHHVM is still faster than PHP 7 in many situations, including with WordPress.

已有 2 人翻译此段
我来翻译

Why Does the HHVM vs. PHP 7 Competition Matter to PHP Shop Owners?

As an online store owner, you need to make your decision on whether to use PHP 7 or HHVM based on the platform that hosts your shop. For example, if your site is built using WordPress, take a look at benchmark tests for HHVM and PHP 7 to find out how the latest release of each one performs. You want to choose the solution that can offer the biggest reduction in page load times, server response times and CPU usage.

Reasons to Choose HHVM

  • HHVM uses dynamic translation to deliver faster performance in many situations, including on WordPress.

  • HHVM uses less memory to process each request in cases where it faces a very large number of requests.

  • HHVM developers are steadily increasing the number of PHP code bases that the engine can run. It can already run the latest version of WordPress, along with many other common PHP frameworks and applications.

  • HHVM is open source. Even though HHVM has been developed by Facebook, it is open source, which means the source code is available to anyone who wants to use or alter it.

已有 1 人翻译此段
我来翻译

Reasons to Choose PHP 7

  • PHP 7 performs faster than HHVM in some situations, including when running on Drupal 8.

  • Using PHP 7 doesn’t require you to install or setup HHVM.

  • Code written in PHP 5 should work as expected after a transition to PHP 7, although some features of PHP 4 code are no longer supported in the new release. In practice, this means that any code created in the last decade is probably ready for the transition to PHP 7.

  • PHP 7 is developed by the PHP community, a group with a long-standing reputation for creating stable and reliable PHP releases.

HHVM vs. PHP 7: Make Your Choice

Don’t agonize for too long over the decision. Kinsta recommends that online businesses choose quickly between PHP 7 and HHVM. The sooner you make your decision, the sooner you can begin to implement the solution, allowing you to optimize your website performance. A poorly performing website can cause your reputation to suffer, which can be difficult to reverse.

Both HHVM and PHP 7 offer significant benefits compared to older versions of PHP. Make your choice and start the process of switching your site to the new system as soon as possible.

已有 1 人翻译此段
我来翻译
本文中的所有译文仅用于学习和交流目的,转载请务必注明文章译者、出处、和本文链接。
我们的翻译工作遵照 CC 协议,如果我们的工作有侵犯到您的权益,请及时联系我们。
加载中

评论(53)

yambo
yambo
支持php7,感觉hhvm有点耍小聪明
轻歌
轻歌
為毛我想起了迅雷5跳到迅雷7的事……
s
silver-申
真不错!!
阿水plus
阿水plus

引用来自“剑心”的评论

这有毛线好比较的,7出来hhvm必死无疑
+1024
Adam_OuYang
Adam_OuYang
太優秀了!
剑心
剑心
这有毛线好比较的,7出来hhvm必死无疑
walkskyer
walkskyer

引用来自“润群”的评论

是时候该大喊一句了
php是世界上最好的语言没有之一!哈哈……
宏哥
宏哥

引用来自“封心”的评论

没用过hhvm,谁给科普一下,从hhvm换到php 或者从php换到hhvm 很费事吗?

引用来自“eechen”的评论

HHVM是一个包含多个线程的单进程服务,它不像PHP-FPM有1个主进程和多个工作进程(Nginx也是这种进程模型),也就是说HHVM因为线程问题发生崩溃或僵死时无法自动恢复,而PHP-FPM的主进程却可以重启工作进程. 百度转HHVM遇到的问题:崩溃/内存泄露/兼容性/死锁/性能(JIT热身/没有触发JIT). http://lamp.baidu.com/2014/11/04/hhvm-in-baidu/

引用来自“宏哥”的评论

你这么空, 能不能帮忙把 bcompiler 升级一下,支持php5.6以及以上版本

引用来自“Risol”的评论

宏哥你最可爱了, 哈哈哈哈哈哈

引用来自“春天花不开”的评论

哈哈

引用来自“隐形人”的评论

bcompiler是什么
是php的编译器, 把php编译成bycode, 和python, lua的bycode想类似
kinosang
kinosang
为什么 HHVM 和 PHP 7 对于网店老板存在竞争关系?

这一节,我总感觉是把 Website 当做 Webstore 翻译了……
eechen
eechen

引用来自“隐形人”的评论

php7 相比较php5 为何性能会提升将近一倍 这是我好奇的地方
PHP7并没有引入JIT,PHP7的性能提升在于采用了更好的内存结构,比如在栈上为zval分配内存取代PHP5在堆上分配, 直接操作zval取代PHP5用(二级)指针操作,减少了内存分配循环. PHP7执行WordPress使用的CPU指令数约为PHP5的1/4,计算密集型的bench.php的CPU指令数也能减少一半以上. http://rango.swoole.com/archives/440
返回顶部
顶部
返回顶部
顶部