I have a django application running on Gunicorn and Nginx. There is one request in application which takes 10 min to load the page [There is lot of data to process], i have increased the worker time to 1200 sec for Gunicorn to make it take sufficient time to load the page. it works fine but until that request is getting processed other users are not able to access the application gives :
504 Gateway Time-out nginx/1.21.4
This is my DOCKER
version: '3.8'
services:
web:
volumes:
- static:/static
command: python manage.py makemigrations /
&& python manage.py migrate && python manage.py collectstatic --noinput/
&& python manage.py crontab add /
&& exec gunicorn DrDNAC.wsgi:application --bind 0.0.0.0:8000 --timeout 1200"
build:
context: .
ports:
- "8000:8000"
depends_on:
- db
db:
image: postgres:13.0-alpine
nginx:
build: ./nginx
volumes:
- static:/static
ports:
- "80:80"
depends_on:
- web
volumes:
postgres_data:
static:
This is nginx:
upstream app {
server web:8000;
}
server {
listen 80;
location / {
proxy_pass https://app;
proxy_connect_timeout 75s;
proxy_read_timeout 300s;
}
location /static/ {
alias /static/;
}
}
CodePudding user response:
This might happen because the amount of workers is not sufficient.
Try to increase the amount by adding --workers=4
to the gunicorn call.
gunicorn DrDNAC.wsgi:application --workers=4 --bind 0.0.0.0:8000 --timeout 1200
You can find more informations under the following link: https://docs.gunicorn.org/en/stable/settings.html#worker-processes
In addition you can also increase the amount of threads by using --threads 4