hhvm

Only a few months ago, HHVM (HipHop Virtual Machine) was a popular buzzword in the PHP community. Many of us were curious about this technology, especially the reports of improved performance. Previously, Zend’s PHP was the only alternative — until Facebook introduced HHVM to the world.

仅在几个月前, HHVM(HipHop虚拟机)在PHP社区中是一个流行的流行词。 我们许多人对此技术感到好奇,特别是有关性能提高的报道。 以前,ZendPHP是唯一的选择-直到Facebook将HHVM推向世界为止。

Good news, HHVM is no longer a buzzword. Many people (including myself) dislike hyped up technologies, but I’m happy to write this as a post-buzzword article.

好消息,HHVM不再是流行语。 许多人(包括我自己)不喜欢大肆宣传技术,但我很高兴将其写成流行语后的文章。

So let’s dive in!

因此,让我们开始吧!

In this article, I’ll cover:

在本文中,我将介绍:

  1. What is HHVM?什么是HHVM?
  2. What is Hack?什么是哈克?
  3. What is the difference compared with traditional PHP?与传统PHP相比有什么区别?
  4. Why is it so important that it exists today (or maybe not)?为什么它今天(或可能不存在)如此重要?
  5. What are some benchmarks to see how HHVM differs from PHP 5 and PHP 7?有哪些基准可以查看HHVM与PHP 5和PHP 7有何不同?

什么是HHVM? (What is HHVM?)

To understand what HHVM is, we first need to cover what Zend Engine is (currently we’re at version 3 with PHP 7). The best explanation on this can be found on this Wikipedia article:

要了解什么是HHVM,我们首先需要介绍什么是Zend Engine(当前是PHP 7的第3版)。 对此的最佳解释可以在以下Wikipedia文章中找到:

The Zend Engine is the open source scripting engine that interprets the PHP programming language. It was originally developed by Andi Gutmans and Zeev Suraski while they were students at the Technion – Israel Institute of Technology. They later founded a company called Zend Technologies in Ramat Gan, Israel. The name Zend is a combination of their forenames, Zeev and Andi.

Zend Engine是一种开放源代码脚本引擎,用于解释PHP编程语言。 它最初是由Andi Gutmans和Zeev Suraski在以色列理工学院学习时开发的。 他们后来在以色列拉马特甘(Ramat Gan)成立了一家名为Zend Technologies的公司。 Zend这个名字是Zeev和Andi的名字的结合。

Is it the language or an interpreter? It’s a ongoing debate with every scripting language. However, let’s say that PHP the language, is abstract, it’s a blueprint for the interpreter (parser). It’s more of a philosophical debate than a real debate. HHVM is like Zend Engine, but it takes a different approach to parse and run the source code.

是语言还是口译员? 对于每种脚本语言,这都是一个持续的辩论。 但是,假设PHP语言是抽象的,它是解释器(解析器)的蓝图。 与其说是一场真正的辩论,不如说是一场哲学辩论。 HHVM类似于Zend Engine,但是它采用了不同的方法来解析和运行源代码。

In the end both interpreters/parsers can (in theory) execute the same source code and provide the same output with the same side effects. HHVM takes a different approach. The team behind HHVM describes it as a Virtual Machine that uses JIT (just in time) compilation to gain more speed and flexibility than Zend’s way.

最后,两个解释器/解析器都可以(理论上)执行相同的源代码,并提供具有相同副作用的相同输出。 HHVM采用不同的方法。 HHVM背后的团队将其描述为一个虚拟机,它使用JIT (及时)编译来获得比Zend方式更快的速度和灵活性。

One more reason to consider HHVM is speed. Until PHP 5.* benchmarks were on HHVM’s side. I know that benchmarks are also a debated topic, but when done right, they can show some truth. Long story short, HHVM appeared superior to PHP but not as much after PHP 7. The gap started to become more blurry when PHP 7 came out. So that’s why we’ll run some benchmarks today comparing them.

考虑HHVM的另一个原因是速度。 直到PHP 5. *基准测试才支持HHVM。 我知道基准测试也是一个有争议的话题,但是如果做得正确,它们可以表明一些事实。 长话短说,HHVM似乎优于PHP,但在PHP 7之后却没有。 因此,我们今天将运行一些基准进行比较。

