I'm using Amazon EC2 instance t2.small. And the memory usage is always increasing up to > 90% usage.
$ free -m
total used free shared buffers cached
Mem: 1993 1925 68 0 1 24
+ buffers/cache: 1899 94
Swap: 2047 994 1053
This is my memory usage :
$ps aux --sort=-resident|head -11
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
webapp 8640 9.4 81.1 3223112 1657264 ? Sl Oct24 28:00 puma: cluster worker 0: 9938 [current]
root 9862 0.1 6.7 1057364 137712 ? Sl Oct23 2:50 sidekiq 4.2.10 current [0 of 5 busy]
healthd 2784 0.0 0.9 684904 19360 ? Ssl Oct18 4:25 puma 2.11.1 (tcp://127.0.0.1:22221) [healthd]
root 4057 0.3 0.6 536908 12652 ? Ssl Oct18 29:52 /usr/bin/python2.7 /opt/aws/bin/cfn-hup
nginx 9905 2.6 0.4 156088 9748 ? S Oct23 67:02 nginx: worker process
webapp 9938 0.0 0.1 121660 3800 ? Ssl Oct23 0:05 puma 3.1.0 (unix:///var/run/puma/my_app.sock) [current]
ec2-user 21670 0.0 0.1 117372 2544 pts/0 R+ 02:39 0:00 ps aux --sort=-resident
root 2309 0.0 0.1 276100 2140 ? Ssl Oct18 0:10 /usr/bin/amazon-ssm-agent
ec2-user 15697 0.0 0.1 115488 2124 pts/0 Ss 00:27 0:00 -bash
root 1 0.0 0.0 19692 1800 ? Ss Oct18 0:01 /sbin/init
I can't find out why the webapp memory usage so high and it's always increasing. So for now we set a job to restart the instance once in a hour.
Is there any way I can figure out what causing high memory usage of my webapp? Thank you so much.
Best Answer
There is some discussion here, indicating it may be a memory leak potentially due to ruby version:
https://github.com/puma/puma/issues/342