Skip to content

Commit

Permalink
Adds the use of HHVM as an option in the web-serving benchmark (parsa…
Browse files Browse the repository at this point in the history
…-epfl#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
  • Loading branch information
Hnefi authored Jan 31, 2019
1 parent 03f35fa commit 85057d7
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 9 deletions.
16 changes: 13 additions & 3 deletions benchmarks/web-serving/web_server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@ LABEL maintainer="Mark Sutherland <[email protected]>"

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/
Expand All @@ -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

Expand All @@ -41,3 +50,4 @@ RUN chmod 700 /etc/bootstrap.sh
EXPOSE 8080

CMD ["/etc/bootstrap.sh", "-d"]

16 changes: 11 additions & 5 deletions benchmarks/web-serving/web_server/bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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

9 changes: 9 additions & 0 deletions benchmarks/web-serving/web_server/files/configure_hhvm.sh
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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;
#}
}
8 changes: 7 additions & 1 deletion docs/benchmarks/web-serving.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit 85057d7

Please sign in to comment.