- Newest
- Most votes
- Most comments
This issue with your EC2 instance becoming unresponsive during Java builds and Tomcat restarts is likely related to resource exhaustion. Here are some potential causes and troubleshooting steps:
-
Resource Limitations: Maven builds and Tomcat restarts can be resource-intensive. Your EC2 instance might be running out of memory or CPU resources during these operations. Check if your instance type provides adequate resources for your workload.
-
Memory Issues: Java applications and Maven builds can consume significant memory. If the JVM is configured to use more memory than available on your instance, it could cause system-wide issues. Review your JVM settings and consider adding swap space.
-
Check System Logs: Before restarting the instance next time, try to access the system logs through the EC2 console (Actions > Monitor and troubleshoot > Get System Log). Look for out-of-memory errors or other system failures.
-
Status Checks: When the instance becomes unresponsive, check if it's failing status checks in the EC2 console. This can provide clues about whether it's a system-level or instance-level issue.
-
Network Configuration: The issue could be related to network connectivity problems. When building and deploying, there might be DHCP timeouts or other network failures.
-
Monitoring: Set up CloudWatch monitoring to track resource utilization during builds and deployments to identify patterns.
-
Instance Recovery: Consider enabling automatic recovery for your instance, which can help when system status checks fail.
-
Alternative Access Methods: Configure AWS Systems Manager Session Manager as an alternative way to access your instance when SSH is not working.
If the problem persists after trying these steps, consider:
- Upgrading to a larger instance type with more resources
- Optimizing your build process to use fewer resources
- Implementing a more robust deployment strategy that doesn't stress the system as much
When you restart the instance, the issue resolves temporarily because it resets all system states and services, but addressing the root cause will provide a more permanent solution.
Sources
t4g.small instance stops responding | AWS re:Post
Can not ssh to ec2 instance though no alarms and is running | AWS re:Post
EC2 instance randomly fails 1/2 status checks at 4:30 AM with no user activity — SSH and APIs become unresponsive | AWS re:Post
Hello.
As stated in the AWS re:Post Agent's automated AI response, the problem may be caused by memory or CPU load.
After restarting your EC2 instance, check your application and system logs to see if there are any errors related to memory or CPU.
If the problem is due to CPU or memory load, you should consider increasing the EC2 instance size.
By the way, the following document has an example of how to monitor using CloudWatch when hosting Tomcat on EC2, so I recommend that you use this as a reference when monitoring.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Solution-Tomcat-On-EC2.html
Relevant content
- asked 3 years ago
- asked a year ago
- AWS OFFICIALUpdated 4 years ago
