Flask server failing when load increases
I've deployed a flask server and it works totally fine if I test it on a dev Vercel deployment, but as soon as I switch the prod backend to the railway flask server and start getting high traffic, I get this weird error over and over. Definitely a traffic thing because it even works for the first few seconds that I deploy, but quickyl get CORS error, presumably because the server can't send back headers.
11 Replies
Project ID:
ce32fe10-d6e2-48b8-97c2-1f14b564dc39
ce32fe10-d6e2-48b8-97c2-1f14b564dc39
have you tried increasing the workers and threads?
how do I do that?
have a read of gunicorns docs, they provide flags to set the number of workers and threads gunicorn will use
upping the number of replicas seems to have done the trick!
Solution
i would try with a single replica but with more workers and threads
railway runs the flask server for me though, would you suggest switching to a docker container so I can actually set these parameters?
railway does not run the server for you, you are in full control of whats ran at all times
most python users have their start commands defined in a Procfile
ohh got it thanks
performance is great! thanks for saving our app!
no problem!