Looking at the Mastodon Server Code

I’ve spent a few hours over the last couple of nights looking at installing a Mastodon server, and unfortunately it doesn’t seem to be designed to scale, so I can understand why folk are having a rough ride atm. Here are some things I found…

Firstly it doesn’t appear to allow for read-replicas databases to be configured during the setup process. Read replicas can take a lot of the load off the more critical (and lock prone) writeable servers, so not having RRs can cause pain as things scale.

It also doesn’t appear to allow for HTTPS accelerators/terminators. If you set up a mastodon instance you need to have SSL working on every instance. This is a PITA from the viewpoint of certificate renewal and using auto-scaling from a single image, which is painful as you scale.

To scale you’d usually have SSL terminated at the load balancer at the edge of a private network, then unencrypted traffic in the private, secured, network. Folk may find this scary, but if the network is secure, SSL doesn’t offer any real security gains.

Finally, it’s written in Ruby. I’ve worked at companies that used Ruby, it doesn’t scale nicely. Yes, you can run lots of instances to scale up, but it tends to need more hardware per user than many other languages (Go, Java, etc.), especially as Mastodon uses a non-JIT Ruby.

In the end I have ended up with an instance hosted on AWS with a few fault-tolerant feature. If you’re interested in that you can find some more details here.