4 ms·
> Citus has a built-in replication mechanism in which the leader node sends writes to all replicas. However, this requires that the leader is involved in every
by rdtsc 10y ago
> Citus has a built-in replication mechanism in which the leader node sends writes to all replicas. However, this requires that the leader is involved in every write to ensure linearizability. Fortunately, streaming replication provides us with an alternative that we use in Citus MX: Let PostgreSQL handle the replication, removing the need for a single leader.
So, how does Postgres handle it? That is, how does pushing that concern further down the stack work? Does Postgres already have a component which provides robust linearizability in a distributed context? Is it partition tolerant as well?
- fdr 10y agoNothing that fancy: Citus has historically had its own replication method where it writes N copies of the data, explicitly controlled by the coordinator node. This imposes locking overheads and would make a multi-machine writing implementation much more difficult and slower, if one were to implement the synchronization necessary. Citus MX does away with this and gets its redundancy through a series of common-variety Postgres active/passive failover techniques. I plan to write a blog post in the near-ish future on how this works in detail. With the redundancy assumed, Citus merely has to bin a query to the correct single machine servicing that sliver of data. After that, the concurrency characteristics are exactly like regular Postgres. What MX contributes is the metadata synchronization, allowing every node to participate in originating a query or modification.
- rdtsc 10y agoAh ok. Thank you for explaining.