Browse Source

Adds an Nginx configuration for Hapi and Postgres (#4038)

* Adds an Nginx configuration for Hapi and Postgres

* Remove unused code and dynamically allocate cores

* Dynamically create nginx service workers
jcoleman-techempower 7 years ago
parent
commit
95c4ee77ba

+ 23 - 0
frameworks/JavaScript/hapi/benchmark_config.json

@@ -24,6 +24,29 @@
       "notes": "",
       "notes": "",
       "versus": "nodejs"
       "versus": "nodejs"
     },
     },
+    "nginx": {
+      "json_url": "/json",
+      "plaintext_url": "/plaintext",
+      "db_url": "/db",
+      "query_url": "/queries?queries=",
+      "fortune_url": "/fortunes",
+      "update_url": "/updates?queries=",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Micro",
+      "database": "Postgres",
+      "framework": "hapi",
+      "language": "JavaScript",
+      "flavor": "NodeJS",
+      "orm": "Full",
+      "platform": "None",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "hapi-nginx",
+      "notes": "",
+      "versus": "nodejs"
+    },
     "mysql": {
     "mysql": {
       "db_url": "/db",
       "db_url": "/db",
       "query_url": "/queries?queries=",
       "query_url": "/queries?queries=",

+ 13 - 0
frameworks/JavaScript/hapi/build-nginx-conf.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+
+CPU_COUNT=$(nproc)
+P=3000
+END=$(($P+$CPU_COUNT))
+CONF=""
+
+while [ $P -lt $END ]; do
+  CONF+="\t\tserver 127.0.0.1:$P;\n"
+  let P=P+1
+done
+
+sed -i "s|# replace|$CONF|g" nginx.conf

+ 2 - 2
frameworks/JavaScript/hapi/create-server.js

@@ -1,5 +1,5 @@
 /**
 /**
- * Currently commenting out redis caching as there is no 
+ * Currently commenting out redis caching as there is no
  * working implementation for the benchmark suite.
  * working implementation for the benchmark suite.
  */
  */
 
 
@@ -14,7 +14,7 @@ const options = {
 
 
 const server = new Hapi.Server(options);
 const server = new Hapi.Server(options);
 
 
-server.connection({port: 8080, host: '0.0.0.0'});
+server.connection({port: process.env.PORT || 8080, host: '0.0.0.0'});
 server.register(Vision, (err) => {
 server.register(Vision, (err) => {
     if (err) {
     if (err) {
         throw err;
         throw err;

+ 18 - 0
frameworks/JavaScript/hapi/hapi-nginx.dockerfile

@@ -0,0 +1,18 @@
+FROM node:10.10.0
+
+RUN apt update
+RUN apt install nginx -y
+
+WORKDIR /
+
+COPY ./ ./
+RUN chmod +x start-servers.sh
+RUN chmod +x build-nginx-conf.sh
+
+RUN ./build-nginx-conf.sh
+
+ENV NODE_HANDLER sequelize-postgres
+
+RUN npm install
+
+CMD ./start-servers.sh && nginx -c /nginx.conf -g "daemon off;"

+ 33 - 0
frameworks/JavaScript/hapi/nginx.conf

@@ -0,0 +1,33 @@
+error_log        stderr;
+worker_processes auto;
+
+events {
+  worker_connections 65535;
+  multi_accept       off;
+}
+
+http {
+  default_type          application/octet-stream;
+  client_body_temp_path /tmp;
+  access_log            off;
+
+  sendfile              on;
+  tcp_nopush            on;
+  keepalive_requests    100000;
+  keepalive_timeout     65;
+
+  upstream workers {
+    # replace
+  }
+
+  server {
+    listen      8080;
+    server_name tfb-server;
+
+    location / {
+      proxy_http_version 1.1;
+      proxy_set_header   Connection "";
+      proxy_pass         http://workers;
+    }
+  }
+}

+ 10 - 0
frameworks/JavaScript/hapi/start-servers.sh

@@ -0,0 +1,10 @@
+#!/bin/bash
+
+CPU_COUNT=$(nproc)
+P=3000
+END=$(($P+$CPU_COUNT))
+
+while [ $P -lt $END ]; do
+  PORT=$P node create-server.js &
+  let P=P+1
+done