Experiments with Rust CRDTs using Tokio web application framework Axum.

Overview

crdt-genome

Synopsis

Experiments with Rust CRDTs using Tokio web application framework Axum.

Background

Exploring some ideas of Martin Kleppmann, particularly Local-First software.

See this Podcast

Also this conference talk

Scenario

A group of Axum executeables represents a group of Actors.

Each actor process maintains a genome, represented by a CRDT List.

pub struct Genome {
    genes: ListOfGenes,
}

Each process mutates its genome at random intervals and circulates a CmRDT Op using HTTP POST.

The goal is to observe every genome instance converging to a common value.

Caveat

This little system has serious shortcomings. If a process joins late, or drops out and rejoins, or even loses a single POST request, it will never have the full genome.

Execution

see scripts/run-test.sh

to run some actors, first bring the executeable up to date:

cargo build

Then run instances of the executeable

#!/bin/bash
set -euxo pipefail

target/debug/crdt-genome --actor=0 --count=3 --base=8000 2>&1 | tee actor-0.log &
target/debug/crdt-genome --actor=1 --count=3 --base=8000 2>&1 > actor-1.log &
target/debug/crdt-genome --actor=2 --count=3 --base=8000 2>&1 > actor-2.log &
USAGE:
    crdt-genome --actor <actor> --base <base> --count <count>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

OPTIONS:
    -a, --actor <actor>    the actor id of this server
    -b, --base <base>      base port number
    -c, --count <count>    The number of actors

Verification

We want to verify that every genome is converging to the same value.

Since the system is constantly changing, there is no absolute way to do this.

We use HTTP GET to return a string representation of the genome.

$ curl localhost:8000/genome
40fd70816b4f664be2f28766

At a fixed interval, each process polls all the others and compares its genome representation with theirs. For this test, we simply log the result.

$ grep "match" actor-1.log 
Oct 24 15:24:05.500 DEBUG crdt_genome: match count = 6
Oct 24 15:24:10.516 DEBUG crdt_genome: match count = 9
Oct 24 15:24:15.528 DEBUG crdt_genome: match count = 9
Oct 24 15:24:20.540 DEBUG crdt_genome: match count = 9
Oct 24 15:24:25.551 DEBUG crdt_genome: match count = 9
Oct 24 15:24:30.561 DEBUG crdt_genome: match count = 9
Oct 24 15:24:35.573 DEBUG crdt_genome: match count = 9
Oct 24 15:24:40.587 DEBUG crdt_genome: match count = 9
Oct 24 15:24:45.601 DEBUG crdt_genome: match count = 9
Oct 24 15:24:50.613 DEBUG crdt_genome: match count = 9
Oct 24 15:24:55.623 DEBUG crdt_genome: match count = 9
Oct 24 15:25:00.635 DEBUG crdt_genome: match count = 9
Oct 24 15:25:05.646 DEBUG crdt_genome: match count = 9
Oct 24 15:25:10.657 DEBUG crdt_genome: match count = 9
You might also like...
Axum + Connect-Web = ♥️

Axum Connect-Web ⚠️ This project isn't even Alpha state yet. Don't use it. Brings the protobuf-based Connect-Web RPC framework to Rust via idiomatic A

This is a simple Api template for Rust ( Axum framework )

Axum-Rust-Rest-Api-Template This project is an open source Rest Api Template built with Rust's Axum framework. Why this project? I have been learning

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust.

Sauron is an html web framework for building web-apps. It is heavily inspired by elm.
Sauron is an html web framework for building web-apps. It is heavily inspired by elm.

sauron Guide Sauron is an web framework for creating fast and interactive client side web application, as well as server-side rendering for back-end w

Web Application with using Rust(Actix, Diesel and etc)
Web Application with using Rust(Actix, Diesel and etc)

Santa Service App Used technology stack Web Server with using Rust (Actix, Actix-web, Diesel) Data base (Postgres) Console Application (Tokio) Tasks o

A (flash) message framework for actix-web. A port to Rust of Django's message framework.

