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 Answer
1
Accepted Answer

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
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions