- Newest
- Most votes
- Most comments
There are some troubleshooting guides available to help track down the problem. I think I would start by doing the following:
- Configuring EC2 Serial Console so that I can login when this happens.
- Install CloudWatch Agent to collect OS-level metrics
- Make sure I have a valid backup of the instance using Data Lifecycle Manager or something similar.
My guess is your instance is running out of memory.
That's why it's fine at the start, but as the t2.micro has only 1GB of memory (which isn't a lot) your application may be trying to consume a little bit more memory, and then a little bit more, until it tries to use more memory than is available. It's here that the Linux memory manager comes into play, and will try to swap processes out of main memory and onto disk (it's more complicated, but that's the general gist of it). This in itself is CPU-intensive, and as free memory gets less and less the memory manager will spend more and more of its time (and more and more CPU) trying to free up pages of main memory, leaving fewer and fewer CPU cycles for anything else (including handling SSH requests for login).
I had a very similar issue once, same setup as you (t2.micro running Wordpress and Apache) which would run fine for maybe 2 or 3 weeks and then become unresponsive, and a reboot would bring it back (actually, a better fix was to restart Apache once a week).
Unfortunately the EC2 section of the AWS Console doesn't display metrics for memory use, so right away you can't prove this is what's happening to you. You'll need to setup CloudWatch agent to collect these https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html
Relevant content
- asked 6 months ago
- asked a year ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago