From 654953b63eb693aa2ca7d72c146c1e2e7b53e555 Mon Sep 17 00:00:00 2001 From: Tobias Allweier Date: Tue, 23 Jan 2024 19:50:41 +0100 Subject: [PATCH] add the scalability for the docker image (#452) Co-authored-by: Tobias Allweier --- README.md | 12 ++++++++++++ WebApp.Dockerfile | 4 +++- infrastructure/deployment.json | 10 +++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 15179512c9..5d325fb6d2 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,18 @@ See the [Oryx documentation](https://github.com/microsoft/Oryx/blob/main/doc/con After adding the settings, be sure to save the configuration and then restart your app. +For apps published with `One click Azure deployment` you can increase your app's ability to handle concurrent requests from multiple users with the following steps: +1. Upgrade your App Service plan tier to a higher tier, for example tiers with more than one vCPU. + +2. Configure the following app settings on your App Service in the Azure Portal: +- `UWSGI_PROCESSES`: 5 (may be higher or lower depending on your App Service Plan tier) +- `UWSGI_THREADS`: 5 (may be higher or lower depending on your App Service Plan tier) + +After adding the settings, be sure to save the configuration and then restart your app. + +> In case you build your own docker image based on the `WebApp.Dockerfile` and host it in a App Serice, you can also increase your app's ability to handle concurrent requests from multiple users with the above steps. +When you host your container not in an App Service you can add this seetings as container environment variable. + ### Debugging your deployed app First, add an environment variable on the app service resource called "DEBUG". Set this to "true". diff --git a/WebApp.Dockerfile b/WebApp.Dockerfile index 74c1d1c98c..6b273330fc 100644 --- a/WebApp.Dockerfile +++ b/WebApp.Dockerfile @@ -27,5 +27,7 @@ RUN pip install --no-cache-dir -r /usr/src/app/requirements.txt \ COPY . /usr/src/app/ COPY --from=frontend /home/node/app/static /usr/src/app/static/ WORKDIR /usr/src/app +ENV UWSGI_PROCESSES=2 +ENV UWSGI_THREADS=1 EXPOSE 80 -CMD ["uwsgi", "--http", ":80", "--wsgi-file", "app.py", "--callable", "app", "-b","32768"] +CMD uwsgi --processes $UWSGI_PROCESSES --threads $UWSGI_THREADS --http :80 --wsgi-file app.py --callable app -b 32768 \ No newline at end of file diff --git a/infrastructure/deployment.json b/infrastructure/deployment.json index 52de1393a1..9957321287 100644 --- a/infrastructure/deployment.json +++ b/infrastructure/deployment.json @@ -578,7 +578,15 @@ { "name": "ELASTICSEARCH_EMBEDDING_MODEL_ID", "value": "[parameters('ElasticsearchEmbeddingModelId')]" - } + }, + { + "name": "UWSGI_PROCESSES", + "value": "2" + }, + { + "name": "UWSGI_THREADS", + "value": "2" + } ], "linuxFxVersion": "[variables('WebAppImageName')]" }