#Does API function timeout if it’s triggered by multiple cron jobs?

14 messages · Page 1 of 1 (latest)

mental dragon
#

I need to send a newsletter to 20k subscribers. Resend doesn’t yet support bulk email sending, so I want to build my own using Resend, Vercel Cron and Next.js API route.

I am not certain though, will a serverless function timeout if I keep triggering it via cron every second for like half an hour?

plain laurelBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

      🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in <id:customize>

      ✅ You can mark a message as the answer for your post with `Right click -> Apps -> Mark Solution`
      (if you don't see the option, try refreshing Discord with Ctrl + R)
daring cairn
#

Hey @mental dragon your function will time out in 10 or 60 seconds, depending on your plan

mental dragon
#

Yes, but what if I call the same function multiple times, in few secs difference? Wouldn’t it try using the same warm lambda and timeout as a result?

daring cairn
#

It will (most likely, but not 100% guaranteed) use the same warm lambda container.

#

But it will be a brand new lambda function execution

#

And will have the same rules as other lambdas. 10 or 60 seconds of runtime

#

The only thing that may be shared between the lambdas (assuming the warm container was reused) is any variables in global scope

mental dragon
#

Yeah, need to test that out. Want to try avoid using 3rd party tools if possible for now for background jobs.

daring cairn
#

I totally understand

#

Vercel doesn’t make this scenario easy

#

You need some sort of locking mechanism

#

If you’re planning on processing the emails concurrently

mental dragon
#

Yeah… it’s nice they added cron jobs. But queueing system would be perfect. So I don’t need to trigger stupid amount of crons without knowing how long should I keep triggering.