Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 299f479

Browse files
nolanlawsonGargron
authored andcommitted
Update Tuning.md to add jemalloc instructions (mastodon#694)
I run jemalloc on all my instances, as do some other admins.
1 parent 6601300 commit 299f479

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Running-Mastodon/Tuning.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Table of contents:
88
- [Using nginx proxy caching](#using-nginx-proxy-caching)
99
- [Using a separate Redis for the Rails cache](#using-a-separate-redis-for-the-rails-cache)
1010
- [Using read replicas](#using-read-replicas)
11+
- [Using jemalloc](#using-jemalloc)
1112

1213
___
1314

@@ -228,3 +229,28 @@ production:
228229
```
229230

230231
Make sure the URLs point to wherever your PostgreSQL servers are. You can add multiple replicas. You could have a locally installed pgBouncer with configuration to connect to two different servers based on database name, e.g. "mastodon" going to master, "mastodon_replica" going to the replica, so in the file above both URLs would point to the local pgBouncer with the same user, password, host and port, but different database name. There are many possibilities how this could be setup! For more information on Makara, [see their documentation](https://github.com/taskrabbit/makara#databaseyml).
232+
233+
## Using jemalloc
234+
235+
Using [jemalloc](http://jemalloc.net/) can decrease the memory usage of the Ruby processes in your Mastodon instance, in particular the Sidekiq and Web processes. (See [this toot](https://toot.cafe/@nolan/99181460393222415) and [this toot](https://x0r.be/@szbalint/99128946006465749) for admin testimonials.)
236+
237+
First, check if you have `jemalloc` installed. It should be somewhere like this:
238+
239+
ls /usr/lib/x86_64-linux-gnu/libjemalloc.so.1
240+
241+
If it's not installed, you may need to run:
242+
243+
sudo apt install libjemalloc
244+
245+
Then to enable `jemalloc`, add this line to both `mastodon-sidekiq.service` and `mastodon-web.service`:
246+
247+
```
248+
Environment="LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so.1"
249+
```
250+
251+
Restart both processes, and enjoy the extra headroom!
252+
253+
```
254+
sudo systemctl daemon-reload
255+
sudo systemctl restart mastodon-web.service mastodon-sidekiq.service
256+
```

0 commit comments

Comments
 (0)