From 85057d7723a91142a29d0d0e77497fea635d52e6 Mon Sep 17 00:00:00 2001 From: Mark Sutherland Date: Thu, 31 Jan 2019 16:58:57 +0100 Subject: [PATCH] Adds the use of HHVM as an option in the web-serving benchmark (#209) * Integrated HHVM as a configurable option to the web-serving application. The following command will start the web server(without HHVM): $ docker run -dt --net=host --name=web_server cloudsuite/web-serving:web_server /etc/bootstrap.sh ${DATABASE_SERVER_IP} ${MEMCACHED_SERVER_IP} ${MAX_PM_CHILDREN} The following command will start the web server (with HHVM enabled): docker run -e "HHVM=true" -dt --net=host --name=web_server_local cloudsuite/web-serving:web_server /etc/bootstrap.sh ${DATABASE_SERVER_IP} ${MEMCACHED_SERVER_IP} ${MAX_PM_CHILDREN} * Updates documentation for using HHVM --- benchmarks/web-serving/web_server/Dockerfile | 16 +++++-- .../web-serving/web_server/bootstrap.sh | 16 ++++--- .../web_server/files/configure_hhvm.sh | 9 ++++ .../files/nginx_sites_avail_hhvm.append | 44 +++++++++++++++++++ docs/benchmarks/web-serving.md | 8 +++- 5 files changed, 84 insertions(+), 9 deletions(-) create mode 100644 benchmarks/web-serving/web_server/files/configure_hhvm.sh create mode 100644 benchmarks/web-serving/web_server/files/nginx_sites_avail_hhvm.append diff --git a/benchmarks/web-serving/web_server/Dockerfile b/benchmarks/web-serving/web_server/Dockerfile index 27413215c..3b08ef119 100644 --- a/benchmarks/web-serving/web_server/Dockerfile +++ b/benchmarks/web-serving/web_server/Dockerfile @@ -3,13 +3,19 @@ LABEL maintainer="Mark Sutherland " USER root -RUN apt-get update && apt-get install -y \ +RUN apt-get update && \ + apt-get install -y --force-yes software-properties-common && \ + apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449 && \ + add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main" && \ + apt-get update && \ + apt-get install --force-yes -y \ build-essential \ git \ nginx \ php5 php5-gd \ php5-mysql php5-curl \ - php5-fpm php5-memcache + php5-fpm php5-memcache \ + hhvm # Increase the open file limit COPY files/limits.conf.append /tmp/ @@ -28,7 +34,10 @@ RUN chmod a+rw /elgg_data # Copy over the Nginx Server configuration COPY files/nginx_sites_avail.append /tmp/ -RUN cat /tmp/nginx_sites_avail.append >> /etc/nginx/sites-available/default + +# Copy over the Nginx HHVM Server configuration +COPY files/nginx_sites_avail_hhvm.append /tmp/ +COPY files/configure_hhvm.sh /tmp/ RUN service nginx restart @@ -41,3 +50,4 @@ RUN chmod 700 /etc/bootstrap.sh EXPOSE 8080 CMD ["/etc/bootstrap.sh", "-d"] + diff --git a/benchmarks/web-serving/web_server/bootstrap.sh b/benchmarks/web-serving/web_server/bootstrap.sh index 067c2e58d..d7841578e 100755 --- a/benchmarks/web-serving/web_server/bootstrap.sh +++ b/benchmarks/web-serving/web_server/bootstrap.sh @@ -1,15 +1,21 @@ #!/bin/bash - - DB_SERVER_IP=${1:-"mysql_server"} MEMCACHE_SERVER_IP=${2:-"memcache_server"} sed -i -e"s/mysql_server/${DB_SERVER_IP}/" elgg/engine/settings.php sed -i -e"s/'memcache_server'/'${MEMCACHE_SERVER_IP}'/" elgg/engine/settings.php -FPM_CHILDREN=${3:-80} -sed -i -e"s/pm.max_children = 5/pm.max_children = ${FPM_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf +if [[ ! -z "${HHVM}" && "${HHVM}" = "true" ]]; then + chmod 700 /tmp/configure_hhvm.sh + /tmp/configure_hhvm.sh +else + cat /tmp/nginx_sites_avail.append >> /etc/nginx/sites-available/default + FPM_CHILDREN=${3:-80} + sed -i -e"s/pm.max_children = 5/pm.max_children = ${FPM_CHILDREN}/" /etc/php5/fpm/pool.d/www.conf + + service php5-fpm restart +fi -service php5-fpm restart service nginx restart bash + diff --git a/benchmarks/web-serving/web_server/files/configure_hhvm.sh b/benchmarks/web-serving/web_server/files/configure_hhvm.sh new file mode 100644 index 000000000..758e20ba3 --- /dev/null +++ b/benchmarks/web-serving/web_server/files/configure_hhvm.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +update-rc.d hhvm defaults +cat /etc/nginx/sites-enabled/default ~/nginx_backup +cat /tmp/nginx_sites_avail_hhvm.append >> /etc/nginx/sites-available/default +/usr/share/hhvm/install_fastcgi.sh +echo "hhvm.server.allow_run_as_root = true" >> /etc/hhvm/server.ini +/usr/bin/hhvm --config /etc/hhvm/php.ini --config /etc/hhvm/server.ini --mode daemon -vPidFile=/var/run/hhvm/pid + diff --git a/benchmarks/web-serving/web_server/files/nginx_sites_avail_hhvm.append b/benchmarks/web-serving/web_server/files/nginx_sites_avail_hhvm.append new file mode 100644 index 000000000..d8bf34a1f --- /dev/null +++ b/benchmarks/web-serving/web_server/files/nginx_sites_avail_hhvm.append @@ -0,0 +1,44 @@ +server { + listen 8080; + server_name localhost; + listen [::]:8080 default_server ipv6only=on; + + root /usr/share/nginx/html/elgg; + # Server root, replace it with your elgg installation location + index index.php index.html index.htm; + + # Server logs, replace it with your project names + error_log /var/log/nginx/example_error.log; + access_log /var/log/nginx/example_access.log; + + location ~ (^\.|/\.) { + return 403; + } + + location /cache { + rewrite ^/cache\/(.*)$ /engine/handlers/cache_handler.php?request=$1&$query_string; + } + + location /export { + rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/?$ /engine/handlers/export_handler.php?view=$1&guid=$2; + rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ /engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4; + } + + location = /rewrite.php { + rewrite ^(.*)$ /install.php; + } + + location / { + try_files $uri $uri/ /index.php?__elgg_uri=$uri&$query_string; + } + + # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 + # + # location ~ \.(hh|php)$ { + # fastcgi_keep_conn on; + # fastcgi_pass 127.0.0.1:9000; + # fastcgi_index index.php; + # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # include fastcgi_params; + #} + } diff --git a/docs/benchmarks/web-serving.md b/docs/benchmarks/web-serving.md index ec4e4c7d8..9b5d73c8b 100644 --- a/docs/benchmarks/web-serving.md +++ b/docs/benchmarks/web-serving.md @@ -5,6 +5,8 @@ Web Serving is a main service in the cloud. Traditional web services with dynamic and static content are moved into the cloud to provide fault-tolerance and dynamic scalability by bringing up the needed number of servers behind a load balancer. Although many variants of the traditional web stack are used in the cloud (e.g., substituting Apache with other web server software or using other language interpreters in place of PHP), the underlying service architecture remains unchanged. Independent client requests are accepted by a stateless web server process which either directly serves static files from disk or passes the request to a stateless middleware script, written in a high-level interpreted or byte-code compiled language, which is then responsible for producing dynamic content. All the state information is stored by the middleware in backend databases such as cloud NoSQL data stores or traditional relational SQL servers supported by key-value cache servers to achieve high throughput and low latency. This benchmark includes a social networking engine (Elgg) and a client implemented using the Faban workload generator. +Furthermore, we have recently incorporated Facebook''s HipHop Virtual Machine compiler and runtime for producing JIT-compiled PHP scripts. For more information, you can read about HHVM [here](https://hhvm.com/). + ## Using the benchmark ## The benchmark has four tiers: the web server, the database server, the memcached server, and the clients. The web server runs Elgg and it connects to the memcached server and the database server. The clients send requests to login to the social network. Each tier has its own image which is identified by its tag. @@ -44,10 +46,14 @@ To start the web server, you first have to `pull` the server image. To `pull` th $ docker pull cloudsuite/web-serving:web_server -The following command will start the web server: +To run the web server *without HHVM*, use the following command: $ docker run -dt --net=host --name=web_server cloudsuite/web-serving:web_server /etc/bootstrap.sh ${DATABASE_SERVER_IP} ${MEMCACHED_SERVER_IP} ${MAX_PM_CHILDREN} +To run the web server *with HHVM enabled*, use the following command: + + $ docker run -e "HHVM=true" -dt --net=host --name=web_server_local cloudsuite/web-serving:web_server /etc/bootstrap.sh ${DATABASE_SERVER_IP} ${MEMCACHED_SERVER_IP} ${MAX_PM_CHILDREN} + The three ${DATABASE_SERVER_IP},${MEMCACHED_SERVER_IP}, and ${MAX_PM_CHILDREN} parameters are optional. The ${DATABASE_SERVER_IP}, and ${MEMCACHED_SERVER_IP} show the IP (or the container name) of the database server, and the IP (or the container name) of the memcached server, respectively. For example, if you are running all the containers on the same machine and use the host network you can use the localhost IP (127.0.0.1). Their default values are mysql_server, and memcache_server, respectively, which are the default names of the containers. The ${MAX_PM_CHILDREN} set the pm.max_children in the php-fpm setting. The default value is 80.