I've got a lambda function and I would like to make sure that it's never being called a second time if it's already running. Is there any option to force this behavior?
-
A file lock on s3 :)RickyA– RickyA2016-03-31 15:35:43 +00:00Commented Mar 31, 2016 at 15:35
-
1@RickyA you might want to look into S3's consistency model before recommending that.Mark B– Mark B2016-03-31 15:37:16 +00:00Commented Mar 31, 2016 at 15:37
-
A lock in zookeeper/etcd/consul?RickyA– RickyA2016-03-31 15:37:29 +00:00Commented Mar 31, 2016 at 15:37
-
@MarkB hence the smile, but yes not a real solutionRickyA– RickyA2016-03-31 15:38:15 +00:00Commented Mar 31, 2016 at 15:38
-
@RickyA DynamoDB is the generally recommended way for implementing locks across distributed systems in AWS.Mark B– Mark B2016-03-31 15:38:45 +00:00Commented Mar 31, 2016 at 15:38
4 Answers
AWS Lambda currently doesn't support this behavior. You could try using DynamoDB to create a lock, but that's obviously not the most ideal scenario. Right now this use case isn't a very good fit for Lambda.
I have a job that I need to ensure only one is ever running, and I wasn't happy with any Lambda solution for that. I ended up just running it on a t2.nano instance.
Comments
AWS Lambda FAQ says that the service is designed to run functions in parallel.
However, you could manage this from your application if you are using the microservice-http-endpoint blueprint. You can do it since this kind of blueprint is just a web service that you can call somewhere.
