Added memory limits to previewservice (#349)

This commit is contained in:
Cristian Balas 2021-07-21 10:39:16 +03:00 коммит произвёл GitHub
Родитель 27cf4d59cc
Коммит 37f18be68d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 14 добавлений и 6 удалений

Просмотреть файл

@ -1,4 +1,4 @@
version: "3"
version: "2"
services:
speckle-frontend:
@ -36,6 +36,8 @@ services:
context: .
dockerfile: packages/preview-service/Dockerfile
restart: always
mem_limit: "1000m"
memswap_limit: "1000m"
environment:
DEBUG: "preview-service:*"
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"

Просмотреть файл

@ -25,8 +25,12 @@ npm run dev
This will use the default dev DB connection of `postgres://speckle:speckle@localhost/speckle`. You can pass the environment variable `PG_CONNECTION_STRING` to change this to a different DB.
## Deployment notes
To run locally in a docker container (after you build the docker image) with limited memory, the command line might look something like:
```
docker run -it --rm --net=host -e DEBUG="preview-service:*" -e PG_CONNECTION_STRING="postgres://speckle:speckle@localhost/speckle" -m 700m speckle-server_preview-service
```
When deploying the PreviewService, it's important to pay attention to the memory requirements: Speckle streams can be arbitrarily large and the preview service must load the entire stream in order to generate the preview image.
You must limit the PreviewService container memory to a value that you want to allocate for preview generation. If a stream requires more memory then the limit, the preview for that stream will fail, but the entire system remains stable.
To limit the container memory when running with `docker run`, you can use the `-m` flag.
With docker-compose, you must use a docker-compose file at version 2 (not 3) and use the `mem_limit` option.

Просмотреть файл

@ -1,4 +1,4 @@
version: "3"
version: "2"
services:
####
# Speckle Server dependencies
@ -65,6 +65,8 @@ services:
speckle-preview-service:
image: speckle/speckle-preview-service:2
restart: always
mem_limit: "1000m"
memswap_limit: "1000m"
environment:
DEBUG: "preview-service:*"
PG_CONNECTION_STRING: "postgres://speckle:speckle@postgres/speckle"