5 ms·
How long would you like it to be? Chris Munns - Lead of Dev Advocacy for Serverless@AWS
by munns 6y ago
How long would you like it to be?
Chris Munns - Lead of Dev Advocacy for Serverless@AWS
- staticassertion 6y agoMy lambdas run indefinitely. It's a bit silly, but basically every lambda spins up a bunch of threads, pulls messages, and then pushes them into internal buffers to be processed. There are reasons for this. What I care about is: * Scale to 0, and automatic scaling up without configuring it * Automatic patching of the OS * Fault isolation Lambda gives me that. So each one runs for 15 minutes, processing all data in an SQS queue. I do wonder if Fargate would be cheaper per millisecond? Dunno.
- munns 6y agoToday, for a nonstop workload you might save money with Fargate or ECS.
- staticassertion 6y agoYeah, I'd be curious to see how much money we'd save with Fargate.
- jeffcarter 6y agoFor raw compute, Fargate is ~1/2 the cost of Lambda. But you'd have to orchestrate the launch yourself. It could be worth it though depending on your workload
- matwood 6y agoI'm going to assume since you're processing off a queue, the lambdas are not serving a waiting user. If you do the work to orchestrate onto Fargate, you might as well go the rest of the way and move to ECS. Then you can use spots, where real savings kick in. Someone mentioned step functions above. All of our steps run on spots. We also have some tasks like you have that read off queues and do processing, which also all run on spots.
- Dunedan 6y agoIf you want sequential processing of the data in the SQS queue, something which works really well today is to create a state machine in AWS Step Functions which triggers a AWS Lambda function which then pulls data from SQS and processes it. Using a condition in the state machine, this can be done in a loop, so when the AWS Lambda function reaches its timeout, another one gets triggered as long as there is still data in the SQS queue. If data doesn't have to be processed sequentially an option is to configure the AWS Lambda function to get invoked for new data in the SQS queue [1], so you don't have to care about manually fetching data from SQS at all. [1]: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html
- staticassertion 6y agoYep, but I prefer to care about manually fetching data from SQS. It's a weird system, but due to our data model there are many benefits to processing as many messages in a given lambda as possible.
- kondro 6y agoThis might be useful to simplify that model for you :) https://aws.amazon.com/about-aws/whats-new/2020/11/aws-lambda-now-supports-batch-windows-of-up-to-5-minutes-for-functions/ https://aws.amazon.com/about-aws/whats-new/2020/11/aws-lambd...
- staticassertion 6y agoPretty cool, but not quite the model I want.
- jusssi 6y agoNow that someone's listening: I don't mind the 15min Lambda timeout, but it would be great to get rid of the Lambda + API Gateway 30s & ~6MB limits. Those always bite unaware devs in the butt and workarounds for them take quite a bit of effort.
- munns 6y agoYes. But being real, we hear you on this one. I can't comment on API Gateway's roadmap here but this is something both teams is aware of. The reason it is the way it is today is for a valid reason. But this is def something we hear pretty often. - Chris
- k__ 6y agoMake it indefinitly and price exponentially. ;)
- munns 6y agothar be dragons :)
- willcipriano 6y agoI have many workloads where 15 minutes may be just a little too short for comfort. A hour timeout would have me reaching for Lambda more often.
- yeldarb 6y agoAs long as possible. Our jobs usually finish well within the limit but the top 1% hit the limit. One example we've been wrestling with is a merge operation. Usually it's merging about 1000 records which completes in a few seconds. But every once in a while someone kicks off a job that tries to merge 1,000,000 records and it times out. We want the benefits of serverless (scale down to zero, up to infinity at the drop of a hat) but these edge cases mean we're having to evaluate other options. An hour or two would be a good start; then it'd cover 99.9% of requests. With a few hours we could add more nines :)
- BoorishBears 6y agoThat sounds like you need a queue of some sort
- dodobirdlord 6y agoIf your lambda function detects that it is going to hit the timeout you could have it launch a Fargate container to handle the long merge. Fargate is essentially a long-lived Lambda.
- mcintyre1994 6y agoIt’s also probably much easier to share code between those two implementations with the new container based lambdas :)