
Co to jest HHVM ?
HHVM maszyna wirtualna jest open-source, przeznaczony do wykonywania programów napisanych w Hack i PHP.
HHVM używa (JIT) podejście kompilacji Just-in-time, aby osiągnąć wysoką wydajność przy zachowaniu elastyczności rozwoju, jakie zapewnia PHP.
Instalacje jaką dziś wam pokaże przeprowadzam na systemie Debian 8 z serwerem WWW nginx/1.9.4
Pamiętaj że aby wszystko zadziałało wymagane jest posiadanie poprawnie skonfigurowanego serwera WWW z PHP !!
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 deb http://dl.hhvm.com/debian jessie main | tee /etc/apt/sources.list.d/hhvm.list apt-get update apt-get install hhvm
Jeśli serwer zwraca błędy typu “segmentation fault” zaintsaluj:
apt-get install hhvm-dbg
Wersja Deweloperska
apt-get install hhvm-nightly apt-get install hhvm-nightly-dbg
Po instalacji uruchamiamy skrypt:
/usr/share/hhvm/install_fastcgi.sh
Pobieramy przygotowane przeze mnie pliki konfiguracyjne:
rm /etc/hhvm/*; wget http://pliki.linuxiarz.pl/08-2015/server.ini -O /etc/hhvm/server.ini; wget http://pliki.linuxiarz.pl/08-2015/php.ini -O /etc/hhvm/php.ini
Edytujemy plik VierualHosta w nginx modyfikując lekko lokalizacje socketu z PHP-FPM
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
unix:/var/run/php5-fpm.sock backup;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Włączamy uruchamianie hhvm przy starcie:
update-rc.d hhvm defaults
i uruchamiany hhvm oraz restartujemy nginx:
/etc/init.d/hhvm start /etc/init.d/nginx restart
Test działania:
root@unitraklub:~# curl -I http://www.os.linuxiarz.pl HTTP/1.1 200 OK Server: nginx Content-Type: text/html Connection: keep-alive Keep-Alive: timeout=10 Vary: Accept-Encoding X-Powered-By: HHVM/3.10.0-dev Date: Sat, 29 Aug 2015 16:36:29 GMT X-Page-Speed: Powered by nginx_pagespeed | gru@linuxiarz.pl Cache-Control: max-age=0, no-cache
Wydajność z HHVM:
root@linuxiarz:~# ab -c 1 -n 100 http://unitraklub.pl:80/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking unitraklub.pl (be patient).....done
Server Software: nginx
Server Hostname: unitraklub.pl
Server Port: 80
Document Path: /
Document Length: 81018 bytes
Concurrency Level: 1
Time taken for tests: 35.581 seconds
Complete requests: 100
Failed requests: 98
(Connect: 0, Receive: 0, Length: 98, Exceptions: 0)
Write errors: 0
Total transferred: 8149392 bytes
HTML transferred: 8104292 bytes
Requests per second: 2.81 [#/sec] (mean)
Time per request: 355.807 [ms] (mean)
Time per request: 355.807 [ms] (mean, across all concurrent requests)
Transfer rate: 223.67 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 28 30 3.3 30 61
Processing: 307 326 14.2 321 383
Waiting: 155 174 12.4 171 214
Total: 336 356 14.5 351 412
Percentage of the requests served within a certain time (ms)
50% 351
66% 360
75% 364
80% 367
90% 377
95% 385
98% 392
99% 412
100% 412 (longest request)
Bez HHVM
root@linuxiarz:~# ab -c 1 -n 100 http://unitraklub.pl:80/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking unitraklub.pl (be patient).....done
Server Software: nginx
Server Hostname: unitraklub.pl
Server Port: 80
Document Path: /
Document Length: 81071 bytes
Concurrency Level: 1
Time taken for tests: 39.691 seconds
Complete requests: 100
Failed requests: 97
(Connect: 0, Receive: 0, Length: 97, Exceptions: 0)
Write errors: 0
Total transferred: 8146249 bytes
HTML transferred: 8103849 bytes
Requests per second: 2.52 [#/sec] (mean)
Time per request: 396.915 [ms] (mean)
Time per request: 396.915 [ms] (mean, across all concurrent requests)
Transfer rate: 200.43 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 28 30 0.9 30 34
Processing: 343 367 22.8 361 476
Waiting: 191 215 21.2 208 324
Total: 372 397 22.7 391 504
Percentage of the requests served within a certain time (ms)
50% 391
66% 401
75% 405
80% 411
90% 420
95% 433
98% 498
99% 504
100% 504 (longest request)
Witryna autorów projektu:
http://hhvm.com