Preventing High CPU Utilization on AWS EC2 Instances

Optimizing CPU Utilization for AWS EC2 Instances

Question

A web application is running on AWS.

The site runs stateless web servers on three Amazon EC2 instances behind an Application Load Balancer.

The company is receiving complaints from some users about the application performance.

Amazon CloudWatch shows that one of the EC2 instances runs at approximately 90% CPU utilization, while the other two are running at approximately 20% CPU utilization. How can a SysOps Administrator prevent this issue from recurring?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Correct Answer: C.

Here the issue is clearly to do with sticky sessions.

Because of this, all sessions are being directed to one server.

By disabling the sticky sessions the traffic can be load balanced in all three instances.

The AWS Documentation mentions the following.

By default, an Application Load Balancer routes each request independently to a registered target based on the chosen load-balancing algorithm.

However, you can use the sticky session feature (also known as session affinity) to enable the load balancer to bind a user's session to a specific target.

This ensures that all requests from the user during the session are sent to the same target.

Option A is incorrect because adding the fourth instance will not restrict the traffic to target one instance with 90% utilization.

Option B is incorrect because increasing the instance will allow the other two instances to be underutilized.

The load balancer should balance the load of all three instances.

Option D is incorrect because there is no need to check sessions in all the instances.

It is better to check sessions for the instance having maximum utilization.

Restarting the webserver is not the required solution.

For more information on sticky sessions, please visit the below URL-

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/sticky-sessions.html

The correct answer is B: Review the server's performance that supports the web application, then choose a more appropriate instance size and apply the change.

Explanation:

The issue is that one of the EC2 instances is running at 90% CPU utilization, while the other two are running at 20% CPU utilization. This indicates that the workload on the application is not being evenly distributed among the three instances, causing a bottleneck in the system.

To prevent this issue from recurring, the SysOps Administrator needs to identify the root cause of the problem and take corrective action. One way to do this is to review the server's performance that supports the web application, and then choose a more appropriate instance size and apply the change.

A more appropriate instance size may be required to handle the workload more efficiently. For example, the Administrator could choose a larger instance size for the EC2 instance that is currently experiencing high CPU utilization. Alternatively, the Administrator could choose to distribute the workload among more EC2 instances, which would allow the application to scale horizontally and better handle incoming requests.

Manually provisioning a fourth EC2 instance and adding it to the Application Load Balancer (Option A) is not the best solution because it does not address the root cause of the issue. Adding another EC2 instance may help to distribute the workload, but it does not solve the underlying problem of uneven workload distribution.

Disabling sticky sessions on the Application Load Balancer and checking CloudWatch to confirm that the issue has been resolved (Option C) is not the best solution because sticky sessions are used to maintain user sessions with a specific EC2 instance. Disabling sticky sessions could potentially cause user sessions to be lost and create new issues.

Reviewing the number of sessions from the Application Load Balancer to each web server and restarting any web server that has significantly more sessions to even out the load (Option D) is not the best solution because it assumes that the workload is evenly distributed across the EC2 instances, which is not the case in this scenario. Restarting a web server will not necessarily distribute the workload more evenly.