Should I Self-host Mastodon?

Should you venture down the self-hosted social media path? I say: yes

Posted by Muddy on January 03, 2023

So you heard about Mastodon, and now you are wondering how to sign up. Mastodon is "not your fathers" social media platform, it is decentralized.

"Well, what does decentralized mean?"

Decentralized means there is no one entity that owns the network. Mastodon is a collection of "Federated" servers, owned by the community. Servers are also linked by Relays. It is similar to the way Email works. Anyone can spin up a Mastodon server and add it to the Fediverse. Servers in the Fediverse are allowed to moderate their own content. Meaning you can tailor your experience to your needs, if you host yourself.

To make things even more complicated, the Fediverse is not just Mastoson servers. Any server that can speak "ActivityPub" (protocol Mastodon uses for federation) can federate with other servers that speak ActivityPub. Some other "federated" social medias are: PeerTube (YouTube alternative), Frendica (Sort of a MySpace/Facebook Vibe), and PixelFed (Instagram Alternative). There are more but I will not go into detail about them here :)

Do I need to self-host?

No! There are actually (at the time of this blog post) about 1800 (Edit: as of 1/2 there are over 4k) instances around the world, each with its own set of rules and moderation. You can choose one of those servers, create an account there and have the same benefits as self-hosting a server.

Even if you join a public server, you can still access content on other servers. This is the whole benefit to the Fediverse, everything is connected and you can choose what you want to see or who you want to follow, even those on other servers.

With the increase of users in the last week (thanks to Elon Musk's hostile changes at Twitter), a lot of public servers have either stopped allowing new accounts, or require a review of new accounts.

Mastodon Stats

<img src="" alt="Markdown Monster icon" style="float: left; margin-right: 10px; margin-bottom: 15px;" />

Self-hosting also takes a fair amount of work. If you don't mind this, it is a great option to ensure you are connecting with the people and servers you want to connect with.

What is required to Self-host?

Bare minimum requirements are:

  1. A cloud provider account (AWS, Digital Ocean, ect.) OR server space at home (if you are like me and have a whole home lab setup)
  2. A domain name (you are required to have a publicly accessible Domain to make this all work. I recommend Cloudflare, as it comes with other benefits such as Proxy and WAF)
  3. An SMTP email service (you can use one of the popular ones, like Mailgun, but if your instance is small, you can also use something like a Gmail account. In my case, I used Gmail as I do not intend to host for more than 5-6 users.)
  4. Your time! (Once you have an instance, you will need to spend time maintaining it! Keep this in mind)

OK, so Self-hosting sounds like it's for me

There are many ways to host Mastodon, the easiest way is to spin up a server in a public cloud platform, such as AWS/Azure/DigitalOcean ect. After you have the server, it is just a matter of installing all the required components and pointing a domain to your instance, and setting up SMTP.

We are not going to use this method today, but I will point you to LearnLinux TV's Video on this subject: https://www.youtube.com/watch?v=2a9YrLsE45Y

In my case, I am using MicroK8s to host in my home lab. You could also install MicroK8s in a cloud instance, but it is not limited to cloud servers. MicroK8s will work on any machine with Linux and Snap installed.

Why MicroK8s?

Unlike K3s, MicroK8s is a production ready, light-weight version of Kubernetes. It was created by Canonical, the maintainers of Ubuntu.

MicroK8s allows for HA (highly-availible) clusters by simply attaching nodes together. Each node runs a copy of the control API and DB, which means if a node fails, the cluster continues to run.

Is it easy to host in MicroK8s?

I could lie and say yes, but honestly it does require some work. Again, if you want easy, the cloud server/vanilla Ubuntu Server will be the easiest option for you.

That being said, if you are looking to dabble in MicroK8s or K8s in general, this is a good way to get your feet wet, and give you a real world example of how applications can scale in K8s.

Storage is the biggest issue. K8s, by design, is best with stateless workloads. If you are not using S3 buckets for storage, it can be a pain. With the addition of Rancher Longhorn, you can make it work, but it does not scale that large. So at scale, I do not recommend the K8s option unless you use some form of either NFS, or S3 storage.

Conclusion

MicroK8s is a fantastic way to host Mastodon. If you have the skills or simply want to learn these skills, I highly recommend installing in MicroK8s. I will be releasing a tutorial soon on how exactly to do this! So stay tuned!