I had no idea how much it would cost to host a Mastodon instance. This is for everyone like I was who’s thinking about running their own server but wants to know what to expect.

Free Radical currently has 62 users. The numbers here are what I pay our small little instance and would certainly jump up if we grew by a factor of 100x.

Current setup

Mastodon, Sidekiq, and one streaming instance run inside Docker. PostgreSQL and Redis run directly in the host OS, with PostgreSQL on its own storage. Assets are uploaded to and served from S3, freeing the compute server to concentrate on dynamic content.

Compute

Free Radical is hosted in Digital Ocean’s SFO2 datacenter. It costs a flat $20 per month for 2GB of RAM, 2 CPUs, 40GB of SSD, and 3TB of transfer. I also use 20GB of block storage for PostgreSQL, at $2 per month.

CPU currently sits at less than 1% busy on avarage, with rare spikes up to 5% or so. At this size, Mastodon and related services take practically no CPU.

RAM usage constantly sits at about 65%. Well, it’s Ruby – that’s expected.

Disk I/O is flat at a few KB/s at most, and disk storage is at about 30%.

Bandwidth seems to be trivial, at a few dozen KB/s.

Compute resource graphs

Conclusion: the current $20 server has lotsof headroom for future growth. I wouldn’t panic if I woke up tomorrow to 10 times the number of users.

S3

In the 10 day window from April 16 to April 26, media storage has grown at a nearly constant rate from about 800MB to about 2.5GB total.

Storage growth over 10 days

If this stays constant, I’ll be adding approximately 5GB of storage per month. In us-west-2 (Oregon), at a cost of $0.023/GB, storage will be nearly free this month but will grow by about $0.12 per month per month. That is, this time next year I’d probably be paying about $1.40 per month to store everything uploaded to date.

Again, that’s assuming a constant rate. I would expect that to scale less than linearly with the number of users, since if two users view the same content, I don’t have to store it twice. Not everyone on an instance will be viewing the exact same content, but there’s still likely to be a lot of overlap.

Conclusion: S3 storage is dirt cheap at this scale. There are also cost reduction ideas, like configuring S3 to automatically move objects to cheaper “infrequent access” storage when no one’s accessed them in a month, or even to delete them altogether after 90 days or so. I’ve got plenty of time to worry about that later.

Backups

I make hourly database backups, compress them with zstd -9, and upload them to S3. This works out to about .3GB of storage per day, but I have a rule to prune backups more than a week old. That should work out to approximately to about $0.05 per month in storage. I think that’s worth it.

Note: I could use zstd -21 instead, but that takes a lot longer and would probably save me about $0.01 per month.

Backup storage growth since yesterday

Summary

It currently costs about $23 per month to host a stable, robust, backed up server easily capable of handling a few hundred users. If I wanted to run a private friends-and-family instance, I could easily trim that down to about $11 by downgrading to a $10 VPS with no block storage, but keeping S3 for media and backup storage.

I’m making a lot of assumptions here and you’re welcome to laugh at me in 6 months if I have to take a second job to pay for this. But I think Free Radical can grow a lot without increasing expenses, and I always have the option of simply turning off new registrations before it gets too large.

Update 2017-05-03

Today I got the first AWS bill that includes my Mastodon S3 bucket. It came to $0.63, of which $0.41 was for transfer.