Yeah, 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...
Lambda 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).
I 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.
Does 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?
I 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.