I understand that the database connection limit on HelioHost is restricted to 10 simultaneous connections. To ensure that my application does not exceed this limit, I tried two different approaches, but both resulted in errors.
First Approach: Using SQLAlchemy Advanced Configuration
I configured the SQLALCHEMY_ENGINE_OPTIONS as follows:
SQLALCHEMY_ENGINE_OPTIONS = {
'pool_size': 5,
'max_overflow': 2,
'pool_timeout': 20,
'pool_recycle': 280,
'connect_args': {
'connect_timeout': 10 # 10-second timeout for database connections
}
}
However, this resulted in the following errors:
2025-04-16 03:19:26 Error 186.205.7.186 504 GET /bma/ HTTP/1.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 967 Apache SSL/TLS access
2025-04-16 03:19:47 Error 186.205.7.186 504 GET /bma/flask.wsgi/usuarios HTTP/1.0 https://talesaz.heliohost.us/bma/flask.wsgi/usuarios/11 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 967 Apache SSL/TLS access
2025-04-16 03:20:26 Error 186.205.7.186 Timeout when reading response headers from daemon process 'talesaz_wsgi': /home/talesaz.heliohost.us/httpdocs/bma/flask.wsgi Apache error
Second Approach: Managing Connections Manually
I then tried to manually open and close connections for each request using the following code:
@app.before_request
def before_request():
g.db = db.session()
@app.teardown_request
def teardown_request(exception):
db.session.remove()
Unfortunately, this also resulted in errors:
2025-04-16 03:55:58 Error 186.205.7.186 500 GET /bma/ HTTP/1.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 986 Apache SSL/TLS access
2025-04-16 03:59:18 Error 186.205.7.186 500 GET /bma/ HTTP/1.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 986 Apache SSL/TLS access
Could you please provide any guidance or tips on how to ensure that my application does not exceed the connection limit imposed by HelioHost? I would greatly appreciate any advice on how to configure SQLAlchemy or manage connections more effectively in this environment.
Thank you in advance for your help!