I am running a restful API using Python SQLAlchemy. We are running serverless on an AWS lambda proxy, the problem I encountered is that sometimes any API endpoints being call would result in a 504 HTTP Status Code
. It's not a particular endpoint timing out, it feels pretty random and it happens let's say every 20th API call made (very peculiar). The API gateway has a timeout of 30 seconds.
I am using Python with SQLAlchemy and a PostgreSQL database. Digging into the logs, I found this error:
[WARNING] Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None))
after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol
(_ssl.c:1091)'))': /api/6261774/envelope/
which seems to be consistently happening when the 504
error occurs.
Any support much appreciated.
Initial thoughts:
Give it's occasional, it could be a network connect on failure?
Provisioned concurrency does run the initialization code which I believe is where the db connection is made. Would it be worth giving it a try with a single instance?