Skip to content
Advertisement

Python-Flask No response: After stayed active for one day

App description: I am using Python-Flask module with PostgreSql 12 as a REST API on a Web based application. There is a lot of request based heartbeat (JavaScript SetIntervals to send heartbeat almost for a every second and the CRUD operations for every user request on a small scale) and REST data (json data with responsed jsonify library of flask) consuming on client-side of application

Environment:
Linode Linux Hosting, Ubuntu 18.04 LTS, Python3 (3.6.9), Flask(1.1.2)

Important code notes & quotes:
This is the schema of the app:

JavaScript

And the run.py:

JavaScript

Problem: Flask get stunned approximately after one day, Takes no requests and return no responses (Chrome returns: It took too long to get response)

Dependencies (If it is possible): Staying with the pure HTTP methods for data and heartbeat transportation; instead of websockets or other transportation protocols

Questions: What could cause this problem? How can i fix this?

Advertisement

Answer

Flask doc recommends not to use the development server when deploying to production. It is intended for use only during local development. It is not designed to be particularly efficient, stable, or secure.

You can use the uwsgi server to serve the flask app in development mode. uWSGI runs multiple processes for your web application. So loads are mitigated in different threads and incoming other requests are accepted by uWSGI.

Advertisement