Application timeout flasks with Amazon load balancer

I am trying to use the Flask application to balance the load of Amazon, and the flash streams continue to fail. It looks like the load balancer is sending the Connection: keep-alive header, and this causes the Flask process to never return (or take a lot of time). By firing ahead, all processes are destroyed and new ones begin. We also tried using uWSGI and simply exposing the Flask application directly (without a shell). All Flask process results simply do not respond.

I don't see anything in Flask docs that would make it ignore this header. I am at a loss as to what else I can do with Flask to fix this problem.

Twisting and direct connections to the machine work fine, only problems with the load balancer cause the problem. The load balancer does not seem to do anything wrong, and we successfully use it with several other packages.

+8
python flask werkzeug gunicorn
source share
4 answers

The solution I have right now is using the fire extinguisher as a wrapper around the bulb application. For worker_class I use an eventlet with several workers. This combination seems stable and responsive. Gunicorn is also configured for HTTPS.

I assume this is a defect in Flask that causes the problem, and it is an efficient workaround.

+8
source share

Did you remember to set session.permanent = True and app.permanent_session_lifetime ?

+1
source share

The easiest way is to force all connections to make sure that you are using HTTP/1.0 and not adding the Connection: Keep-Alive header to the response.

Please check werkzeug.http.remove_hop_by_hop_headers() .

0
source share

Do you need an HTTP load balancer? Using a level 4 balancer can also solve your problem because it does not interfere with higher protocol levels.

0
source share

All Articles