Background processing + notification
I have a business need where I need the client to send a request to a server and run a process that takes a long time (say 30 mins per process, imagine generating huge pdfs here), and once it's done the client should be notified. As per my understanding of serverless, this isn't possible because there's a timeout on the lambda functions. I was wondering what solutions are common to a typical problem like this. What I had in mind was using a queue, and some kind of notification service. I have never done this before so I'd appreciate any help! TIA.
24 Replies
i think i know one way but you need to be sure that he will not close the tab
Web worker
it will not block client side
not possible. They should be allows to close the tab
you can create a chrome extension but then they are not allow to close browser but can tab
I wouldn't do either of those.
If lambdas work for you ( 15 minute max runtime) that could be an option. If you need more time you can spin up ec2s to handle it then kill them once done. Another option would be step functions which would just let you circumvent that 15 minute limit.
You can also set up a server that'll just do the processing that consumes a message queue or work queue
How can I get lambda to work in this case?
You'd invoke a lambda function that would handle the processing for you
With t3 I usually just write functions
well with vercel they have much stricter runtimes i think
Im using AWS directly
so I have 15 mins
perfect
do you have any tutorial that you recommend
i didnt know you could close tabs about 15 minutes and it will proccesed 😳
Let me dig something up
Nah this kind of stuff should prob be handled on your own services for a proper user experience
Thats just really it
yeap
and a chrome extension is just too much of a burden to get the user to use your service
agreed
Thanks keef
A server that does thing for you is easy and lambdas are even easier tbh
let me know what you find
let me find a resource
that is true, my answers arent right my bad, i think i havent read the question right then
Nah its okay
So I think just creating a provider like this: https://github.com/nramkissoon/t3-s3/blob/main/src/server/aws/s3.ts
and following this should probably do it for you
https://docs.aws.amazon.com/lambda/latest/dg/example_lambda_Invoke_section.html
GitHub
t3-s3/src/server/aws/s3.ts at main · nramkissoon/t3-s3
Example create-t3-app with AWS S3 presigned URL integration - t3-s3/src/server/aws/s3.ts at main · nramkissoon/t3-s3
Invoke a Lambda function using an AWS SDK - AWS Lambda
Invoke a Lambda function using an AWS SDK
I'll see if i find something more hand holding, I really just worked with aws sdk using go and you just connected to aws then invoked your functions using args
And for notifications you can apply the same thing that'll send an email or whatever flavor of your notification you dream up
ok thanks
more hand holding would be nice lol