Extremely Slow/Stuck Ubuntu on EC2 (t2.micro)

0

I'm using to t2.micro EC2 instance for hosting a static website for a small business. While trying to upgrade the underlying framework of the website and the upgrading Ubuntu OS and depdencies etc, I must've used large number of CPU hours and IOPS etc.

For few days it worked fine without any performence issue, but lately for past few days, when I run simple commants in Ubuntu Shell (like apt install or even apt remove etc.) to install or remove compoenents within ubuntu then the response has become almost stangnant. I wait hours after after simple command to install a package. During this time the CPU monitoring show the CPU credit as 144 (it shows straignt line at 144 marker in CPU Credits monitoring) and the graph shows there is no CPU utilization during this time i.e., either Linux is not getting any CPU or some other resource limit is not letting the linux do anything even though it has CPU credits. I tried changing my instance from 'standard' to 'unlimited' but still do not see any improvement in the processing speed.

Appreciate any guidance in trying to find out what could be causing this stagnant response within EC2 instance.

asked 11 days ago49 views
2 Answers
2
Accepted Answer
t2.micro EC2 instance for hosting a static website

Since this is a static site, you may want to consider hosting your web files on S3 bucket, and front with Amazon CloudFront.

This option is more secure, performant and scalable as it uses Amazon CloudFront for CDN, and you can request free public HTTPS cert from AWS Certificate Manager (ACM). Solution can be deployed using CloudFormation template from Github. Refer to Get started with a secure static website to get started.

If you still prefer to use EC2 instance, consider replacing your Ubuntu Intel t2.micro (1 vCPU/1 GB RAM) with a new larger Ubuntu Graviton EC2 instance type. There is currently a Amazon EC2 T4g Free Trial, which includes a t4g.small (2 vCPUs/2 GB RAM) instance type for up to 750 hours per month through December 31, 2025.

AWS
EXPERT
answered 10 days ago
profile picture
EXPERT
reviewed 10 days ago
  • Thanks so much, this is extremely helpful. While I'm at this point where my linux is slow, so just for research I will try cloudwatch agent first to see what exactly is the issue causing the slowness (likely it will be RAM) and then definitely will try the T4g free trial and monitor the cloudwatch metrices there as well. Thanks again.

0

The issue you're experiencing with your t2.micro EC2 instance is likely related to resource constraints, particularly CPU and memory limitations. While you've observed that your CPU credits are at 144 and there's no apparent CPU utilization, the problem may be more complex.

T2 instances, including t2.micro, are burstable performance instances designed for workloads with occasional CPU spikes. However, they have a baseline CPU performance, and when you exceed this baseline consistently, performance can degrade significantly.

Even though you've changed your instance from 'standard' to 'unlimited' mode, this doesn't necessarily solve all performance issues. Unlimited mode allows you to burst beyond your CPU credit balance, but it may still not provide enough resources for your workload, especially if memory is the bottleneck.

Your situation sounds like it could be related to memory exhaustion rather than CPU limitations. The t2.micro instance only has 1 GB of RAM, which can be quickly consumed when upgrading the OS, installing packages, or running resource-intensive processes. When the system runs out of memory, it starts using swap space on the disk, which is much slower and can cause the system to appear unresponsive.

To address this issue, consider the following steps:

  1. Monitor your memory usage using tools like 'free' or 'top' to confirm if memory is the bottleneck.

  2. Add swap space to your instance if you haven't already. This can provide some relief for memory-constrained operations, though it's not a long-term solution.

  3. Consider upgrading to a larger instance type with more RAM and CPU resources. A t3.small or t3.medium might be more suitable for your workload.

  4. If possible, optimize your application and upgrade processes to use fewer resources.

  5. For operations that require more resources temporarily, you could consider stopping your instance, changing to a larger size, performing the upgrades, and then scaling back down.

Remember that while t2.micro instances are part of the AWS Free Tier, they are primarily intended for very light workloads or proof of concept deployments. For a small business website that requires regular updates and maintenance, a slightly larger instance type might be more appropriate and cost-effective in the long run.

Sources
EC2 Ubuntu T2.micro seems to be maxing CPU during application installation | AWS re:Post
T2 micro unlimited | AWS re:Post
Problem with ec2 | AWS re:Post

profile picture
answered 11 days ago
profile picture
EXPERT
reviewed 11 days 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