a year ago
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>
29 Replies
a year ago
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
Yes, that's what I have seen, it's possible that it takes longer than 10 seconds.
a year ago
then yeah theres nothing we can do about that from our side, your app would have to start faster
a year ago
are you doing something at boot that takes a long time?
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.
a year ago
yeah im only talking about during runtime
a year ago
yeah i can see from the logs its taking a long time for your application to start
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
a year ago
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
so you are saying that the fact it takes long to start comes from the code itself, right? (not the settings of the app)
a year ago
correct, this is an issue at the application level, and not at the platform level
what do you think about my hacky workaround (having the client send recursive call to that /awake)
a year ago
i think it would be best to work towards having your app start faster
If you have any other tips about how I can track what is causing the problem, they would be appreciated
a year ago
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 year ago
a reddit thread I saw recommended adjusting some configs
a year ago
other said to optimize dockerfile
a year ago
a year ago
!s
Status changed to Solved brody • about 1 year ago