S
S
Sergey Ganzhela2021-04-06 17:59:56
Django
Sergey Ganzhela, 2021-04-06 17:59:56

How to defeat upstream timed out (110: Connection timed out)?

Good day!
Tell me how you can win

021/04/06 12:27:51 [error] 18610#18610: *38741 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 46.98.107.68, server: ****.com.ua, request: "GET /shop/api/****/products/ HTTP/1.1", upstream: "uwsgi://unix:///home/********.uwsgi/sock", host: ********"

There is a bunch of Django + Nginx + Uwsgi DRF is used as Rest
There is a request to the database from 1C as a result of which a packet of information flies to 1C now more than 20K records in the database the
object is serialized through viewsets.ModelViewSet the back-end itself works fine if you reduce the number of processed records to 15K then it turns out 54-55sec and everything works out if more than 1 minute then there is a 504 error
Shoveled a lot of information everywhere almost the same timers :(

here are my settings!
location / {
        uwsgi_pass    unix:///*******/dj/*****.com.ua/.uwsgi/sock;
        include uwsgi_params;
        client_body_timeout 1800s;
        uwsgi_connect_timeout 15s;
        uwsgi_read_timeout 1800s;
        uwsgi_send_timeout 1800s;
        proxy_send_timeout 900s;
        proxy_read_timeout 900s;
        send_timeout 600;        
    }

but still the connection breaks after 60 seconds

here's another
[uwsgi]


log-format = {VSZ: %(vsz)/%(vszM)M}{RSS: %(rss)/%(vszM)M} [pid: %(pid)|app: -|req: -/-] %(addr) (%(user)) {%(vars) vars in %(pktsize) bytes} [%(ctime)] %(method) %(uri) "%(proto)" %(status) %(rsize) bytes in %(msecs) msecs %(headers) headers in %(hsize) bytes (%(switches) switches on core %(core)) %(var.HTTP_X_REQUEST_ID)

stats = /home/%c/dj/%n/.uwsgi/stats.sock

socket = /home/%c/dj/%n/.uwsgi/sock
chmod-socket = 660
chgrp-socket = www-data

workers = 4         # maximum number of workers
cheaper-algo = spare2
cheaper = 2           # tries to keep 2 idle workers
cheaper-initial = 2   # starts with minimal workers
cheaper-step = 1      # spawn at most 2 workers at once
cheaper-idle = 10     # seconds
enable-threads = true

uid = %c
gid = www-data

env = LC_ALL=ru_RU.utf8

wsgi-file = /home/%c/dj/%n/code/src/project_src/wsgi.py

chdir = /home/%c/dj/%n/code/src
home = /home/%c/dj/%n/.venv

master=true
vacuum = true
memory-report = true

evil-reload-on-rss = 1024
harakiri = 1200
max-requests = 5000 
buffer-size = 65535 
post-buffering = 8192

touch-reload = %(wsgi-file)
daemonize2 = /home/%c/dj/%n/.uwsgi/log
pidfile2 = /home/%c/dj/%n/.uwsgi/pid

# disable IOError: write error, in Sentry
ignore-sigpipe = true
ignore-write-errors = true
disable-write-exception = true

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim, 2021-04-06
@Sergiy_Hanzhela

look at and increase the timeout directive for nginx, I think the problem is there - nginx.org/en/docs/http/ngx_http_proxy_module.html#...
besides, the information flow is not entirely clear - do you process the 1C database using Django Rest? How is the request going?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question