Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoke AWS Lambda(s) regularly every 1 minute

How can I invoke an AWS Lambda regularly, specifically every 1 minute? The current functionality allows Lambdas to be setup with 5 minute trigger, but I am looking for a much lesser time interval. I thought of running the Lambda forever, but it looks like that can't be done since the Maximum execution duration per request 300 seconds

like image 847
Chenna V Avatar asked Feb 08 '16 15:02

Chenna V


People also ask

How do you trigger Lambda automatically?

Under Targets, Choose Add target, On the dropdown menu, select the preferred Lambda function, For Function, Select the function name. For Configure details, Under the Rule definition, enter a name for the rule and then provide a short description. State should be Checked (Enabled).

How many requests per second can Lambda handle?

Lambda uses the 3,000 available burst concurrency to create new environments to handle the additional load. 1,000 requests are throttled as there is not enough burst concurrency to handle all 5,000 requests. Transactions per second are 16,000.


2 Answers

[Removed previous answer and update] Now, AWS Lambda provides a per minute frequency CloudWatch Events - Schedule as a trigger option. enter image description here

like image 130
Chenna V Avatar answered Oct 04 '22 20:10

Chenna V


There was a session at AWS Reinvent in 2015 that covered this exact topic, you can watch it here on youtube: https://www.youtube.com/watch?v=FhJxTIq81AU shows how to use lambda and cloudwatch to get that 1 minute frequency with no external dependencies.

Do you need to run an AWS Lambda function on a schedule, without an event to trigger the invocation? This session shows how to use an Amazon CloudWatch metric and CloudWatch alarms, Amazon SNS, and Lambda so that Lambda triggers itself every minute—no external services required! From here, other Lambda jobs can be scheduled in crontab-like format, giving minute-level resolution to your Lambda scheduled tasks. During the session, we build this functionality up from scratch with a Lambda function, CloudWatch metric and alarms, sample triggers, and tasks.

I suspect that at some point AWS will allow the 1 minute interval without using this method, but this may hold you over in the mean time.

like image 40
E.J. Brennan Avatar answered Oct 04 '22 20:10

E.J. Brennan