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.

43 lines
4.5 KiB
Markdown

9 years ago
# rqlite
4 years ago
You can find details on the design and implementation of rqlite from [these blog posts](http://www.philipotoole.com/tag/rqlite/) (in particular [this post](https://www.philipotoole.com/replicating-sqlite-using-raft-consensus/) and [this post](https://www.philipotoole.com/rqlite-replicated-sqlite-with-new-raft-consensus-and-api/)).
9 years ago
3 years ago
## Design Presentations
- [Presentation](http://www.slideshare.net/PhilipOToole/rqlite-replicating-sqlite-via-raft-consensu) given at the [GoSF](http://www.meetup.com/golangsf/) [April 2016](http://www.meetup.com/golangsf/events/230127735/) Meetup.
- [Presentation](https://docs.google.com/presentation/d/1lSNrZJUbAGD-ZsfD8B6_VPLVjq5zb7SlJMzDblq2yzU/edit?usp=sharing) given to the University of Pittsburgh, April 2018.
9 years ago
9 years ago
## Node design
5 years ago
The diagram below shows a high-level view of an rqlite node.
9 years ago
5 years ago
┌ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┐ ┌ ─ ─ ─ ─ ┐
Clients Other
└ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ┘ │ Nodes │
│ ─ ─ ─ ─ ─
│ ▲
│ │
│ │
▼ ▼
┌─────────────────────────────┐ ┌───────────────┐
│ HTTP(S) │ │ TCP │
└─────────────────────────────┘ └───────────────┘
┌───────────────────────────────────────────────┐
│ Raft (hashicorp/raft) │
└───────────────────────────────────────────────┘
9 years ago
┌───────────────────────────────────────────────┐
│ matt-n/go-sqlite3 │
└───────────────────────────────────────────────┘
┌───────────────────────────────────────────────┐
│ sqlite3.c │
└───────────────────────────────────────────────┘
┌───────────────────────────────────────────────┐
│ RAM or disk │
└───────────────────────────────────────────────┘
5 years ago
## File system
### Raft
The Raft layer always creates a file -- it creates the _Raft log_. The log stores the set of committed 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 as entries, depending on read-consistency choices.
5 years ago
### SQLite
3 years ago
By default the SQLite layer doesn't create a file. Instead it creates the database in memory. rqlite can create the SQLite database on disk, if so configured at start-time, by passing `-on-disk` to `rqlited` at startup. Regardless of whether rqlite creates a database entirely in memory, or on disk, the SQLite database is completely recreated everytime `rqlited` starts, using the information stored in the Raft log.
5 years ago
5 years ago
## Log Compaction and Truncation
7 years ago
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.