S
S
stvoid2019-01-26 22:41:22
Python
stvoid, 2019-01-26 22:41:22

Application crashes 502?

In the application, a GET request is made to the flask, as a result of which an .xlsx file is returned.
In certain situations, it can be very large, so the request processing time takes a long time.
As a result, the application crashes, NGINX gives a 502 error (application on port 5000).
Can you tell me what can be done about it?
PS. I googled about the buffer size or response time settings, but either I didn’t enter it there, or
PSS didn’t help. There is an alternative option to send users a file by mail, but it's not so convenient
NGINX config (VPS ubuntu 16)

#user  nobody;
worker_processes  auto;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  HOST.tk;
    client_max_body_size 100m;

    
    location / {
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   Host      $http_host;
        proxy_pass         http://127.0.0.1:5000;}

    }
  server {
      listen       80;
      server_name  stats.HOST.tk;
      client_max_body_size 100m;
      
      location / {
      proxy_set_header   X-Real-IP $remote_addr;
      proxy_set_header   Host      $http_host;
      proxy_pass         http://127.0.0.1:3000;}
  }

}

fr

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Syomov, 2019-01-26
@stvoid

Most likely, you have 502 because your process is busy for a very long time and does not accept connections at this time.
It is necessary either to change the logic of work, or to launch many processes, and distribute requests between them.
If the problem was in a processing timeout, there would be a 504 error. If in the amount of data received from the client (client_max_body_size is responsible for this), then 413.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question