
Deploying a Mastodon/ActivityPub Server: Hardware & Setup Guide
Deploying a Mastodon/ActivityPub Server: Hardware & Setup Guide
The Fediverse has grown rapidly since 2022, with Mastodon leading as the most popular decentralized social platform powered by the ActivityPub protocol. In 2025, thousands of businesses, communities, and individuals run their own Mastodon servers, providing independence from centralized networks. But hosting a Mastodon instance is not trivial — it requires careful planning of hardware, software stack, scaling strategies, and federation rules. This guide provides a step-by-step breakdown for deploying Mastodon on VPS or dedicated servers, with advanced recommendations for sysadmins and developers.
🔹 Hardware & Hosting Requirements
VPS vs Dedicated
- VPS: Suitable for small communities (100–500 active users). Start with 4 vCPU, 8–16 GB RAM, 200 GB NVMe SSD, 2–5 TB bandwidth.
- Dedicated Server: Recommended for medium to large communities (>1,000 users). Choose dual AMD EPYC/Intel Xeon CPUs, 64+ GB RAM, 2+ NVMe drives in RAID1, and 10 Gbps networking.
Storage
Mastodon stores media (images, videos, attachments) locally or on object storage (S3/MinIO). Plan at least 500 GB per 1,000 users, especially if federation pulls remote media.
Networking
- Dual-stack IPv4/IPv6 strongly recommended for federation.
- Low latency peering (AMS-IX, DE-CIX, RoNIX) improves cross-instance performance.
🔹 Core Software Stack
- OS: Ubuntu 22.04/24.04 LTS or Debian 12 (Bookworm).
- Database: PostgreSQL 14+ with pgBouncer connection pooling.
- Caching: Redis for background jobs and session handling.
- Search: Elasticsearch or OpenSearch for full-text search.
- Background Jobs: Sidekiq with Redis.
- Web Server: Nginx (reverse proxy) with Let’s Encrypt SSL.
- Object Storage: MinIO, Wasabi, or AWS S3 for media offloading.
🔹 Installation Steps
- Prepare Server: Update system, set hostname, configure firewall (UFW/iptables).
apt update && apt upgrade -y ufw allow OpenSSH ufw allow 80,443/tcp
- Install Dependencies: Node.js 20, Yarn, Ruby 3.2, PostgreSQL, Redis, Nginx.
- Clone Mastodon:
git clone https://github.com/mastodon/mastodon.git cd mastodon git checkout $(git tag | sort -V | tail -n 1)
- Configure Database & Redis: Create mastodon DB, enable connection pooling with pgBouncer.
- Install Gems & JS Packages:
bundle install yarn install --pure-lockfile RAILS_ENV=production bundle exec rake db:setup
- Environment Variables: Configure
.env.production
with SMTP, S3, secrets, and domain name. - Systemd Services: Enable
mastodon-web
,mastodon-sidekiq
,mastodon-streaming
as background services. - Reverse Proxy: Use Nginx with SSL/TLS 1.3, HTTP/2, and caching for media.
🔹 Scaling & High Availability
Application Scaling
- Run multiple Sidekiq workers for queues (default, mailers, push).
- Use HAProxy/Nginx load balancers to distribute API/web traffic.
- Consider containerization (Docker/Kubernetes) for orchestration.
Database Scaling
- Use PostgreSQL replication for read scaling.
- Run regular VACUUM jobs to maintain DB performance.
- Shard media storage across multiple disks or object storage buckets.
Monitoring
- Zabbix, Prometheus, or Grafana dashboards for DB load, Redis latency, and Sidekiq queue length.
- Alert on federation errors, slow queries, and media disk usage.
🔹 Federation Best Practices
- Domain Reputation: Use DKIM/SPF for email notifications to prevent spam blocking.
- Blocklists: Apply community-maintained blocklists to avoid spam/abuse instances.
- Content Policies: Set clear moderation rules for your instance.
- Media Offloading: Configure object storage to prevent local disks from filling.
🔹 Security & Hardening
- Enable fail2ban for Nginx/SSH.
- Use Let’s Encrypt with auto-renewal for HTTPS.
- Keep Ruby, Node.js, and Mastodon updated monthly.
- Enforce strong passwords or 2FA for admins.
✅ Conclusion
Deploying a Mastodon server in 2025 is achievable for sysadmins with VPS or dedicated hosting experience. The key is to size hardware correctly, configure PostgreSQL + Redis efficiently, and plan for media growth. For communities up to a few hundred users, a VPS with NVMe storage is enough. For larger federated instances, dedicated servers or multi-node clusters are essential. By following best practices in scaling, monitoring, and federation, you can run a resilient ActivityPub server that contributes to the growing Fediverse.
At WeHaveServers.com, we provide optimized VPS and dedicated servers in Romania/EU with NVMe storage, IPv6 support, and low-latency networking — perfect for hosting Mastodon and other Fediverse services.
❓ FAQ
How much RAM do I need for a Mastodon server?
At least 8 GB for small instances (500 users). Larger communities require 32–64 GB RAM with dedicated PostgreSQL.
Is PostgreSQL mandatory?
Yes. Mastodon requires PostgreSQL, not MySQL or MariaDB.
Can I run Mastodon on shared hosting?
No. It requires system-level access, multiple services, and custom tuning. VPS or dedicated only.
How do I back up Mastodon?
Schedule daily PostgreSQL dumps, Redis snapshots, and sync object storage/media volumes.
What’s the best storage option?
Local NVMe for performance + S3/MinIO for scalable media storage.