From 99d604b029455bd5d34db15fae6519af8a42fbb2 Mon Sep 17 00:00:00 2001 From: tschaffter Date: Mon, 9 Aug 2021 15:03:01 -0700 Subject: [PATCH 1/2] Bump data node version to 1.3.0 --- README.md | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 72ccc06..64c5d80 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ predictions generated by N tools contributed to NLPSandbox.io. ### Specification +- Data Node version: 1.3.0 - Data Node API version: 1.2.0 -- Data Node version: 1.2.1 - Docker image: [nlpsandbox/data-node] ## Usage diff --git a/docker-compose.yml b/docker-compose.yml index beb7fa7..cf7d2fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,7 +17,7 @@ services: - "${MONGO_PORT}:27017" data-node: - image: nlpsandbox/data-node:1.2.1 + image: nlpsandbox/data-node:1.3.0 build: context: server dockerfile: Dockerfile From 5c57ee1a756b30c2f32039ab1eb92a3d0908e32b Mon Sep 17 00:00:00 2001 From: Thomas Schaffter Date: Wed, 11 Aug 2021 19:24:07 -0700 Subject: [PATCH 2/2] Increase uwsgi processes and limit memory usage (#195) * Increase default uwsgi processes from 1 to 2 * Simplify env vars in docker-compose.yml * Add comment about uwsgi number of processes * Add network configuration in docker-compose.yml * Limit memory resources used by db and service * Update README * Add note about docker compose * Restore $SERVER_PORT in docker-compose.yml --- README.md | 13 ++++++----- docker-compose.yml | 54 +++++++++++++++++++++++++++++++++------------- server/uwsgi.ini | 2 +- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 64c5d80..983e958 100644 --- a/README.md +++ b/README.md @@ -48,9 +48,12 @@ Create the configuration file. The command below starts the Data Node locally. - docker-compose up --build + docker compose up -You can stop the container run with `Ctrl+C`, followed by `docker-compose down`. +You can stop the container run with `Ctrl+C`, followed by `docker compose down`. + +> Note: `docker compose` is not yet available on Linux. Use `docker-compose` +> instead. ### Running with Python @@ -67,7 +70,7 @@ variables. Start the MongoDB instance. - docker-compose up -d db + docker compose up -d db Install and start the Data Node. @@ -81,8 +84,8 @@ The Data Node provides a web interface that you can use to create and manage resources. The address of this interface depends on whether you run the Data Node using Docker (production mode) or the Python development server. -- Using Docker: http://localhost/ui -- Using Python: http://localhost:8080/ui +- Default: HTTP://localhost:8080/ui +- Format: `http://localhost:{SERVER_PORT}/ui` ## Contributing diff --git a/docker-compose.yml b/docker-compose.yml index cf7d2fa..7fe69b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,15 +6,21 @@ services: container_name: data-node-db restart: always environment: - - MONGO_INITDB_ROOT_USERNAME=${MONGO_INITDB_ROOT_USERNAME} - - MONGO_INITDB_ROOT_PASSWORD=${MONGO_INITDB_ROOT_PASSWORD} - - MONGO_INITDB_DATABASE=${MONGO_INITDB_DATABASE} - - MONGO_USERNAME=${MONGO_USERNAME} - - MONGO_PASSWORD=${MONGO_PASSWORD} + - MONGO_INITDB_ROOT_USERNAME + - MONGO_INITDB_ROOT_PASSWORD + - MONGO_INITDB_DATABASE + - MONGO_USERNAME + - MONGO_PASSWORD volumes: - database-data:/data/db + networks: + - nlpsandbox-data-node-internal ports: - - "${MONGO_PORT}:27017" + - "27017:27017" + deploy: + resources: + limits: + memory: 1G data-node: image: nlpsandbox/data-node:1.3.0 @@ -22,26 +28,44 @@ services: context: server dockerfile: Dockerfile container_name: data-node - # command: uwsgi --ini uwsgi.ini --lazy --http :8080 --processes 4 + # Uncomment the line `command` if you want to customize any of its + # parameters. Replace the following values: + # - {processes}: min(2 * max number of concurrent processes that the data + # node should support, 6 * number of CPU cores) + #command: uwsgi --ini uwsgi.ini --lazy --http :8080 --processes {processes} environment: - - SERVER_PROTOCOL=${SERVER_PROTOCOL} - - SERVER_DOMAIN=${SERVER_DOMAIN} - - SERVER_PORT=${SERVER_PORT} - - DB_PROTOCOL=${DB_PROTOCOL} + - SERVER_PROTOCOL + - SERVER_DOMAIN + - SERVER_PORT + - DB_PROTOCOL - DB_DOMAIN=db - - DB_PORT=${DB_PORT} - - DB_DATABASE=${DB_DATABASE} - - DB_USERNAME=${DB_USERNAME} - - DB_PASSWORD=${DB_PASSWORD} + - DB_PORT + - DB_DATABASE + - DB_USERNAME + - DB_PASSWORD # healthcheck: # test: curl --fail http://localhost:8080/api/v1/healthCheck # interval: 10s # timeout: 5s # retries: 5 + networks: + - nlpsandbox-data-node + - nlpsandbox-data-node-internal ports: - "${SERVER_PORT}:8080" depends_on: - db + deploy: + resources: + limits: + # The amount of memory required depends on the number of uwsgi + # processes used. Default: number of processes * 100M + memory: 2G volumes: database-data: + +networks: + nlpsandbox-data-node: + nlpsandbox-data-node-internal: + internal: true diff --git a/server/uwsgi.ini b/server/uwsgi.ini index 94bd762..18569ae 100644 --- a/server/uwsgi.ini +++ b/server/uwsgi.ini @@ -6,7 +6,7 @@ wsgi-file = openapi_server/__main__.py callable = app uid = www-data gid = www-data -processes = 1 # Number of concurrent processes / workers +processes = 2 # Number of concurrent processes / workers threads = 1 # Number of threads per process master = true chmod-sock = 660