Giter Club home page Giter Club logo

dwal's Introduction

DWAL - Distributed Write-Ahead Log Service

A distributed write-ahead log (aka commit or transaction log) is a system designed to handle the storage, replication, and dissemination of records (log entries) across multiple servers or nodes within a network.

This is a simple implementation of distributed WAL server using GO, protobuffs and gRPC.

For example, Kafka can serve as a kind of external transaction log for a distributed system. The log helps replicate data between nodes and acts as a re-syncing mechanism for failed nodes to restore their data.

It's a fundamental component in distributed systems and databases, ensuring high availability, durability, and fault tolerance.

Core Principles

  • Immutability: Entries in the WAL are immutable once written. This simplifies replication, data recovery, and consistency checks, as logs can be replayed to rebuild state.
  • Append-only: New records are always appended at the end of the log. This ensures efficient writes and straightforward replication across nodes.
  • Sequential Access: Logs are designed for sequential access, making reads and writes efficient, especially for use cases that naturally fit a time-ordered sequence.

Functionality

  • Replication: The log is replicated across several nodes to ensure data availability even in the face of hardware failures or network partitions.

  • Consistency: It helps in achieving consistency across distributed systems through consensus algorithms (like Raft or Paxos) that ensure all copies of the log agree on the current state.

Implementation notes:

gRPC

Protobuf

  • Install protobuf runtime, and compile protobuf with:
go get google.golang.org/protobuf/
protoc api/v1/*.proto --go_out=. --go_opt=paths=source_relative --proto_path=.

Testing

To test the simple JSON WAL server, launch it:

go run cmd/server/main.go

In other tab do POST and GET requests:

curl -X POST localhost:8080 -d '{"record": {"value": "BLA1234567FOOBAR"}}'
curl -X POST localhost:8080 -d '{"record": {"value": "FOO1234567FOOBAR"}}'
curl -X POST localhost:8080 -d '{"record": {"value": "XXX1234567FOOBAR"}}'

curl -X GET localhost:8080 -d '{"offset": 0}'
curl -X GET localhost:8080 -d '{"offset": 1}'
curl -X GET localhost:8080 -d '{"offset": 2}'

dwal's People

Contributors

mfilipav avatar

Watchers

Lucian avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.