3 ms·
AIUI, Lambda operates on requests. (Either "calls" to a function, i.e., just invoking a lambda function w/ args and getting the result over the network somewher
by deathanatos 8y ago
AIUI, Lambda operates on requests. (Either "calls" to a function, i.e., just invoking a lambda function w/ args and getting the result over the network somewhere else, or as an HTTP handler or a CloudWatch handler, but those are really specialized cases of the first.) Using time.NewTicker/time.After strikes me as something you would do to maintain some sort of background process, which Lambda is not intended for: IIRC, Lambda can arbitrarily freeze your process b/c no requests are being served presently, and that "capacity" isn't needed as far as AWS is concerned. I think under the hood they're doing a cgroup freezer or something, but the result would be exactly what you see: timers firing way too late. They wouldn't fire until the underlying container is unfrozen. This wouldn't be a bug in Go or Lambda; Lambda is specifically designed to do this, so as to free you from needing to care about how much capacity you require¹. (At the cost of making stuff like background timers not work; that's not its model.)
See: https://aws.amazon.com/blogs/compute/container-reuse-in-lambda/ https://aws.amazon.com/blogs/compute/container-reuse-in-lamb...
¹ish. take that statement w/ a grain of salt.
- freecodyx 8y agoWell, this is the issue, when my function exceeds the timeout configured in the function yml, lambda will respond with internal server error, and will freeze the VM, if it decides to reuse the VM for another request, then the go-routines of the last call will resume (because i didn't call os.Exit).