Mastodon is an open source social network similar to Twitter, but it’s decentralized. The network is made of individual servers that are federated (connected). Accounts exist on a single server, but posts and other activity transcend server boundaries.
Understanding the decentralized nature of Mastodon isn’t paramount. Creating and sharing posts is a familiar process. But understanding the three “timelines” will augment the experience.
- Home. Posts from users you follow.
- Local. Posts from users on your server.
- Federated. Posts from users your server is federated with.
We’ll dive into federation, but first let’s explore how posts from users you follow make it to your home timeline.
Before we go deeper, it’s worth noting Mastodon is powered by ActivityPub, an open source social networking protocol. Most of the proceeding is an explanation of how ActivityPub works. Mastodon is just one implementation of it.
Accounts exist on a single server. For example, my account is on fosstodon.org. The server is responsible for storing account data such as posts, likes, and followers. An account can also be referred to as an Actor, as defined by the ActivityPub specification. An Actor has many attributes, but some are of particular note to understanding federation.
- Inbox. Messages received by this Actor.
- Outbox. Messages produced by this Actor.
- Following. Actors this Actor is following.
- Followers. Actors that follow this Actor.
When a user follows another, the respective following and followers fields are updated. Users do not need to be on the same server to follow each other. The definition of a users account resides on a single server, but references can exist on many servers through the following and followers fields. This is why Mastodon’s search behaves differently across servers; the server only knows about users it has seen before.
When a user creates a post, a message is added to their outbox. The message is then pushed to the inbox of all users in the author’s followers collection. These messages are often published cross-server, but can just as easily be published to an inbox on the same server.
The keen observer may note a potential redundancy. If a user has multiple followers on the same server, publishing the same message to each inbox is inefficient. This is where the
sharedInboxfield comes in. Users on a server have the same
sharedInbox, allowing for smart message batching.
When a server routinely publishes posts to another server’s inbox, we consider them federated. This is how posts make their way to the federated timeline. The federated timeline contains unique posts across all inboxes and outboxes on the server. More plainly, it contains all posts the server knows about.
The culmination of this interconnected mesh of federated servers is referred to as the fediverse. Servers are independently hosted, but communicate to produce an experience greater than the sum of its parts.