3 ms·
That’s great news. For some reason cloud function run extremely slowly for me on Firebase. Like a few seconds slow on the first call if not called frequently, t
by mrtksn 6y ago
That’s great news. For some reason cloud function run extremely slowly for me on Firebase. Like a few seconds slow on the first call if not called frequently, then it drops to milliseconds level.
- WrtCdEvrydy 6y agoYeah, this is called a 'startup effect' in most cloud function environments. Lambda has a thing called 'prewarming' which basically hits it every 15ish seconds to make sure it's still active...
- mrtksn 6y agoI am considering to implement something like that by myself. It’s not an acceptable performance otherwise. Alternatively I am looking into running it on different tech, I would have moved already on Swift on Linux if Fireplace had a library for Swift beyond iOS.
- gnulinux 6y agoDoes it really sleep in 15 seconds such that it needs to warm up? Why call it every 15 seconds? Why not every hour, every day? Is there a documentation how often it needs a warm-up?
- WrtCdEvrydy 6y agoI believe AWS docs say that your function is loaded on a machine for 15 seconds after termination... so if a new request comes in during that time it goes to that function instead of starting a new one.
- moduspwnens14 6y agoLambda has provisioned capacity now. You can just tell it how many to keep warm and it'll keep that many warm (but still cold start additionally as necessary).
- asadlionpk 6y agoThat's by design. Your server 'sleeps' and - wakes up on for a request(few seconds delay on request), - stays awake (requests are fast here), - goes back to sleeping if idle for sometime (15mins?) This is what keeps the costs low (or free). Same is true for Heroku, Lambda, Vercel, Azure Functions, etc.
- mrtksn 6y agoSure but it is not an acceptable level of latency when the product is supposed to respond on user input. When the app or the feature is new or obscure it would fall in this state all the time. Last time I checked I wasn’t renting a server, it was supposed to be a service that’s fast at any scale. A 5$ DO instance would provide much better experience. They should give an option to keep it awake albeit at a cost.
- oldmanhorton 6y agoAzure functions has that option, but at some point... Why not just use a "real" web server if you want it always online? The whole point of serverless was that you don't need a server always running in the background.
- ncw96 6y agoLambda also provides this functionality — they call it "provisioned concurrency": https://docs.aws.amazon.com/lambda/latest/dg/configuration-concurrency.html https://docs.aws.amazon.com/lambda/latest/dg/configuration-c...
- mrtksn 6y agoI don’t want to deal with it until it’s worth dealing with it. That is, until the cost of managing a server and it’s integration is less than the cost of using Firebase(which comes with free integration and no management needs).
- asadlionpk 6y agoThe easiest way around it is to keep ping-ing it every 5 mins from either from a third party (like pingdom, uptimerobot.com) or a cron function (https://cloud.google.com/scheduler/docs/creating https://cloud.google.com/scheduler/docs/creating). But I would recommend using Cloud Run instead.
- deleted 6y ago[deleted]