HHVM is still a new, cool, and different technology than Zend. It’s totally different from a technical perspective. Some things start as an experiment and may be part of a daily toolbox for some developers. Did I mention that it’s baked from Facebook and that they also use it in production (although not sure which parts of Facebook). HHVM was built from a real problem that Facebook had – speed (plus some other complicated problems that most developers might never run into).

与Zend相比,HHVM仍然是一种新的,酷的和不同的技术。 从技术角度来看,这是完全不同的。 有些事情是作为实验开始的,对于某些开发人员来说可能是日常工具箱的一部分。 我是否提到过它是从Facebook烘焙而来的,而且他们还在生产中使用它(尽管不确定Facebook的哪个部分)。 HHVM是基于Facebook的一个实际问题-速度(以及大多数开发人员可能从未遇到过的一些其他复杂问题)构建的。

HHVM also supports Hack. Hack is a programming language for HHVM. However, isn’t PHP the language that HHVM parses? Yes, but there’s also Hack. Basically Hack is PHP plus some other features that are not currently part of PHP or not planned in the near future. So when you write PHP, HHVM can parse and execute it, but you can also use Hack which is PHP with some additional stuff. It’s your choice. But don’t forget that Hack is not 100% compatible with PHP. The specific Hack features don’t work on Zend Engine, they only work on HHVM.

HHVM还支持Hack 。 Hack是HHVM的编程语言。 但是,PHP不是HHVM解析的语言吗? 是的,但也有Hack。 基本上,Hack是PHP加上一些其他功能,这些功能目前尚不属于PHP或在不久的将来未计划。 因此,当您编写PHP时,HHVM可以解析并执行它,但是您也可以使用带有PHP的Hack PHP。 这是你的选择。 但是请不要忘记,Hack与PHP并非100%兼容。 特定的Hack功能在Zend Engine上不起作用,它们仅在HHVM上起作用。

在Docker上设置HHVM和WordPress (Setting up HHVM and WordPress on Docker)

I didn’t want to make the whole article on just my setup, so that’s why I created WP_Dock (WordPress + Docker). If you want to know more on Docker and WordPress make sure to read these articles:

我不想只根据设置来撰写整篇文章,所以这就是为什么我创建了WP_Dock (WordPress + Docker)。 如果您想进一步了解Docker和WordPress,请务必阅读以下文章:

  • Introduction to Docker for WordPress Developers

    WordPress开发人员Docker简介

  • How to Manually Build Docker Containers for WordPress

    如何手动为WordPress构建Docker容器

  • How to Use the Official Docker WordPress Image

    如何使用官方Docker WordPress映像

  • Deploying WordPress with Docker

    使用Docker部署WordPress

You can choose to install everything on your OS, but using Docker makes it easier for everyone to install on every OS. It also removes the need to install PHP, HHVM, nginx or MySQL on your desktop OS. That being said, you can follow HHVM’s own tutorial on how to install both HHVM and WordPress if you’d prefer.

您可以选择在操作系统上安装所有内容,但是使用Docker可以使每个人都更容易在每个操作系统上进行安装。 它还消除了在台式机操作系统上安装PHP,HHVM,nginx或MySQL的需要。 话虽如此,如果您愿意的话,可以按照HHVM自己的教程安装HHVM和WordPress 。

First you have to download the Docker Toolbox if you haven’t already. Then download or clone this project.

首先,您必须下载Docker Toolbox(如果尚未安装)。 然后下载或克隆此项目。

git clone https://github.com/AleksanderKoko/WP_Dock wpdock

Download WordPress, copy it inside the folder and rename it to ‘app’. Navigate to inside the Docker folder, cd wpdock/docker.

下载WordPress,将其复制到文件夹中,然后将其重命名为“ app”。 导航至Docker文件夹cd wpdock/docker

By default, nginx runs php-fpm, so you’ll have to change this. On ‘docker-compose.yml’ change nginx ‘links‘ to ‘hhvm‘. It should look something like this:

