Mastodon Self-Hosting: Lightweight Setup for Federating with Threads
This document summarizes everything I did to set up and optimize a self-hosted Mastodon instance, with the specific goal of federating with my Threads account, while keeping system resource usage low. This includes systemd tuning, Sidekiq concurrency adjustments, federation limits, and selective media handling.
Why I Did This
I wanted to stay connected to the fediverse via Threads (which I'm verified on), but without committing fully to a busy Mastodon instance. My intent is not to host a large social server, but to run a minimal and functional one for the purpose of federation — particularly with Threads.
Environment
- Server OS: Debian 11 via YunoHost
- Mastodon install method: YunoHost application
- Shell: SSH with
sudo
access - Mastodon user:
mastodon
(managed by YunoHost) - Instance type: Private/personal use
1. Sidekiq Concurrency Optimization
Goal
Limit Sidekiq's thread usage to avoid high memory and CPU consumption.
What I Did
- Created a systemd override to force Sidekiq to run with only 2 threads (
-c 2
).
Final Working Override
File: /etc/systemd/system/mastodon-sidekiq.service.d/override.conf
[Service]
ExecStart=
ExecStart=/bin/bash -lc 'cd /var/www/mastodon/live && exec bundle exec sidekiq -c 2'
Then reloaded and restarted:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl restart mastodon-sidekiq
Verified With
systemctl status mastodon-sidekiq
Output showed:
"sidekiq ... [0 of 2 busy]"
Which confirmed that Sidekiq is now respecting the -c 2
limit.
2. Disabling Streaming Service
Goal
Reduce resource usage by disabling real-time updates, which are not essential for my use case.
What I Did
sudo systemctl disable --now mastodon-streaming
This turns off the WebSocket-based streaming component, meaning I need to manually refresh pages (or rely on polling from the front-end).
3. Limiting Federation Scope
Goal
Avoid excessive background traffic from large Mastodon instances that I don’t care about. Focus on Threads and maybe a few others.
What I Did
a. Enabled authorized_fetch
Edited /var/www/mastodon/live/config/settings.yml
and added:
authorized_fetch: true
This means only instances I interact with (e.g., Threads) can request data from me.
b. Blocked Large Instances
Using the admin panel at:
https://<my-domain>/admin/domain_blocks
I blocked:
mastodon.social
mastodon.online
mstdn.social
Set to:
- Severity: Suspend
- Reject media: Yes
This prevents those busy instances from pulling posts or federating with mine.
4. Media Processing Preferences
Goal
Keep media handling efficient, but not disabled — I still want to allow video and audio uploads.
What I Chose
- Did NOT disable video/audio transcoding (I want users to be able to upload media)
- Kept default thumbnail sizes: 600x600 (thumbnail), 1200x1200 (preview)
- Disabled media proxying to reduce bandwidth and storage pressure
.env.production
settings
DISABLE_MEDIA_PROXY=true
This means remote images are not cached or served via my server — they’re loaded directly from their source.
5. Sidekiq Concurrency in .env.production (for clarity)
Even though systemd overrides enforce concurrency, I added this to .env.production
as documentation or fallback:
SIDEKIQ_CONCURRENCY=2
This is safe, and it communicates intent in case someone else checks the environment later.
Other Notes
- I used
sudo su - mastodon
to switch to the Mastodon user for commands. - On YunoHost, even the
mastodon
user requiressudo
to edit.env.production
, since it’s owned by root or protected. - The
systemctl edit mastodon-sidekiq
command failed to open a usable editor at first, so I manually created the override file at the correct path. - I did not set up external S3 storage — media is stored locally.
Conclusion
The Mastodon instance now:
- Uses minimal Sidekiq workers (
-c 2
) - Has no streaming server running
- Limits federation to only necessary servers (e.g., Threads)
- Allows audio/video uploads
- Doesn't proxy media (saves bandwidth)
- Is ideal for quiet personal use, especially for verified Threads users like me who don’t want to give up the platform but still want a foothold in the fediverse.