3

Yesterday I deployed on Amazon Elastic Beanstalk my first flask app. App is working, but there is a problem when I press a button that launch a scraping process. This process is pretty long, it can takes about 3/4 minutes, and obviously after one minute from i pressed the button i got the 504 error.

I read a lot on internet on how solve this problem and it is related to nginx, but nothing is working.

This is what I have tried:

1. EC2 Load Balancer I have created a load balancer linked to my istance, and increased the idle timeout to 300s. But nothing changed.

2. Added .ebextensions to my project I also tried to modify nginx parameters with my_name.conf inside

.ebextensions -> nginx -> conf.d -> my_name.conf

my_name.conf

keepalive_timeout 240s
proxy_read_timeout 240s;
proxy_send_timeout 240s;
proxy_connect_timeout 240s;

and alone in .ebextensions

proxy.config

container_commands:
    01_reload_nginx:
        command: 'sudo service nginx reload'

Neither this solution worked.

So I tried another approach

In .ebextensions i create this file, but didn't work, then i tried to put in .ebextensions -> nginx , but again the problem still remain.

proxy.config

files:
    “/etc/nginx/conf.d/01-timeout.conf”:
        mode: “000644”
        owner: root
        group: root
        content: |
            keepalive_timeout 240s;
            proxy_connect_timeout 240s;
            proxy_send_timeout 240s;
            proxy_read_timeout 240s;
            fastcgi_send_timeout 240s;
            fastcgi_read_timeout 240s;
container_commands:
    nginx_reload:
        command: “sudo service nginx reload”

My project structure is:

my_app
-> .ebextensions
->project (where there are python file with all the code)
->application.py (python file wiith main used to load all the file and launch the app)
->requirements.txt

Do you have any idea how to solve this problem? Thanks in advance

hobbit
  • 53
  • 1
  • 7
  • Is it possible to change the Idle Timeout via settings somehow? Because i dont want to configure it manually – alext Apr 10 '21 at 15:15

1 Answers1

4

The nginx settings you are trying to use (/etc/nginx/conf.d/01-timeout.conf`) are for Amazon Linux 1.

Its likely that you are using Amazon Linux 2, for which the nginx settings should be in .platform/nginx/conf.d/, not in .ebextentions (see docs).

Therefore, you could try the following .platform/nginx/conf.d/mytimeout.conf with content:

keepalive_timeout 240s;
proxy_connect_timeout 240s;
proxy_send_timeout 240s;
proxy_read_timeout 240s;
fastcgi_send_timeout 240s;
fastcgi_read_timeout 240s;
Marcin
  • 215,873
  • 14
  • 235
  • 294
  • 1
    Oh my gosh, man, you made my day. I am really grateful to you, my bad, but i didn't search really well and i didn't find that page. Thanks again @Marcin – hobbit Dec 28 '20 at 09:51