Skip to content
Ozan Tezcan edited this page May 18, 2021 · 19 revisions

Status License: BSD

What is Resql?

Resql is a SQL database server that uses SQLite as its SQL engine and it provides replication and automatic failover capabilities.

Why ?

It's mostly about performance and consistency. Resql tries to be as fast as possible without giving up on consistency :

  • Performance : A quick benchmark in wiki : Benchmark
  • Consistency : Resql implements RAFT consensus algorithm and provides exactly-once execution of operations. If you're not familiar with distributed systems, basically, Resql executes client operations one by one. If configured with multiple nodes, it replicates your operations to each node. Once you get an answer from the server for an operation, you can be sure your operation is persisted. If the client retries an operation on a server crash/network issue etc, it's guaranteed that the operation will be executed exactly once.

Features

  • Can be used as a single node persistent database or in a cluster with replication and failover.
  • Light on resources: ~1 MB executable size, can start with a few MB of RAM. Currently, it uses 2 threads only, it'll occupy 2 cores on your machine at most.
  • C, Java and Go clients are available.
  • JSON, Full-Text Search, RTree and Geopoly SQLite extensions are included.
  • Each operation is atomic. Operations can be batched together and sent to the server in one round-trip and executed atomically.
  • Read and write operations can be combined together. e.g. SELECT and INSERT in a single batch.

Limitations

  • Explicit transactions are not supported. e.g. No BEGIN, COMMIT or ROLLBACK. Instead of explicit transactions, you can batch your operations and send them in one go. A batch is executed atomically.
  • Not suitable for long-running analytical queries. e.g. Queries that last tens of seconds.

Build

Resql can be compiled on Linux, macOS and FreeBSD. CI runs on multiple architectures. Big-little endian systems and 32 bit CPUs are supported.

Requirements

CMake, GCC or Clang.

These can be installed via the package manager of your OS.

Ubuntu : apt install gcc cmake  
MacOS  : brew install cmake

Compile

git clone https://github.com/tezc/resql.git
cd resql
./build.sh

Build takes ~ 1 minute. It will create server, cli and benchmark executable under bin/ directory of the current directory.

After the build is completed :

cd bin
./resql

Start command-line interface (CLI) to connect to the server

./resql-cli

Documentation

Get Started

Administration

Clients

Project Layout

bin/     : output dir, ./build.sh will generate server executable and cli here.  
cresql/  : c client
goresql/ : go client
jresql/  : java client
lib/     : dependencies
src/     : server source code  
test/    : server tests
util/    : cli, docker, benchmark tool

Acknowledgements

This project contains code from other open source projects :

  • Sqlite               : Resql uses sqlite as database engine.
  • CRC32C           : A modified version of CRC32C implementation.
  • HdrHistogram : Used in resql_benchmark tool.
  • Linenoise         : Used in resql_cli.
  • Inih                   : A modified version of INI parser, used for the configuration file.
  • Redis               : Functions to get RAM capacity of the machine and RSS value.
Clone this wiki locally