## 502 error during cold boot?

30 messages · Page 1 of 1 (latest)

karmic cliff
#

Project ID: 483187d7-a9d4-4961-b10f-f2804b57d52b

The "serverless" (formerly "sleep" right?) is active in my fastAPI application in Railway. There have been a few occasions this week when a request was not received (or least I didn't see a trace of it in the logs). The container started and then closed, but the request was not queued as far as I can see.

I would prefer not to disable the sleep/serverless feature, so I am considering a recursive call to a dummy /awake endpoint that would take place prior to the actual request to "awaken" the app, and would iterate a predetermined numbered of times (say, 5) while it gets status code 502. Would you say this is a good approach to avoid the problem?

Or are you aware of any issues on your end that might be related?
Thanks, Manuel

#1006629907067064482

fallow craterBOT
#

Project ID: 483187d7-a9d4-4961-b10f-f2804b57d52b

queen venture
#

how long does your app take to boot? if it takes longer than 10 seconds we will cancel the incoming request and return our 502 page instead

karmic cliff
#

Yes, that's what I have seen, it's possible that it takes longer than 10 seconds.

queen venture
#

then yeah theres nothing we can do about that from our side, your app would have to start faster

#

are you doing something at boot that takes a long time?

karmic cliff
#

Every time the app is (re) deployed, there are a few dependencies that need to be downloaded and installed, but I don't consider that as part of the booting.

#

Although if by "boot" you mean start after sleep (you probably do), I don't think there's anything in particular in the booting that takes long. The action of the app take long but I don't consider them as part of the booting.

#

Could there be something incorrect in the app's settings?

queen venture
#

yeah im only talking about during runtime

karmic cliff
#

(rather than in the code of the application)

queen venture
#

yeah i can see from the logs its taking a long time for your application to start

karmic cliff
#

do you see why that is?

#

I know the processing may take up to 1 min (from the moment the API gets the request until it sends a response), but I'm not aware why it could take long to start

queen venture
#

no im sorry but i have no way to answer that, we do not have any observability into what your code is / is not doing

karmic cliff
#

so you are saying that the fact it takes long to start comes from the code itself, right? (not the settings of the app)

queen venture
#

correct, this is an issue at the application level, and not at the platform level

karmic cliff
#

thanks, @queen venture

#

what do you think about my hacky workaround (having the client send recursive call to that /awake)

#

(the client is another API deployed in Railway)

queen venture
#

i think it would be best to work towards having your app start faster

karmic cliff
#

thanks, we'll try to achieve that

#

Thanks a lot for your help

#

If you have any other tips about how I can track what is causing the problem, they would be appreciated

round galleon
#

with a quick google search u can see that fastapi has some troubles with cold starts so you aren't the only one with these issues

#

a reddit thread I saw recommended adjusting some configs

#

other said to optimize dockerfile

karmic cliff
#

thanks, @round galleon

queen venture
#

!s