Hi <@U01QEJ9PP53> , all task is almost functional,...
# ask-community
t
Hi @Kevin Kho , all task is almost functional, so then flow in general, in functional. So my question is why not support to deploy Agent on serverless function like AWSLambda, Cloud function,...etc?
k
The agent needs to consistently check Prefect for flows to run. If you want to try running with no agent, you can look at agentless execution here . It might fit your use case? I’ve only seen one other person using it in production
t
I experiment with some potential use cases and come up with this question because the Lambda function is more lightweight I think
j
Serverless execution is on the roadmap for 2022
👍 1
t
Sound great!
n
(apologies if there is a public roadmap I missed, and for resurrecting an old thread) I'm also interested in serverless execution. Do you think that project is slated, generally, for early or late '22? If it's going to be the latter I figure I may play around with agentless execution. I'm fairly new to Prefect but, to that end, does the following sound crazy for flows that may benefit from low cost/high elasticity/low latency and fit within the limitations of Lambda? 1. Bundle prefect on an AWS lambda function 2. Call
prefect run --execute
in Python via subprocess (very meta, I know) 3. (optional) setup retry behavior on AWS to emulate the missing Lazarus functionality
@Anna Geller In searching around the community it seems that you're the go-to Lambda expert! I wonder if you had any thoughts on the above? Apologies if someone has covered this already and I didn't find it
k
We don’t have a public roadmap, but I would say don’t wait for it. I saw one person attempt this, but didn’t hear back. I think it might work but you may get some sluggishness with throughput when using Lambda. Anna would know more. Let’s see if she responds (might be delayed as it’s the weekend)
👍 1
a
@Nicholas Shaffer I would recommend the ECS agent. The underlying compute infrastructure of ECS Fargate containers and Lambda functions is very similar. Both allow you to run your workflows entirely serverless. The benefit of Lambda is that it allows you to trigger your flows event-based (e.g. when a file arrives in S3), ECS doesn’t have that. But to run your flows on schedule and ad-hoc from the UI/API, ECS agent will give you the same result as Lambda and it will work out of the box once the agent is configured. I could share some links if you don’t know how to get started with ECS. Lambda is mostly useful for triggering flow runs event-based.
n
Wow! Thanks for the quick reply! As a follow-on, I think my use case could just as well be solved by using a hybrid ECS or EKS workflow (EC2 for low latency flows, ECS for high). That said, the disposability and elasticity of Lambda is nice. Part of the reason I ask is for generic, asynchronous flows (or tasks, even). Ex. kick off some asynchronous job that handles its own callbacks/exceptions/retries. Seems like overkill to manage EC2 or wait for ECS to spin up. For my purposes I already have lots of infra setup to handle various events in AWS (ex. S3 notifications) and use Step Functions to manage orchestration. I'd love to get off Step Functions and take advantage of all the amazing orchestration Prefect provides, but still have a low latency, free(ish), elastic way to kick off various, self-managing AWS tasks. Basically, to your knowledge 1. Did I totally miss the boat on the Prefect docs and am proposing an anti-pattern? 2. Does the above already exist/do you know if anyone has attempted it?
Shoot. Cross talk. Need to read Anna's reply 🙈
🤣 1
a
I totally understand you, I’ve been in this serverless world for a while and while it’s great and costs close to nothing, at scale it gets really difficult to figure out what is the state of your workflows and how to figure out the root cause when something went wrong. I also heard some horror stories about people who accidentally configured some recursive Lambda callbacks only because they wanted something to retry automatically 🤦‍♀️
honestly, I think that you could start with a single-node AWS EKS cluster. 1 node and 10 cents per hour for the Kubernetes control plane on AWS EKS shouldn’t break a bank. This would allow you to have all the infrastructure needed to get started with a Prefect Kubernetes agent. Then, you could additionally have: • some flows that would get triggered from Lambda event-based • some flows running on EKS invoking your existing Lambda functions you perhaps don’t wanna migrate via LambdaInvoke task This would probably give you the best balance of costs and performance (low latency with always on EKS) + addition of Lambda when it makes sense
n
Love it, very much appreciate the thoughtful response! Yeah I totally agree re: using Lambda as a trigger mechanism. And you're dead on: I could definitely solve this with always on EKS or ECS + EC2 launch. However, I was also looking to avoid the overhead of managing EC2 / not have to worry about elasticity and load balancing (which I may be overestimating, to be honest). I suppose at a higher level I wonder if Prefect is thinking about supporting generic webhooks/callbacks? If I really think about it that's really the only thing keeping some of my workflows on Step Functions, their generic task callback feature is surprisingly elegant (through boto3 or otherwise). My infra has been totally serverless for so long, I'm probably just trying too hard to avoid EC2 management / long polling 🤷‍♂️
a
so with AWS EKS you can have fully managed nodes and AWS will take care of ensuring availability, replacing broken nodes and load balancing when you have more than 1 nodes. You need to decide what is more painful: 1. Latency is painful - you rather pay a bit more and use AWS EKS with fully managed nodes or ECS with fully managed EC2 nodes always on 2. Costs and having always on instances is painful more than latency - go full serverless with Fargate either EKS Fargate or ECS Fargate. Those trade-offs… 😄
n
For real though.. I may take a crack at the meta-subprocess approach on Lambda but, if/when that fails, I bet I'll end up using a hybrid (EC2 + Fargate) EKS cluster. Thanks so much for your help! V excited to see what workflows I can start porting to Prefect. Ya'll are really kicking ass.
🙌 2