Last active
April 10, 2023 01:48
-
-
Save ThomasLeister/64a8ff3e86574aafb29bf6653633894c to your computer and use it in GitHub Desktop.
How to install jemalloc and save RAM on your Mastodon instance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### If you set up your Mastodon instance before 9th of June 2018, you probably | |
### might not have jemalloc active on your Ruby setup. Jemalloc changes the way Ruby | |
### allocates memory and saves up RAM. On my 140 users instance RAM usage dropped by 300 MB just by using jemalloc. | |
### This is how to set it up on Debian 9 Stretch: | |
### As root, install libjemalloc-dev: | |
apt install libjemalloc-dev | |
### Change to mastodon user: | |
su - mastodon | |
### Check your active ruby version and if there maybe is a new version recommended in the Mastodon Production Guide: | |
### https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Production-guide.md#dependencies-that-need-to-be-added-as-a-non-root-user | |
### (see rbenv install command). At the time of writing my server was running on Ruby 2.5.0, but version 2.5.1 | |
### was recommended. Therefore I did not recompile the old Ruby version, but the new one instead: | |
RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.5.1 | |
### Make sure you're on the latest Ruby version: | |
rbenv global 2.5.1 | |
### Leave mastodon user and restart all the services: | |
exit | |
systemctl restart mastodon-sidekiq | |
systemctl restart mastodon-streaming | |
systemctl restart mastodon-web | |
### DONE! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment