How to Reduce Memory Usage for Rails
bsky Sep 20 Updated on Oct 01, 2018
I was very annoyed with them for using a large amount of a memory.
So I tried the solution proposed by a friend.
Here is an example of our servers 👀
The method was simple but very effective.
Environment: Rails, Puma, Sidekiq
Install jemalloc 🛠
It was very easy in Ubuntu.
apt install libjemalloc
If you couldn't do that, search jemalloc like this.
apt search jemalloc
And then, install that.
Compile Ruby with jemalloc 🛠
RUBY_CONFIG_OPTS=--with-jemalloc rbenv install any.version.of.ruby
Add the following line to service file of Puma 🛠
Add the following line to service file of Sidekiq 🛠
Restart your app! 🏁
Now you can restart your app. And if everything works as planned, enjoy looking at htop!