默认情况下,nginx运行php-fpm,因此您必须更改它。 在“ docker-compose.yml ”改变nginx的“ links ”到“ hhvm ”。 它看起来应该像这样:

nginx:
build: ./nginx
volumes:
- ./../storage/logs/nginx:/var/log/nginx
- ./../app:/var/www/app
ports:
- "80:80"
- "443:443"
links:
- hhvm

Also in docker/nginx/config/upstream.conf change ‘php‘ to ‘hhvm‘. It should look like this:

同样在docker/nginx/config/upstream.conf hhvm ' php '更改为' hhvm '。 它看起来应该像这样:

upstream fastcgi-upstream { server hhvm:9000; }

Then execute docker-compose up -d nginx. This builds Docker containers using ‘docker-compose.yml’ as its configuration. Now you’ll know on which IP your containers can be found, make a note of that for the next step.

然后执行docker-compose up -d nginx 。 这将使用“ docker-compose.yml”作为配置来构建Docker容器。 现在,您将知道可以在哪个IP上找到您的容器,记下下一步。

docker-machine ip default

Now open your browser to the IP noted above and you’ll see the WordPress installation guide. The final step is to change the WordPress database configuration. By default, the credentials are specified in docker-compose.yml. If you look at the MySQL section you’ll see:

现在,将浏览器打开到上述IP,您将看到WordPress安装指南。 最后一步是更改WordPress数据库配置。 默认情况下,凭据在docker-compose.yml中指定。 如果查看MySQL部分,您将看到:

mysql:
build: ./mysql
volumes:
- ./../storage/data/mysql:/var/lib/mysql
- ./../storage/logs/mysql:/var/log/mysql
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: databasename
MYSQL_USER: username
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: root

If you want to change the database name, username and password, change these values and then:

如果要更改数据库名称,用户名和密码,请更改以下值,然后:

docker-compose down
docker-compose up -d --build nginx

Note: the MySQL host should be the IP of the machine. The one that you used on the browser to see the WordPress installation.

注意:MySQL主机应该是机器的IP。 您在浏览器上用来查看WordPress安装的那个。

To switch back to PHP first run docker-compose down then change the configuration back to PHP. So remove ‘hhvm‘ as nginx link and add ‘PHP‘. Also update docker/nginx/configuration/upstream.conf to:

要切换回PHP,请先运行docker-compose down然后将配置更改回PHP。 因此,删除“ hhvm ”作为nginx link并添加“ PHP ”。 还要将docker/nginx/configuration/upstream.conf更新为:

upstream fastcgi-upstream { server php:9000; }

Execute docker-compose up -d --build nginx to use PHP instead.

执行docker-compose up -d --build nginx改为使用PHP。

HHVM + WordPress与PHP 7 + WordPress (HHVM + WordPress Versus PHP 7 + WordPress)

Now for the benchmark, these are the rules. I’ll use the base containers as they are. HHVM can also be used stand alone but I used it as fpm to make the comparison. I know that both can be configured to be more optimized but that is an article for another day. As HHVM needs a warm up to be at its full potential, I should make some requests first, for the HHVM to compile its stuff (we’ll do the same for PHP to make things more even). For the benchmark we’ll use Apache Bench (ab). Check their docs for installation or how to use it if you want to run benchmarks on your machine. Also, Bruno Skvorc has an excellent article on Apache Bench to help get you started.

现在作为基准,这些是规则。 我将按原样使用基本容器。 HHVM也可以单独使用,但我将其用作fpm进行比较。 我知道两者都可以配置为更优化,但这是另一天的文章。 由于HHVM需要充分发挥其潜力,因此我应该首先提出一些要求,以使HHVM编译其内容(我们将对PHP进行同样的处理,以使事情更加均匀)。 对于基准测试,我们将使用Apache Bench (ab)。 如果要在计算机上运行基准测试,请检查其文档以进行安装或使用方法。 另外,Bruno Skvorc 在Apache Bench上有一篇出色的文章,可以帮助您入门。

My bench command is: ab -n 500 -c 100 http://192.168.99.100. In total there are 500 requests with 100 concurrent requests.

我的基准命令是: ab -n 500 -c 100 http://192.168.99.100 。 总共有500个请求和100个并发请求。

