1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4.1 KiB

rqlite

You can find details on the design and implementation of rqlite from these blog posts.

The design and implementation of rqlite was also discussed at the GoSF April 2016 Meetup. You can find the slides here. A similar talk was given to the University of Pittsburgh in April 2018. Those slides are here.

Node design

The diagram below shows a high-level view of an rqlite node.

             ┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐     ┌ ─ ─ ─ ─ ┐
                         Clients                    Other
             └ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘     │  Nodes  │
                            │                     ─ ─ ─ ─ ─
                            │                        ▲
                            │                        │
                            │                        │
                            ▼                        ▼
             ┌─────────────────────────────┐ ┌───────────────┐
             │           HTTP(S)           │ │      TCP      │
             └─────────────────────────────┘ └───────────────┘
             ┌───────────────────────────────────────────────┐
             │             Raft (hashicorp/raft)             │
             └───────────────────────────────────────────────┘
             ┌───────────────────────────────────────────────┐
             │               matt-n/go-sqlite3               │
             └───────────────────────────────────────────────┘
             ┌───────────────────────────────────────────────┐
             │                   sqlite3.c                   │
             └───────────────────────────────────────────────┘
             ┌───────────────────────────────────────────────┐
             │                 RAM or disk                   │
             └───────────────────────────────────────────────┘

File system

Raft

The Raft layer always creates a file -- it creates the Raft log. The log stores the set of commited SQLite commands, in the order which they were executed. This log is authoritative record of every change that has happened to the system. It may also contain some read-only queries entries, depending on read-consistency choices.

SQLite

By default the SQLite layer doesn't create a file. Instead it creates the database in RAM. rqlite can create the SQLite database on disk, if so configured at start-time.

Log Compaction and Truncation

rqlite automatically performs log compaction, so that disk usage due to the log remains bounded. After a configurable number of changes rqlite snapshots the SQLite database, and truncates the Raft log. This is a technical feature of the Raft consensus system, and most users of rqlite need not be concerned with this.