Browse Source

Adding RoadRunner and AMP integration (#4155)

* Updating to Hamlet 3.1

* Updating to Hamlet 3.2

* uncomment a line

* Adding RoadRunner engine

* hamlet-amp integration added
vka 6 years ago
parent
commit
7e3f75aec8

+ 7 - 0
frameworks/PHP/hamlet/README.md

@@ -2,6 +2,13 @@
 
 This is the [Hamlet Core](https://github.com/vasily-kartashov/hamlet-core) portion of a [benchmarking test suite](../)
 
+Current submission tests the following configurations:
+
+- Hamlet + PHP FPM
+- Hamlet + ReactPHP
+- Hamlet + RoadRunner
+- Hamlet + Swoole
+
 ## (Some) Documentation
 
 - [Short overview of framework's architecture](https://notes.kartashov.com/2016/07/08/simple-caching-web-framework/)

+ 6 - 0
frameworks/PHP/hamlet/amp.php

@@ -0,0 +1,6 @@
+<?php
+
+require_once __DIR__ . '/vendor/autoload.php';
+
+$application = new \Benchmark\Application;
+\Hamlet\Bootstraps\AmpBootstrap::run(8080, $application);

+ 46 - 0
frameworks/PHP/hamlet/benchmark_config.json

@@ -69,6 +69,52 @@
       "display_name": "hamlet-react",
       "notes": "",
       "versus": "php"
+    },
+    "roadrunner": {
+      "plaintext_url": "/plaintext",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/update?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "mysql",
+      "framework": "hamlet",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "micro",
+      "platform": "None",
+      "webserver": "roadrunner",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "hamlet-roadrunner",
+      "notes": "",
+      "versus": "php"
+    },
+    "amp": {
+      "plaintext_url": "/plaintext",
+      "json_url": "/json",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/update?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "mysql",
+      "framework": "hamlet",
+      "language": "PHP",
+      "flavor": "PHP7",
+      "orm": "micro",
+      "platform": "None",
+      "webserver": "amp",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "hamlet-amp",
+      "notes": "",
+      "versus": "php"
     }
   }]
 }

+ 9 - 1
frameworks/PHP/hamlet/composer.json

@@ -1,9 +1,17 @@
 {
+  "config": {
+    "discard-changes": true
+  },
   "require": {
     "hamlet/hamlet-core" : "^3.2",
     "cache/apcu-adapter": "^1",
     "react/http": "*",
-    "swoft/swoole-ide-helper": "*"
+    "spiral/roadrunner": "*",
+    "swoft/swoole-ide-helper": "*",
+    "amphp/amp": "*",
+    "amphp/http-server": "*",
+    "amphp/http-server-router": "*",
+    "amphp/cluster": "@dev"
   },
   "autoload": {
     "psr-4": {

+ 8 - 0
frameworks/PHP/hamlet/deploy/.rr.yaml

@@ -0,0 +1,8 @@
+http:
+  enable: true
+  address: 0.0.0.0:8080
+  workers:
+    command: php /php/roadrunner.php
+    relay: pipes
+    pool:
+      numWorkers: WORKERS

+ 29 - 0
frameworks/PHP/hamlet/hamlet-amp.dockerfile

@@ -0,0 +1,29 @@
+FROM ubuntu:18.10
+
+ENV PHP_VERSION="7.3"
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update -yqq > /dev/null && \
+    apt-get install -yqq software-properties-common > /dev/null
+
+RUN add-apt-repository -y ppa:ondrej/php && \
+    apt-get update -yqq > /dev/null && \
+    apt-get install -yqq \
+        curl \
+        git \
+        unzip \
+        php${PHP_VERSION}-cli \
+        php${PHP_VERSION}-mysqli \
+        php${PHP_VERSION}-apcu \
+        php${PHP_VERSION}-opcache > /dev/null
+
+RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
+
+ADD ./ /php
+WORKDIR /php
+RUN chmod -R 777 /php
+
+RUN composer update --quiet --no-dev --optimize-autoloader --classmap-authoritative
+
+CMD php /php/amp.php

+ 1 - 1
frameworks/PHP/hamlet/hamlet-react.dockerfile

@@ -18,6 +18,6 @@ ADD ./ /php
 WORKDIR /php
 RUN chmod -R 777 /php
 
-RUN composer install --quiet --no-dev --optimize-autoloader --classmap-authoritative
+RUN composer update --quiet --no-dev --optimize-autoloader --classmap-authoritative
 
 CMD php /php/react.php

+ 44 - 0
frameworks/PHP/hamlet/hamlet-roadrunner.dockerfile

@@ -0,0 +1,44 @@
+FROM ubuntu:18.10
+
+ENV PHP_VERSION="7.3"
+ENV RR_VERSION="1.2.6"
+
+ENV RR_URL="https://github.com/spiral/roadrunner/archive/v${RR_VERSION}.tar.gz"
+ENV GOPATH="/php/go"
+
+ARG DEBIAN_FRONTEND=noninteractive
+
+RUN apt-get update -yqq > /dev/null && \
+    apt-get install -yqq software-properties-common > /dev/null
+
+RUN add-apt-repository -y ppa:ondrej/php && \
+    apt-get update -yqq > /dev/null && \
+    apt-get install -yqq \
+        curl \
+        git \
+        php${PHP_VERSION}-cli \
+        php${PHP_VERSION}-mysqli \
+        php${PHP_VERSION}-apcu \
+        php${PHP_VERSION}-opcache \
+        golang-go > /dev/null
+
+RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
+
+ADD ./ /php
+WORKDIR /php
+RUN chmod -R 777 /php
+
+RUN mkdir "${GOPATH}"
+
+RUN curl -sSL "${RR_URL}" | tar xzf - && \
+    cd "roadrunner-${RR_VERSION}" && \
+    go get -d ./... && \
+    make && \
+    cp rr /usr/local/bin/rr && \
+    chmod +x /usr/local/bin/rr
+
+RUN sed -i 's|WORKERS|'"$(nproc)"'|g' /php/deploy/.rr.yaml
+
+RUN composer update --quiet --no-dev --optimize-autoloader --classmap-authoritative
+
+CMD rr -c /php/deploy/.rr.yaml serve

+ 1 - 1
frameworks/PHP/hamlet/hamlet-swoole.dockerfile

@@ -18,6 +18,6 @@ ADD ./ /php
 WORKDIR /php
 RUN chmod -R 777 /php
 
-RUN composer install --quiet --no-dev --optimize-autoloader --classmap-authoritative
+RUN composer update --quiet --no-dev --optimize-autoloader --classmap-authoritative
 
 CMD php /php/swoole.php

+ 6 - 0
frameworks/PHP/hamlet/roadrunner.php

@@ -0,0 +1,6 @@
+<?php
+
+require_once __DIR__ . '/vendor/autoload.php';
+
+$application = new \Benchmark\Application;
+\Hamlet\Bootstraps\RoadRunnerBootstrap::run($application);