Question

Too many concurrent requests for a Flask app on App Platform returns "Error: We encountered an error when trying to load your application...

I am building a flask app that takes a long time to return (minutes) after receiving a GET request. I noticed that when I try to stress test the server by sending 5 concurrent requests, the backend can still be running normally, but the front end would timeout with the following message. I already set a very generous gunicorn worker timeout so that the backend would not timeout. I cannot reproduce this locally and I failed to find which digital ocean setting controls this behavior.

Error

We encountered an error when trying to load your application and your page could not be served. Check the logs for your application in the App Platform dashboard.


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
April 10, 2023

Hi there,

It sounds like that your app is making an external request to a database or another system which might be timing out. Usually if the request to an external system takes too long to respond or is unreachable, it could cause your Flask app to hang, leading to a timeout error on the frontend.

Does this happen on every single GET request or just on a specific request?

I could suggest enabling the debug for your Flaks app and checking if there will be some more useful information in the logs that might point you to the direction on what might be causing the issue.

Also, if you were to open your web console, and then go to the Network tab, do you see specific requests that are pending?

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel