Last active
January 17, 2017 14:24
-
-
Save JoeStanton/f57b25736798fc011e95807ed5dfed1a to your computer and use it in GitHub Desktop.
Lambda container lifetime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var startedAt = (new Date).toString(); | |
var lastExecuted = null; | |
exports.ping = function(event, context, done) { | |
lastExecutedCopy = lastExecuted; | |
lastExecuted = (new Date).toString(); | |
done(null, { | |
warm: !!lastExecutedCopy, | |
startedAt: startedAt, | |
last: lastExecutedCopy, | |
now: lastExecuted | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
def test(interval, desc) | |
before = JSON.parse(`sls invoke -f ping`) | |
sleep interval | |
after = JSON.parse(`sls invoke -f ping`) | |
outcome = after["warm"] ? "warm" : "cold" | |
puts "Function was #{outcome} after #{desc}" | |
end | |
test(15 * 60, "fifteen minutes") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment