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