I'm relatively new to AWS and I've deployed a web app on an EC2 instance located in the us-east-2 region. I've also set up AWS CloudFront as a CDN for this app. My EC2 instance has a public IP address for downloading patches and for SSH access. Plus, I've configured an AWS CloudWatch alarm to restart the server if it becomes unavailable.
Everything worked well for several months, but recently I've noticed that my app becomes unreachable multiple times a day. During these downtimes, I can't even ping or SSH into the EC2 instance, and the public IP address appears unreachable too. After a few hours, the app becomes accessible again, and I'm able to SSH back into the EC2 instance without issue. However, the CloudWatch alarms don't show any problems. Is this behavior normal, or am I missing something in my setup?
4 Answers
I recommend keeping an eye on application logs and EC2 metrics like CPU, network, and memory usage through CloudWatch. Frequent outages often indicate resource starvation or a blockage from another resource. Ensure you have alarms set for metrics beyond just CPU.
Are you using a burstable instance? It might be worth checking if the instance type can handle your app's workload effectively. If it's a burstable instance, resource limitations during high demand could cause the app to become unavailable.
If your web app is relatively static, consider storing your files in an S3 bucket and using CloudFront to distribute them. This setup typically resolves several availability issues. If you're interested, I can point you to some resources that dive deeper into this approach.
One possibility could be that your app has a memory leak or is consuming too much CPU, which makes it unresponsive, similar to how a heavy workload can freeze a laptop. You might want to investigate resource usage patterns.
Related Questions
Cloudflare Origin SSL Certificate Setup Guide
How To Effectively Monetize A Site With Ads