actix-web-flash-messages Flash messages for actix-web Web applications sometimes need to show a one-time notification to the user - e.g. an error mess

The goal of this repository is to have a real world template of a Rust backend using Axum, Diesel, etc.

Axum Diesel Real-World Example A modular Rust backend template based on the Domain-Driven Design (DDD) architecture, utilizing the Axum and Diesel fra

Build, bundle & ship your Rust WASM application to the web.

Trunk Build, bundle & ship your Rust WASM application to the web. ”Pack your things, we’re going on an adventure!” ~ Ferris Trunk is a WASM web applic

a port of yaxpeax-dis that runs as a web application

this a rough translation of yaxpeax-dis, the CLI tool, to instead accept architectures and data to disassemble as an HTTP request. the package is then deployed to dis.yaxpeax.net as a compute@edge application.

Releases(v0.1.0)
  • v0.1.0(Oct 24, 2021)

    Runnable system. Basic verification

    What's Changed

    • Start-crdt-genome by @dougfort in https://github.com/dougfort/crdt-genome/pull/1
    • replace println with tracing by @dougfort in https://github.com/dougfort/crdt-genome/pull/2
    • add verifier by @dougfort in https://github.com/dougfort/crdt-genome/pull/4

    New Contributors

    • @dougfort made their first contribution in https://github.com/dougfort/crdt-genome/pull/1

    Full Changelog: https://github.com/dougfort/crdt-genome/commits/v0.1.0

    Source code(tar.gz)
    Source code(zip)
Owner
dougfort
programmer
dougfort
Code template for a production Web Application using Axum: The AwesomeApp Blueprint for Professional Web Development.

AwesomeApp rust-web-app More info at: https://awesomeapp.dev/rust-web-app/ rust-web-app YouTube episodes: Episode 01 - Rust Web App - Course to Produc

null 45 Sep 6, 2023
Extremely simple Axum + SolidJS starter for a fullstack web application.

royce Extremely simple Axum + SolidJS starter for a fullstack web application. Deploy immediately with a ready-to-use preconfigured Docker deployment.

null 39 Oct 16, 2024
A highly customizable, full scale web backend for web-rwkv, built on axum with websocket protocol.

web-rwkv-axum A axum web backend for web-rwkv, built on websocket. Supports BNF-constrained grammar, CFG sampling, etc., all streamed over network. St

Li Junyu 12 Sep 25, 2023
Demo of Rust and axum web framework

Demo of Rust and axum web framework Demonstration of: Rust: programming language that focuses on reliability and stability. axum: web framework that f

Joel Parker Henderson 115 Dec 29, 2022
Axum web framework tutorial for beginners.

Axum Tutorial For Beginners Hello web developers! This tutorial will cover how to write simple web applications in rust with axum framework. If you ar

Eray Karatay 46 Jan 5, 2023
Starter template for use with the Leptos web framework and Axum.

Leptos Axum Starter Template This is a template for use with the Leptos web framework and the cargo-leptos tool using Axum. Creating your template rep

Leptos 10 Mar 4, 2023
Ergonomic and modular web framework built with Tokio, Tower, and Hyper

axum axum is a web application framework that focuses on ergonomics and modularity. More information about this crate can be found in the crate docume

Tokio 7.9k Dec 31, 2022
JWT Authentication in Rust using Axum Framework

Are you interested in building a secure authentication system for your Rust web application? Look no further than the Axum framework and JSON Web Tokens (JWTs)! Axum is a fast and scalable Rust web framework that provides a reliable and efficient platform for developing microservices and APIs.

CODEVO 16 Jun 11, 2023
Axum + JWT authentication Middleware that allows you to start building your application fast

axum_jwt_ware Integration Guide Simple Axum + JWT authentication middleware with implemented Login and refresh token. Goal I aim to simplify the proce

Eze Sunday 3 Dec 2, 2023
Layers, extractors and template engine wrappers for axum based Web MVC applications

axum-template Layers, extractors and template engine wrappers for axum based Web MVC applications Getting started Cargo.toml [dependencies] axum-templ

Altair Bueno 11 Dec 15, 2022