Python API App becomes stale hours after deployment.

Posted November 6, 2021 113 views
DigitalOcean Managed PostgreSQL DatabaseDigitalOcean App Platform

I have a simple API (Fast API) python app through a Dockerfile on DO App Platform. When I deploy it fresh it works really well. After about 24 hours of being idle, the server will respond with a 500 for about 5-10% of requests (to the same endpoint)…

I’ve narrowed it down to a DB Connection error: Interface already closed. But it only happens when deployed, and being idle for about 24 hours. Been trying to reproduce locally (no luck), and directly after a fresh deploy. After a fresh deploy, I can hit the URL 1000 times with no issues.

Any Digital Ocean App Platform specific things I should look at to continue troubleshooting ?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hey there!

I wonder if this may be related to the database connections staying open. It could be possible you are running out of connections and it eventually fails. I’d recommend opening a ticket with our support team the next time you are seeing those 500 errors and they can take a look.

Hope it helps!