PHP结果 (The PHP Results)

HHVM结果 (The HHVM Results)

79 seconds vs 18 seconds sounds like a big promise, even if 79 seconds is PHP 7. But I have to admit that I haven’t optimized PHP or HHVM. Maybe HHVM is more speedy out of the box, so don’t take my word for granted – take it with a grain of salt, test it yourself. In the real world PHP 7 may be even faster than HHVM.

即使79秒是PHP 7,79秒vs 18秒听起来也很有希望。但是我必须承认我没有优化PHP或HHVM。 也许HHVM开箱即用的速度更快,所以不要认为我的话是理所当然的-随便拿一点盐,自己进行测试。 在现实世界中,PHP 7甚至可能比HHVM更快。

最后提示 (Some Final Tips)

HHVM seems like a cool technology (that’s why I packed it on Docker). However, I have to warn you, use it with caution. Zend Engine is a mature, battle-tested tool. PHP in general is battle tested, and doesn’t suffer from hype. That doesn’t mean that you can’t experiment with it. That isn’t the only problem. With WordPress many plugins and themes may not work with HHVM. They were built on PHP, and HHVM is not 100% compatible with PHP.

HHVM似乎是一项很酷的技术(这就是为什么我将其打包在Docker上的原因)。 但是,我必须警告您,请谨慎使用。 Zend Engine是一种经过考验的成熟工具。 一般而言,PHP经过了实战测试,并且不会遭受炒作。 这并不意味着您不能尝试它。 那不是唯一的问题。 使用WordPress,许多插件和主题可能不适用于HHVM。 它们基于PHP构建,并且HHVM与PHP并非100%兼容。

结论 (Conclusion)

In this article, we saw what HHVM is and how to setup WordPress with HHVM.

在本文中,我们了解了HHVM是什么以及如何使用HHVM设置WordPress。

I see HHVM as a positive move from Facebook, not only from the Open Source perspective. In this new age of web where every language is jumping on the server-side train, competition rises. It’s not necessary to increase fragmentation, but it makes the whole scene different and innovative.

我认为HHVM是Facebook的积极举措,不仅是从开源角度而言。 在网络的新时代中,每种语言都在服务器端运行,竞争日益激烈。 不必增加碎片,但它会使整个场景变得不同且具有创新性。

PHP itself has borrowed many things from Java, or Laravel from Ruby on Rails. Except being cool, fast and with new approach, the team behind HHVM has also pushed the team behind Zend Engine to become even better. PHP 7 was one of the best updates to hit the PHP community. As PHP itself is so coupled with Zend, competition from other teams, is a good thing. Also, a few may know that HHVM is not the only Virtual Machine in the game. Tagua VM is a new VM written with Rust. Also, their approach is different, where the main idea was to be memory safe.

PHP本身从Java借来了很多东西,或者从Ruby on Rails借来了Laravel。 除了装酷 ,速度快,有新的方法,后面HHVM球队也把背后Zend引擎球队变得更好。 PHP 7是影响PHP社区的最佳更新之一。 由于PHP本身与Zend结合在一起,因此来自其他团队的竞争是一件好事。 另外,可能有人知道HHVM不是游戏中唯一的虚拟机。 Tagua VM是用Rust编写的新VM。 同样,他们的方法也不同,其主要思想是保护内存。

Being curious, experimenting and production are different most of the time. However, if it happened that you’ve tried HHVM yourself, I want to hear from you. What are your experiences with HHVM? Have you tried to benchmark it on a real site? What (if any) problems have occurred?

好奇,实验和制作在大多数时候都是不同的。 但是,如果碰巧您自己尝试过HHVM,我希望收到您的来信。 您对HHVM有什么经验? 您是否尝试过在真实网站上进行基准测试? 发生了什么(如果有)问题?

翻译自: https://www.sitepoint.com/hhvm-and-wordpress/

hhvm

