Dolt Replication Options

REFERENCE
3 min read

Dolt is the world's first and only version controlled SQL database. An important feature of modern databases is replication: enabling writes to multiple database instances. Replication is used for scalability, performance, and disaster recovery. Dolt implements two different forms of replication. Dolt can also be used as a replica of an existing MySQL instance. Which replication option is best for you? This blog attempts to explain your options.

Dolt Replication

What is Replication?

Replication is a database feature that allows database writes (ie. inserts, updates, deletes, creates, drops, and alters) to a primary copy of a database to be replayed on multiple other secondary copies of a database. Replication can be synchronous: fail the write if it fails to replicate. Or, replication can be asynchronous: if the write to the primary succeeds, make a best effort attempt to replicate the write in the background.

Why do you need Replication?

Scalability

Traditional SQL databases like Dolt scale to the load a single host can handle. Replication allows you to offload read traffic to other, additional hosts. At the limit, replication allows your primary database to scale to the load of writes as your replicas can handle all read traffic.

Disaster Recovery

If your primary database loses power or network connectivity, any application that relies on it will break. In this failure case, replication allows applications to continue to read from the database but not perform any writes. In disaster situations, you may have the option to fail over to a read replica and make that your new primary.

Performance

Related to scalability is performance. If you have expensive queries that consume most of the resources on your primary, other queries will slow down. Replication allows you to offload those expensive queries to a read replica ensuring your primary database has enough resources to maintain performance on other queries.

Dolt <=> Dolt Replication

Dolt has two options for replicating your primary Dolt database to another Dolt database: Standby Replication and Remote-based replication. Standby replication is newer and likely preferable for most use cases. Remote-based replication is still useful for some use cases especially those where you have a Dolt remote already. Remote-based replication can be done asynchronously.

Standby Replication

Standby Replication

Standby replication was launched in October 2022.

Standby replication leverages a new feature where a running Dolt server can act as a remote. Standby replication is configured via Dolt server configuration. A Dolt server is configured as either a primary or standby and must know about every other Dolt server in the cluster.

Pros:

  • Speed. No remote middleman.
  • The Hosted Dolt option. Makes replication easy and managed.
  • Failover hooks. Dolt procedures provided for failover.
  • Replicates all writes, not just commits.

Cons:

  • Adding a replica requires configuration changes on all servers.
  • Replicates everything always.
  • No asynchronous option.

For more information see our Documentation on Standby replication.

Remote-based Replication

Remote-based replication

Remote-based replication was launched in October 2021.

Remote-based replication leverages dolt push and dolt pull in conjunction with a Dolt remote to perform replication. It is configured via Dolt system variables. It is more flexible than standby replication.

Pros:

  • Leverages a remote which you may need anyway.
  • Allows for additional collaboration features via remote.
  • Customizable. Only replicate specific heads.
  • Adding or removing replicas requires no coordination with existing servers.
  • Can replicate asynchronously and do catch up.

Cons:

  • Slower than cluster-based.
  • More moving pieces. Lots of configuration.
  • No failover hooks.
  • Only replicates commits.

For more information see our Documentation on Remote-based replication.

Dolt <=> MySQL Replication

Dolt is MySQL-compatible. You use a MySQL client to connect to it. Thus, Dolt can be configured to be a replica of your existing MySQL database. Dolt can consume a MySQL binlog so it works just like any other MySQL replica. Dolt currently does not produce a binlog. When it does, you could replicate a branch to MySQL.

Replicate from MySQL

Dolt binlog replication

Dolt replication from MySQL was launched in February 2023.

In this mode, Dolt consumes a MySQL binlog. Your Dolt replica behaves exactly like a normal MySQL replica. However, each replicated write becomes a Dolt commit. This gives you some version control features on your Dolt replica like an audit log of every cell and powerful rollback capabilities.

Pros:

  • Easy and safe way to get started with Dolt.
  • Audit log of every cell on your replica.
  • Powerful MySQL rollback capabilities.

Cons:

  • Not full Dolt feature set. Merges to main branch break replication.
  • Requires a MySQL primary.

Read more about a versioned MySQL replica in our Getting Started Guide.

Replicate to MySQL

Dolt To MySQL Coming Soon

Dolt currently does not produce a binlog. When it does, you could replicate a Dolt branch to MySQL. This would give you the read performance of a regular MySQL database for that branch while maintaining the Dolt version control features on your primary where they are most useful.

Conclusion

As you can see, Dolt is a modern SQL database complete with replication features. We recommend using Standby replication to make Dolt replicas. If you are using MySQL, a Dolt replica is always a good idea to give your MySQL an audit log of every cell and powerful rollback capabilities. Having a MySQL replica of a Dolt branch is a feature we will eventually build. Interested in learning more? Want a MySQL replica of your branch now? Come talk to us on our Discord.

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.