Hosted DoltDB Launches Replicas

HOSTEDFEATURE RELEASE
4 min read

Dolt is Git for Data. It's a MySQL compatible database with Git-style versioning and branching built in. We launched Hosted Dolt a little over a year ago and since then we've released additional metrics, improved logs, created a sql workbench, added DoltHub integration, backups, and more. Today we're excited to announce the launch of read replicas for Hosted Dolt.

What are Read Replicas?

When you create a Hosted Dolt deployment you can choose to create up to 8 read replicas. Every write to the primary server is replicated to the read replicas. A read replica is a read only server which you can run queries against. Queries that would mutate data such as a sql INSERT, UPDATE or DELETE statement will fail. This allows you to scale your read traffic horizontally. Future releases will allow you to manually fail over to a read replica in the event of a primary server failure for increased availability.

How to Create a Deployment with Replicas

When you create a new deployment you must first select the checkbox Enable Replication. Once this box is checked you are presented with an input box will appear that allows you to specify the number of replicas you want to create. You can create up to 8 read replicas

Create Deployment with Replicas

How to Connect to a Read Replica

After clicking the Create Deployment button you will be taken to the deployment details page. In under 5 minutes your deployment should be up and running and the details of your primary server and read replicas will be displayed on the Connectivity tab.

Replicated Deployment Connectivity

The primary host name for the primary server will be something like orgname-deploymentname.dbs.hosted.doltdb.com and the host names for your replicas will be something like r#-orgname-deploymentname.dbs.hosted.doltdb.com, where the # is the index of the read replica. You can connect to the primary or the read replicas using a mysql compatible client or driver, the only difference being that queries that mutate the database must execute against the primary server.

An Example Session

Below are two terminal sessions. The first session connects to the primary server, creates a database, and a table and then inserts data into the table. The second session connects to a read replica and queries the server to verify that the data written to the primary server has been replicated to the read replica. Finally at the end of the 2nd session I attempt to modify the data on the read replica and the query fails.

Primary Server Session

~>mysql -h"dolthub-replicas.dbs.hosted.doltdb.com" -u"r8logp5vehihnpj9" -p"CUiC4sz0wQ3w2RT6ADKaoONxZjAUZofH"
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9-Vitess

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> CREATE DATABASE db;
Query OK, 1 row affected (0.086 sec)

MySQL [(none)]> USE db;
Database changed
MySQL [db]> CREATE TABLE t (
    -> pk int primary key,
    -> c1 varchar(8));
Query OK, 0 rows affected (0.048 sec)

MySQL [db]> INSERT INTO t VALUES (0,'zero'),(1,'one'),(2,'two'),(3,'three');
Query OK, 4 rows affected (0.048 sec)

MySQL [db]> select * from t;
-+------+-------+
| pk   | c1    |
+------+-------+
|    0 | zero  |
|    1 | one   |
|    2 | two   |
|    3 | three |
+------+-------+
4 rows in set (0.038 sec)

Read Replica Session

~>mysql -h"r01-dolthub-replicas.dbs.hosted.doltdb.com" -u"r8logp5vehihnpj9" -p"CUiC4sz0wQ3w2RT6ADKaoONxZjAUZofH"
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.9-Vitess

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MySQL [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| db                 |
| dolt_cluster       |
| information_schema |
| mysql              |
+--------------------+
4 rows in set (0.038 sec)

MySQL [(none)]> USE db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MySQL [db]> SHOW TABLES;
+--------------+
| Tables_in_db |
+--------------+
| t            |
+--------------+
1 row in set (0.040 sec)

MySQL [db]> SELECT * FROM t;
+------+-------+
| pk   | c1    |
+------+-------+
|    0 | zero  |
|    1 | one   |
|    2 | two   |
|    3 | three |
+------+-------+
4 rows in set (0.041 sec)

MySQL [db]> INSERT INTO t VALUES (4,'four'),(5,'five');
ERROR 1105 (HY000): Database db is read-only.

Changes to Graphs and Logs

Now that a deployment can have multiple servers, we have made some changes to the graphs and logs so that you can specify which server you want to view metrics or logs for. There is a new dropdown menu at the top of the tab that lets you select which server you want to view metrics or logs for.

Graphs and Logs Dropdown

Additionally, there is a new graph that shows the replication lag between the primary server and each read replica. This graph is only available on the primary server.

Replication Lag Graph

Upcoming Features

Hot Standby Failover

As briefly mentioned above, we plan on allowing you to use these read replicas as hot standby failover servers. This will allow you to manually fail over to a read replica in the event of a primary server failure. This will improve your applications fault tolerance and increase the availability of your deployment. Following the release of manual failover later this summer, we plan on releasing automatic failover, which will fail over to a hot standby replica automatically if a failure is detected.

Resize your Deployment

Currently, you can only specify read replicas when you create a new deployment. We will add the ability to resize your existing deployment to add or remove read replicas, to allow you to scale your read traffic up or down as needed. We plan on releasing this some time in June.

Conclusion

We're excited to release read replicas for Hosted Dolt. This is a big step towards making Hosted Dolt a fully featured database as a service. We hope you enjoy this new feature, and we look forward to hearing your feedback. If you have any questions or comments please join our Discord server and let us know what you think.

SHARE

JOIN THE DATA EVOLUTION

Get started with Dolt

Or join our mailing list to get product updates.