Skip to content

Educational project for exploring core concepts of distributed systems and networking (NO FRAMEWORKS).

Notifications You must be signed in to change notification settings

abdel-rahmanSalem/distributed-key-value

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Distributed Key-Value Store

Table of Contents

Project Overview

This educational project demonstrates a distributed key-value store using raw TCP connections with Node.js and TypeScript. It is designed to help you understand the principles of distributed systems, low-level networking, and CLI-based interaction.

Features

  • Distributed Architecture: Operates across three nodes to ensure data consistency.
  • Command Support: Implements basic commands like GET, SET, UPD, and DEL.
  • Node Failure Detection: Monitors and manages node failures with a heartbeat mechanism.
  • Recovery Mechanism: Synchronizes recovered nodes with the rest of the system.
  • CLI Tools: Provides command-line interfaces for both server management and client interactions.

Setup and Installation

  1. Clone the Repository

    git clone https://github.com/your-username/distributed-key-value.git
    cd distributed-key-value
  2. Install Dependencies

    npm install

Usage Guide

To start a server, use the following command:

npm start

You will be prompted to choose which server instance to run.

To interact with a server, use the following command:

npm test

You will be prompted to select a server instance and then execute commands like SET, GET, UPD, and DEL.

Visualization

System Architecture Diagram

Diagram showing the overall architecture of the distributed key-value store system.

Command Forwarding Diagram

Diagram illustrating how the SET command is forwarded from Server A to other nodes.

Starting a Server

Starting Server

Screen recording of the CLI prompt for selecting and starting a server.

Sending Commands

Sending Commands

Screen recording of the CLI interaction for sending commands to a server.

Example Scenarios

Scenario 1: Basic Operations

  1. Start Server Instances:
    Run the servers using npm start for Server A, Server B, and Server C.

  2. Set a Value Using Client CLI:
    Connect to Server A and execute the command:

    SET myKey myValue

    The SET command will be forwarded to Server B and Server C.

  3. Get the Value:
    Execute the command to retrieve the value:

    GET myKey

    Confirm that myKey returns myValue from Server A, Server B, and Server C.

  4. Update the Value:
    Update the value using the command:

    UPD myKey newValue

    Ensure that all servers reflect the updated value newValue.

  5. Delete the Key:
    Execute the delete command:

    DEL myKey

    Verify that myKey is no longer present on Server A, Server B, and Server C.

Scenario 2: Fault Tolerance and Recovery

  1. Start Server Instances:
    Ensure all server instances are running.

  2. Simulate Node Failure:
    Stop Server B to simulate a failure.

  3. Send Commands:
    Execute commands using the Client CLI and verify that Server A and Server C process them.

  4. Restart the Failed Node:
    Restart Server B and check the recovery process.

  5. Verify Recovery:
    Confirm that Server B resynchronizes with Server A and Server C and reflects the latest data.

  6. Check Data Consistency:
    Ensure that all servers have consistent data after the recovery of Server B.

About

Educational project for exploring core concepts of distributed systems and networking (NO FRAMEWORKS).

Resources

Stars

Watchers

Forks