0

I'm using Amazon EC2 instance t2.small. And the memory usage is always increasing up to > 90% usage.

Memory usage > 90 %

$ 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.

0

There is some discussion here, indicating it may be a memory leak potentially due to ruby version:

https://github.com/puma/puma/issues/342

  • I'm using ruby v2.3.1 & puma 3.1.0. Seems like this memory leak problem has no solution yet.. Thank you for the info – Adrian Rotama Oct 25 '18 at 3:29
  • Good luck! Memory leaks are a terrible problem to have to deal with :( – guzzijason Oct 25 '18 at 3:55
  • In the past I've had cron jobs restart services that had memory leaks. It's not a good solution, and it takes the service down occasionally, but it's a stopgap until a proper solution can be found. – Tim Oct 25 '18 at 7:36
  • @tim Yes currently I'm also using cron jobs to restart the service, and sometimes my service got 503 error when restart process occurred. What proper solution you use at that time Tim? – Adrian Rotama Oct 26 '18 at 0:10
  • The proper fix is likely to wait until Ruby is fixed, or maybe go down a version to one that doesn't have the bug. – Tim Oct 26 '18 at 4:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.