3 ms·
What is the biggest resource bottleneck in Mastodon? Like, are the certain design decisions that could be optimised to make it more resource efficient? Is it j
by weavie 3y ago
What is the biggest resource bottleneck in Mastodon?
Like, are the certain design decisions that could be optimised to make it more resource efficient? Is it just because it is written in Ruby? Is there something inherent to ActivityPub that means it has to use a lot of resources? Can work be done to make it cheaper to run?
- simonw 3y agoActivityPub involves a HUGE number of HTTP requests. Every time you create a post your server has to deliver that post via HTTP to every other instance that has at least one of your followers - this can quickly grow to hundreds of deliveries if you have a few thousand followers. Mastodon uses a Sidekiq queue and Ruby threads to handle these deliveries. I have a strong hunch that switching to delivery through a more efficient mechanism - async IO, or a lower level language - could have a big impact there. My web browser doesn't blink at loading 100 resources to render a web page, so delivering a few hundred HTTP requests shouldn't be impossibly hard to scale, even when you take retries into account.
- weavie 3y agoI see. So essentially the issue is built in to the way Activity Pub is designed. It is a scaling issue. Your browser may not blink at loading 100 resources, but say you were constantly reloading 100s of tabs, it would start to grind down. Rewriting in a more efficient language would help, but that would just mean it would start to grind down when you have 20,000 users rather than 10,000. I'm surprised it doesn't do some kind of batching peer to peer communication instead. Maybe that wouldn't be as real time. Thanks for the insight.