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 (
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:
-/app --__init__.py | The part which is assembly of other py components(client.py,errors.py...) and calling config properties --client.py | The file contains Client routes --errors.py | Where the error routes written --models.py | The file contains database Columns and Python objects --panel.py | The main backend file of whole app --/static --/templates -config.py | Config -manage.py | Manage file to database migrations -run.py
And the run.py:
from app import app if __name__ == "__main__": app.run("0.0.0.0", debug=True, port=3000, ssl_context=('cert.crt', 'key.key'),threaded=True)
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?
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.