hhvm_HHVM和WordPress入门相关推荐

  1. wordpress入门基本操作,网站安全防护及常用插件(建站必看教程)

    关于WordPress网站如何搭建,大家可以看我之前的文章. 链接:阿里云服务器快速部署网站教程 本篇文章主要讲WordPress的入门基本操作,以及网站安全防护和常用的插件等. WordPress基 ...

  2. wordpress入门主题_设置和运行WordPress网站的终极入门指南

    wordpress入门主题 So you've decided to run a WordPress site but have no idea where to start? This tutori ...

  3. WordPress入门

    WordPress 入门教程 原文发表在 http://www.imaiko.com/course/?p=1144 欢迎访问原文,更多更新和讨论. 使用指南 您可以免费使用本指南 禁止销售本指南 禁止 ...

  4. wordpress入门-wordpress入门一键建站免费插件配置教程

    wordpress入门?wordprss怎么入门怎么快速搭建一个网站,并且做好SEO优化.今天就给大家推荐一款 wordpress全套工具,一键建站+SEO内容优化. 各种主题功能插件等等最全word ...

  5. wordpress入门主题_WordPress区块编辑器中的封面图片与精选图片(入门指南)

    wordpress入门主题 WordPress 5.0 was released with the brand new Gutenberg block editor and a host of coo ...

  6. WordPress建站详细流程,WordPress入门

    在安装WordPress之前,先看看服务器及本地软硬件是否满足安装要求. 服务器端要求 PHP 7.3或更高版本 MySQL 5.6或MariaDB 10.1或更高版本 Apache或Nginx 本地 ...

  7. WordPress入门【四、主题】

    WordPress支持用户自由选择喜爱的主题和插件.在这一篇里,我们一起来看看如何管理主题和吧~ 主题 众所周知,WordPress在自定义上给了用户非常大的选择自由,有成千上万的主题供我们使用. 首 ...

  8. WordPress 入门教程

    http://www.wpdaxue.com/series/wordpress-start http://ninghao.net/course/618 1. 用XAMPP来搭建Wordpress建站环 ...

  9. wordpress如何配置两个header。php_WordPress入门|WordPress建站详细流程

    在安装WordPress之前,先看看服务器及本地软硬件是否满足安装要求. 服务器端要求 PHP 7.3或更高版本 MySQL 5.6或MariaDB 10.1或更高版本 Apache或Nginx 本地 ...

最新文章

  1. python的re.findall()函数中的括号问题
  2. Redis未授权访问漏洞记录(端口:6379)
  3. Pycharm常见问题
  4. hdu 5964:平行四边形 【计算几何】
  5. Linux基础命令及其常识
  6. 语法树,短语,直接短语,句柄
  7. 上门洗车APP --- Android客户端开发 之 网络框架封装介绍(二)
  8. 对接阿里云的短信接口发送手机验证码
  9. 阿里云播放器AliyunPlayer的走马灯组件的位置
  10. R语言——ggplot2的绘图逻辑
  11. [反汇编练习] 160个CrackMe之024
  12. 巧妙复制网页中的文本——复制网页上不能复制的文字
  13. sfu计算机科学排名世界,QS世界高校排行榜出炉,UBC/SFU的世界排名+排名前五专业一览...
  14. uni-app 最简单的显示隐藏
  15. 找工作笔试面试那些事儿(15)---互联网公司面试的零零种种和多家经验
  16. Mysql-查询指定表中的所有字段名称
  17. 安装Carthage
  18. 如果装完柜还剩很多空间,该怎么办?
  19. sj时间戳转成年月日
  20. orcad中的Net Alias应该怎么使用,与Wire有什么区别?

热门文章

  1. 01背包 java代码_01背包问题JAVA实现
  2. php move_uploaded_file liunx,php move_uploaded_file()上传文件实例及遇到问题的解决方法...
  3. 还在用ps?超好用的在线图片处理软件分享给你
  4. itchat实现命令行聊天+记录聊天图片/表情
  5. code visual 笔记共享_VScode编辑同步Markdown文档到印象笔记
  6. android studio2.0去除运行按钮旁边闪电标志的方法
  7. [Unity]Project视图收藏夹、缩放视图不见
  8. linux部署项目(Java项目+Tomcat+mysql)
  9. 阿里大文娱正式加入短视频竞争,一石二鸟
  10. 最全前端性能优化总结