Mastodon server operators often face unexpectedly high bandwidth costs due to outbound federation traffic. Every time a user on your instance views a remote post or follows an account on another server, your server downloads and then re-uploads that content to your local users. This duplication of data can cause your outbound traffic bill to spike significantly, especially on smaller instances with limited budgets. This article explains the primary causes of high outbound traffic in Mastodon federation and provides practical steps to reduce it without breaking your users experience.
Key Takeaways: Reduce Mastodon Outbound Bandwidth Costs
- Preferences > Administration > Server Settings > Content Retention: Automatically delete media from remote instances after a set number of days to reduce re-upload traffic.
- Preferences > Administration > Server Settings > Federation > Media Cache: Disable or limit the media cache for remote content to prevent local re-distribution of large files.
- Preferences > Administration > Server Settings > Federation > Domain Blocks: Block high-traffic or unwanted domains to stop their content from being fetched and re-broadcasted.
Why Federation Traffic Is Expensive for Mastodon Instances
Mastodon uses the ActivityPub protocol to communicate between servers. When a user on your instance follows a remote account or boosts a remote post, your server fetches that content from the remote instance. Your server then stores a copy of that content and delivers it to all local users who follow the same remote account or are mentioned in the post. This process is called re-broadcasting or fan-out delivery.
The outbound traffic is the data your server sends to other instances. Each time your instance delivers a post to a remote server, the full content including text, media attachments, and metadata is transmitted. If your users follow many active accounts on large instances like mastodon.social, your server may send the same post to hundreds of remote servers. This multiplication effect is the root cause of high outbound traffic bills.
Media Files Are the Main Driver of Bandwidth Costs
Text content in Mastodon posts is small, typically a few kilobytes. Media attachments such as images, videos, and audio files are much larger. A single video can be tens of megabytes. When your server fetches a remote post with a video, it downloads the file and then uploads it to every remote server that needs it. If that video is boosted by several users on different instances, the upload cost multiplies quickly.
Unnecessary Federation With Inactive or Unwanted Instances
By default, Mastodon federates with all instances that are not blocked. This means your server may be sending data to instances that have no users interested in your content. Additionally, some instances are known for generating large volumes of spam or low-quality content that still consumes bandwidth. Blocking these domains reduces outbound traffic immediately.
Steps to Reduce Mastodon Federation Outbound Traffic
- Configure Media Retention Settings
Go to Preferences > Administration > Server Settings > Content Retention. Set a retention period for remote media files. For example, set it to 30 days. After 30 days, your server automatically deletes locally cached copies of remote media. This prevents your server from re-uploading old media files when a remote post is boosted or referenced again. This is the single most effective change for reducing outbound bandwidth. - Disable Media Cache for Remote Content
In Preferences > Administration > Server Settings > Federation, find the Media Cache option. Uncheck the box that says Cache remote media. When disabled, your server will not store copies of remote media files. Instead, when a local user views a remote post, the media is loaded directly from the source server. This eliminates the re-upload cost for media entirely. Note that this may slow down media loading for your users because they rely on the remote server availability. - Block High-Traffic or Unwanted Domains
Go to Preferences > Administration > Server Settings > Federation > Domain Blocks. Add domains that generate excessive traffic or that are not relevant to your community. For example, block instances known for spam or instances with very high activity that your users do not follow. Use the Suspend action for full blocking. This stops all incoming and outgoing federation with that domain. - Limit Local User Follows to Remote Accounts
Encourage your users to follow accounts on instances that are not bandwidth-heavy. You can also set a limit on the number of remote accounts a local user can follow. This is configured in Preferences > Administration > Server Settings > Limits. Set a maximum follows per user. While this may reduce user engagement, it directly caps the number of remote deliveries your server must handle. - Use a Content Delivery Network for Media
If your instance serves a lot of media to users, consider using a CDN like Cloudflare or Bunny.net. While this does not reduce outbound federation traffic directly, it offloads the delivery of media to your users from your server. This can lower your bandwidth bill if you pay per gigabyte. Configure the CDN to cache media assets with a long expiration time, such as 7 days. - Monitor Bandwidth Usage With Analytics
Install a monitoring tool like vnstat or iftop on your server to track real-time bandwidth usage. Identify which instances are consuming the most outbound traffic. Use the Domain Blocks list to block the top offenders. Repeat this monitoring weekly to catch new high-traffic instances early.
Common Issues After Reducing Federation Traffic
Media Not Loading for Users After Disabling Cache
When you disable the media cache, remote media loads directly from the source server. If that server is slow or offline, users see broken media placeholders. To mitigate this, inform your users about the change in a server announcement. You can also set a short cache time, such as 1 hour, instead of disabling it completely. In the Federation settings, set Media cache retention to a low value like 1 day.
Users Losing Access to Content From Blocked Instances
Blocking a domain stops all federation with that instance. Users who follow accounts on that domain will no longer see new posts from those accounts. Before blocking a domain, check if any of your users follow accounts there. You can use the Admin interface to list remote accounts followed by local users. If only a few users are affected, consider asking them to unfollow those accounts instead of blocking the entire domain.
Bandwidth Reduction Is Not Immediate
After applying retention changes, existing cached media is not deleted until the retention period expires. If you set a 30-day retention, the old media remains and continues to be re-uploaded for 30 days. To see immediate bandwidth reduction, manually clear the media cache. Run the following command on your server: RAILS_ENV=production bin/tootctl media remove --days=0. This deletes all cached media immediately. After that, only new media will be cached and retained according to your new settings.
Comparison of Outbound Traffic Reduction Methods
| Method | Impact on Bandwidth | User Experience Impact | Ease of Implementation |
|---|---|---|---|
| Media retention period | High reduction after retention expires | Minimal; old media may become unavailable | Very easy; done via admin UI |
| Disable media cache | Immediate and high reduction | Moderate; media may load slower | Easy; one toggle in admin UI |
| Block high-traffic domains | Moderate to high depending on domain | Users lose access to blocked instance content | Moderate; requires monitoring and user communication |
| Limit remote follows per user | Moderate; caps number of deliveries | Moderate; users may be restricted | Easy; set a number in admin UI |
| CDN for media delivery | Reduces server outbound but not federation traffic | Positive; faster media loading | Moderate; requires DNS and CDN setup |
By implementing a combination of media retention, domain blocking, and user limits, you can significantly lower your Mastodon outbound traffic bill. Start with the media retention setting because it requires no user communication and has the highest impact. Monitor your bandwidth usage weekly using tools like vnstat and adjust your domain block list accordingly. For advanced control, consider using the bin/tootctl media remove command to purge old media immediately after changing retention settings.