Auto-stop EC2 on low CPU, then auto-start on HTTPS request — how to keep a “front door” while the instance is off?
dev.to·2d·
Discuss: DEV
🔒Caddy
Preview
Report Post

Hi everyone,

I’m trying to deploy an application on a single EC2 instance and reduce costs by stopping the instance when it’s idle, then automatically starting it again when someone calls my API over HTTPS. I’ve made some progress, but I’m stuck on the last part and would appreciate advice on the right architecture or patterns.

*What I want to achieve * Automatically stop the EC2 instance when it’s idle (for example, CPU utilization < 5%).

When an incoming HTTPS request hits my API:

The EC2 instance should be started automatically if it’s stopped.

The request should eventually be served by the application running on that EC2 instance.

*What I’ve already done * I successfully auto-stop the EC2 instance using a CloudWatch alarm that triggers StopInstances.

I created a…

Similar Posts

Loading similar posts...