How do I troubleshoot slow connections to a website hosted on my EC2 instance?
Last updated: 2020-12-07
I'm running a public website on my Amazon Elastic Compute Cloud (Amazon EC2) instance. Connections to my website are slow. How do I resolve this?
Over-utilization of your instance's resources might cause slow connections to a website hosted on the instance. Check the following to make sure that you aren't over-utilizing your instance's resources:
- Check the instance's system log for exhausted memory or disk full errors.
- Make sure that the instance's system log indicates the web service started correctly and is running.
- Make sure that the instance is within CPU utilization limits
- Make sure that the Amazon Elastic Block Store (Amazon EBS) volume attached to the instance hasn't hit the IOPS or throughput limits.
Check the instance's system log for exhausted memory or disk full errors
- Check the instance's system logs for errors such as "Out of memory: kill process".
- Check the instance's system logs for error such as "oom-killer, "failure to fork", or other insufficient memory errors. For more information, see How do I tune memory allocation for an Apache web server running on an Amazon EC2 Linux instance?
- Check the instance screen shot for errors.
Note: You might see out of memory or other insufficient memory errors if you're using docker containers, cgroups, and so on. These errors might be intentional due to your configuration.
Make sure that the instance's system log indicates the web service started correctly and is running
Reboot the instance and check to see your web service started normally or look for any errors that might prevent the restart.
Make sure that the instance is within CPU utilization limits
For T2 or T3 instances, check the CPU credit metrics in the CloudWatch metrics table to determine if the CPU credits are at or near zero. If the CPU credits are at zero, the CPUUtilization metric shows a saturation plateau at the baseline performance for the instance. The baseline performance might be 20%, 40%, or so on, depending on the instance type.
For information on resolving this issue, see My EC2 Linux instance failed the instance check due to over-utilization of its resources. How do I troubleshoot this?
Make sure that the Amazon Elastic Block Store (Amazon EBS) volume attached to the instance hasn't hit the IOPS or throughput limits
Verify that your EBS volume isn't hitting IOPS limits. If your volume hits its IOPS limit, latency increases, which negatively impacts your website. For information on optimizing volume performance, see How do I optimize the performance of my Amazon EBS Provisioned IOPS volumes?
If you're using a GP2 volume, check that your volume hasn't exhausted the burst credits.