Up in The Clouds

So Mastodon’s infamous Media Cache for this instance has stabilised and was running fine for the last two-and-a-half months. Still, the extra volume required some monitoring, and it does cost extra; not a lot, but quite a bit when seen in relation to the vServer’s base cost. So I was looking at the Cloud options again.

Picking a Cloud Service

Initially, I was skeptical about the cloud option, mainly because I wasn’t sure what it would cost me. Since I now have a better idea how much space this instance needs and since it turned out that cloud storage is not so expensive to begin with, I was ready to take the plunge.

In the end, I simply went with the instructions by Thomas Leister and the cloud service he was using, Scaleway. Details will differ between cloud services, whereas the costs are comparable. So if you’re looking for an alternative, try the instructions by Stanislas for Wasabi.

I don’t have much to add to Thomas’ instructions. If you’re looking for a cloud service based in Europe, Scaleway seems like a good option. You can also pick the location of the data center. Their web interface can be a bit overwhelming – just make sure you’re booking the Object Storage. That’s the one you want – ignore all the others.

Then just follow Thomas’ instructions (which sometimes link back to Scaleway’s help pages). Also, make extra sure you replace the default names that Thomas uses with the ones you chose for your instance and your server location. For example, I overlooked the line:

S3_BUCKET=instance-media

Things seemed to work, but all images in posts were missing and instead displayed an “not available” message. So if something is not working as expected, go over all these names, URLs, and keys again carefully. And don’t forget to restart nginx and/or Mastodon itself.

One important bit I learned: You still want to maintain a (small) local cache, since outgoing traffic (i.e. out of the cloud service) costs money. You can avoid having to serve (and therefore pay) for the same file being sent over and over by configuring nginx with a local proxy. Thankfully, both Thomas and Stanislas explain how to do that in their instructions.

Thomas’ instructions cut off a bit abruptly and left me with a “now what?” For that part, switch over to Stanislas, who shows how to check if everything is working using curl. And then concludes: You can now remove your public/system folder on your server! :D

This actually gave me pause. What I had failed to realise was that I was not only moving the cache to The Cloud but also any media that are being uploaded directly onto my instance. This felt a little like losing control over these assets. But then again, I can still download them via the cloud provider’s web interface, if need be. Or do a data export for my account. And it’s not like they were easily accessible in the first place, but buried deep down in some subfolder. So yeah, go ahead and delete that directory (once everything works).

What next?

I still have a problem that sometimes avatars are not loading. My hunch, based on some logfile entries I saw, is that some process is running out of memory when doing this. So I’m considering upgrading to a more beefy vServer. Since the extra cost for the second volume is now gone and the cost for the cloud storage is lower (hopefully), this is something I will look into next.

#MastodonAdventures #RunningMastodon