Reputation: 1840
I have a lambda and I would like to ensure that there is only one instance of it running at a time.
Is it possible for a lambda (written in python) to check if another instance of that same lambda is already running?
Upvotes: 2
Views: 1094
Reputation: 238199
To ensure that no more than 1 instance of your function is running, the easiest way is to set reserved concurrency to one:
Reserved concurrency also limits the maximum concurrency for the function, and applies to the function as a whole, including versions and aliases.
To check if this is actually the case, you can query ConcurrentExecutions metric on your function with By Function Name
dimension:
The number of function instances that are processing events.
To do it programmatically, you can use get-metric-data or get-metric-statistics calls.
Upvotes: 4