Automate DB Tasks in JavaScript on AWS

0

Hi,

I currently run a Serverless application using Vercel, and I'm looking for a way to run a scheduled script in AWS.

The script will simply total up some database rows and re-insert them into a database table (Using Node.JS). What's the best way for me to host this on AWS and have it run every ~15 minutes. I'm aware a solution like EC2 would work just running a permanent server that's not serverless, although is there a better way which powers down when not running?

已提問 1 年前檢視次數 217 次
1 個回答
1
已接受的答案

How long does it take to run? If its going to be a large chunk of that 15 minutes, then just having an always on EC2 instance might be best. If its quick, you could have a Lambda function which is triggered once every 15 minutes based on a cron schedule in EventBridge.

You'll want to compare pricing for EC2 instances and Lambda. Keep in mind that for both, a smaller amount of computer is cheaper, but will likely take longer to run. For EC2, that helps with your cost formula (if you're leaving it running), but for Lambda it can sometimes be cheaper to pay for a larger compute environment since you're billed per ms it runs.

For an EC2 instance, you could schedule it to start every 15 minutes, but there are startup and shutdown times involved, so I doubt it would be worth it to start/stop vs a Lambda if the jobs are that short that the extra stopped instance time would be worth it

AWS
已回答 1 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南