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개 답변
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
답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