The k3S multi-Master supports Mysql, PostgreSql and ETCD, and is now experimenting with an embedded multi-master using an HA version of SQLite – DqLite, dQLite – as the name implies, Distibution SQLite, if stable in the future, may become the official recommended HA solution.
Dqlite does several things:
-
Provide a raft based solution based on a lightweight implementation called C-Raft,
-
Encapsulate SQLite and register a custom driver with its storage tier to manipulate data
-
In CAP theory, like most distributed databases, DQLite chooses CP without A, meaning Consistency and Partition tolerance, without ensuring Availability. That is:
-
Data consistency is ensured
-
Maintain strong consistency. User requests are returned only after they have been consistent across all partitions in the server
-
However, there is no guarantee that every request will receive an error-free response
In general, we use SQLite like this:
The application calls a single-node SQLite instance directly
With DQLite, this is the case
Instead of directly manipulating sqLite’s interface, applications call the interface provided by DQLite, which uses C-RAFT to ensure data consistency and fault-tolerant lines
Currently, a Go binding is officially provided, and dQLite interface can be directly used in GO
The author has a demo presentation showing an example of a distributed oxygen saturation detector written by GO
This code is simple, simulating the insertion of oxygen saturation data and then providing an HTTP interface to query the average saturation back to the caller
Where the getDatabase method, if using single-instance SQLite, looks like this:
So if YOU use DQLite, it looks like this
StartEngine actually creates a new DQLite node by calling the dQLite interface
Then call the DQLite Client interface to connect to the cluster
Inject a DQLite custom driver into the SQLite storage tier
As you can see, using GO to use this HA scheme is still pretty easy to use.
At present, the DQLite HA version of K3S is still in experimental state and should not be used in production environment. There are still some problems, such as:
-
High CPU usage
-
If the first startup node crashes, the leader cannot be elected
Overall, the embedded HA solution of K3S is very desirable, after all, mysql or ETCD programs are still a little too heavy for IOT fly devices
Reference:
-
The author’s speech
-
Go binding and demo
Read more:
- How should a novice choose a cloud server
- Individual players and small and medium enterprise cloud server selection comparison