High Memory ,CPU Usages by c4.large Amazon Linux

0

We have observed that the process on our c4.large instance is consuming a significant amount of memory. Specifically: Total Memory Used: Approximately 2.5 GB out of 3.6 GB. CPU Usage: CPU usage 50% We are experiencing high CPU and memory usage on your Amazon Linux c4.large instance but cannot identify the culprit using top or htop We aslo verify no services or cron running behind and instance shows zero CPU and memory usage right after a reboot but then gradually starts consuming resources again

asked 2 months ago103 views
3 Answers
1
Accepted Answer

Hi

  • Use top or htop to identify processes consuming the most resources.
  • Check system logs for error messages.
  • Monitor network and disk I/O.

This command will list all running processes, including their user, PID (process ID), CPU usage, memory usage, and command.

Filtering:

To focus on CPU-intensive processes:

ps aux | sort -k3 -r | head

By following these steps, you should be able to effectively troubleshoot and resolve high CPU and memory usage on your instance.

profile picture
EXPERT
Sandeep
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 3260 0.0 0.4 725356 17716 ? Ssl 12:29 0:00 /usr/bin/amazon-ssm-agent root 3262 0.0 0.4 682420 17020 ? Ssl 12:29 0:00 /usr/sbin/rsyslogd -n root 1818 0.0 0.3 47260 12080 ? Ss 12:29 0:00 /usr/lib/systemd/systemd-journald root 3078 0.0 0.3 272816 12084 ? Ss 12:29 0:00 /usr/sbin/httpd -DFOREGROUND root 3421 0.0 0.2 150628 8476 ? Ss 12:29 0:00 sshd: ec2-user [priv] root 2986 0.0 0.1 98688 4456 ? Ss 12:29 0:00 /sbin/dhclient -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid -H ip-172-31-42-185 eth0 root 3033 0.0 0.1 98688 4108 ? Ss 12:29 0:00 /sbin/dhclient -6 -nw -lf /var/lib/dhclient/dhclient6--eth0.lease -pf /var/run/dhclient6-eth0.pid eth0 -H ip-172-31-42-185 rngd 2748 0.0 0.1 96348 4808 ? Ss 12:29 0:00 /sbin/rngd -f --fill-watermark=0 --exclude=jitter postfix 3208 0.0 0.1 90472 6836 ? S 12:29 0:00 qmgr -l -t unix -u

    gettin this only but i did not understand why cpu 50%

1

Hello.

Is it possible to run the "ps" command below to identify the process with high CPU usage?
Also, what kind of applications are you running on EC2?

ps aux
profile picture
EXPERT
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
  • The issue is when i used this command cpu total usages showing 50% but in services wise no one utiliztion that much

0

Check for Memory Leaks and Diagnose Memory Leaks in Applications: If you have custom or third-party applications running on the instance, they might be leaking memory. Use tools like valgrind, memcheck, or heaptrack to track memory allocations and identify leaks in your application .

Also Check for Zombie Processes: Zombie processes don't usually consume a lot of memory, but they can accumulate if parent processes don’t properly handle child processes. Use

 ps aux | grep 'Z' to check for zombies.
profile picture
EXPERT
answered 2 months ago
  • No zombies process is running , only issue is when is used top,htop aur ps aux , no service is showing high cpu consumtion but overall and also in aws console 50% used

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