Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This may not be the right place for this question but what happens if you'd like to do a long-running Lambda? Something that might run for hours, days, maybe even indefinetly? How do you schedule something like that?


You almost certainly wouldn't use lambda for that (the last option I've listed is a case where you still could).

You have several options.

For many cases like that you should just have an EC2 instance that you run jobs on -- this is the simplest and there are already many tools for managing scheduled tasks like that.

You could also use a scheduled Lambda to start an EC2 instance/record task info in a DynamoDB table and another Lambda to check the status of the task periodically, shutting the instance down when it is done and updating the status. I've written a thing that does this and it works pretty well. You can also use spot instances for this to potentially save some $.

You can use ECS and kick off an ECS Task via a scheduled Lambda. This means learning some stuff about ECS and Docker.

Another interesting but much more complex (and probably not applicable) option is to break your task up into chunks that take less than 5 minutes, and just have Lambdas kick off more Lambdas for the next parts of the task.


I think the appeal for Lambda for me is that I'm not a dev-ops guy. I just want to write some code and have it work. Sadly I don't think this will happen any time soon but I'd like a Lambda-like system that can be triggered from other AWS things.


I am slightly disheartened that you would consider running something on a linux machine with cron "devops" ;).

You can also have Lambdas execute commands on EC2 instances. This makes it easier to run non-web-app code in response to various AWS events since most things can be hooked into Lambda. Maybe that is more along the lines of what you want?


If discrete steps can take less than 5 minutes to complete, you could do it using their "step" tooling:

https://aws.amazon.com/step-functions/

Basically a form of state machine using Lambda.

Personally, I'd prefer to just use a regular EC2 instance for long duration tasks, perhaps even spot instances to keep costs low.


I don't think you can do that. Lambda has a max limit of 5 minutes per invocation. You can however schedule Lambda to invoke as per schedule just like cron.

You'd probably be better off having a small EC2 box that runs long processes than AWS Lambda if your processes can't be broken into 5 minute chunks.


You can't. The process will get aborted after either your set timeout or AWS's fixed timeout.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: