Giter Site home page Giter Site logo

simple-replicated-log's Introduction

Naive Distributed Log System

This project is a basic implementation of a distributed log system with tunable semi-synchronicity for replication.

Prerequisites

Build and run the services:

docker-compose up --build --force-recreate
  • By default, the master runs on port 5000.
  • By default, the secondaries runs on port 5300 and 5301 respectively, but you can change this with the PORT environment variable.


Interacting with the Distributed Log System

To append a message to the log with a write concern of 1 (just the master):

curl -X POST "http://localhost:5000/log?message=YourMessageHere&w=1"

Replace YourMessageHere with the actual message you wish to send. You can adjust the w parameter to specify the write concern (how many acknowledgements are needed before responding).



Iteration 1

Replicated Log Architecture:

Components:

  • Master: Manages the main log and handles replication.
  • Secondaries: Any number can be added; they maintain replicated logs.

Master Server:

  • POST: Adds a message to the in-memory list.
  • GET: Retrieves all messages in the list.

Secondary Server:

  • GET: Retrieves all replicated messages.

Features:

  • Messages are replicated to all Secondaries after each POST on Master.
  • Master waits for an acknowledgment (ACK) from every Secondary before concluding a POST.
  • Introduced a delay on a Secondary to simulate blocking replication.
  • Communication is assumed perfect (no lost messages or failures).

Tech Details:

  • gRPC used for communication between Master and Secondaries.
  • Enabled logging.
  • Deployed Master and Secondaries in Docker containers.


Iteration 2

We need to perform the following tasks:

  • Implement Write Concerns on the primary server.
  • Introduce Artificial Delay for replicas to emulate inconsistency.
  • Handle Messages Deduplication and total ordering on secondary nodes.


Iteration 3

We need to perform the following tasks:

  • Exactly-once
  • Heartbeats
  • Quorum
  • Deduplication
  • Ordering
  • Retry


Changelog

  • Drop docker.override, as it seems to be confusing

  • Drop hardcoded urls from Master, and define them in appsettings

  • Timestamp Handling in Secondary Server:
    Introduced handling for timestamp.Timestamp in the secondary server's Message struct. Modified the AppendMessage and BatchAppendMessages methods to convert timestamp.Timestamp to Go's time.Time for correct timestamp handling. Adjusted logging to format the Timestamp field correctly. HTTP Endpoint for Logs in Secondary Server:

  • Added an HTTP server running alongside the gRPC server in the secondary server.
    Implemented a new HTTP handler (handleGetLogs) to return all logged messages as JSON. Configured the HTTP server to listen on a separate port (default 8080 or as specified by the HTTP_PORT environment variable). Fixing Instance Sharing Between gRPC and HTTP Servers:

  • Corrected the instance sharing issue between gRPC and HTTP servers in the secondary server.
    Ensured that both gRPC and HTTP servers share the same instance of the server struct, allowing them to manage and return the same set of logs. Minor Corrections and Improvements:

  • Made various minor code corrections and improvements, including adjusting logging statements and refining the implementation of server functions for better performance and readability.

simple-replicated-log's People

Contributors

kernel1034 avatar

Watchers

Dmytro Ostapenko 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.