Source: http://www.aisir.cn/2017/07/15/aws Instance deployment flask Error script-timed-out-before-returning-headers-application-py/
[Thu Jul 13 13:21:32.542375 2017] [Core:error] [PID 25744] [Client 127.0.0.1:48852] Script timed out before returning Headers:application.py[thu Jul 13:21:32.618324] [core:error] [pid 25672] [Clien T 127.0.0.1:48754] Script timed out before returning Headers:application.py[thu Jul 13:21:33.517055] [Core:error] [PID 25702] [Client 127.0.0.1:48846] Script timed out before returning Headers:application.py[thu Jul 13:21:33.593206] [core:error] [pid 25722] [Clien T 127.0.0.1:48814] Script timed out before returning headers:application.py
This is a problem that has been plagued by demand, the number of messages received from SQS has more than 10,000, not many, has always been the problem of flask framework, so the solution has been
Background of the production:
Grab Facebook ad data and process it through the SQS distribution in AWS, with the number of SQS in the million, while extracting the image video information from the ad data, the execution time is consumed in the network request.
Problem solving:
Configuring a Machine instance
Visibility timeout (SQS visibility timeout): 3600
Official explanation: The number of seconds that the inbound message is locked for processing before it is returned to the queue. You know, that's more than the time setting for an app to process SQS messages.
Inactivity Timeout (inactivity timeout): 1800
Official explanation: The number of seconds to wait for a response from an application on an existing connection. That is, how long to report time out error, that is, the error seen above.
Note: the inactivity timeout needs to be less than the visibility timeout, otherwise the error the inactivity timeout you specified for your worker tier environment is greater than the SQS Visibility timeout. Be aware that this can result in multiple retries, which can increase the resources your application tasks consume. Consider an inactivity timeout , that's not greater than.
The workaround for this problem on the Stack overflow is that the test is not valid in the. ebextensions Command
: Files:
"/etc/httpd/conf.d/wsgi_custom.conf":
Mode: "000644"
Owner:root
Group:root
Content: |
Wsgiapplicationgroup%{global}
AWS Instance Deployment flask Error Script-timed-out-before-returning-headers-application-py