Coder Social home page Coder Social logo

akash-pateria / quick-store Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 19.5 MB

Efficient and Stable Peer-To-Peer Distributed Hash Table System

Shell 1.72% Python 98.28%
distributed-systems distributed-storage distributed-file-system distributed-hash-table gossip-protocol gossip-dissemination heartbeat-service failure-detection joining-protocol

quick-store's Introduction

Efficient and Stable Peer-To-Peer Distributed Hash Table System

This project is based on the following papers:

System Architecture

System Design

System Setup

  • Unzip/Clone project source
$ unzip project.zip
$ cd quick-store/
OR 
$ git clone https://github.com/Akash-Pateria/quick-store.git
  • Install python virtual environment package
$ apt install python3-venv
  • Create a virtual environment and activate it
$ python3 -m venv env
$ source env/bin/activate
  • Install package dependencies
$ pip3 install -r requirements.txt
  • Install Redis server and ensure that it runs on default 6379 port
$ apt install redis-server
$ redis-cli ping
  • Apply Django model migrations
$ python manage.py makemigrations webapp
$ python manage.py migrate webapp
$ python manage.py migrate
  • Create one default heartbeat object for node local timestamp
$ python manage.py shell
> from webapp.models import Misc
> Misc.objects.create(name="heartbeat")
CTRL+d for exit
  • Open another terminal tab and run celery for spawning periodic tasks
$ cd p2p_File_Sharing
$ source env/bin/activate
$ celery -A FileSharingSystem worker -l info -B
  • Deploy Bootstrap Server as an application and Start it for acknowledging new node join-request.
bootstrapServer/$ python manage.py runserver 0:8000

Note: Perform this last step only on a seperate node (no db setup required for this application). System assumes that this node never fails. In production envrionment, it is prudent to have multiple backup servers for such tasks.

Project Structure

  • App/- Contains application related configurations such as celery setup, url configs, and app settings.
  • quick-store/-
    • Gossip.py - contains handler of /heartbeat, /contact-heartheat, /delete-node endpoints
    • Tasks.py - contains periodic task implementations:
      • detect_failure
      • disseminate_contact_heartbeat
      • disseminate_heartbeat
      • increment_heartbeat
    • Gossip.yaml - contains gossip configurable parameters
    • Models.py - Django model definitions
    • Urls.py - System routes
    • Views.py - contains endpoint definitions of file operations
    • Node.py: contains node joining protocol operations
    • bootstrapServer/views.py - contains logic for accepting new node join-requests.
  • Requirement.txt- contains system package dependencies
  • Manage.py- Django manager

System usage

System supports two major operations: File Upload (object insertion) and File Download (object lookup) Note: It is recommended to use an API Client (eg. Postman) to hit the required endpoint.

  • File Upload Endpoint:
  HTTP Method: POST
  URL: http://<IP address of the node>:<Port>/admin/webapp/upload/
  Body  :
  {
  “file_obj “: <Select the file to be uploaded>
  “file_name” : <filename>
  }
  • File download Endpoint:
  HTTP Method: GET
  URL: http://<IP address of the node>:<Port>/admin/webapp/download?fileName=<filename> 
  Filter parameter to the request is the filename you are looking for. 
  This get API will download the file to /media/downloads folder on the server on which API is targeted.
  • Node Join Endpoint
  HTTP Method: GET
  URL: http://<IP address of the bootstrap server>:<Port>/bootstrapServer/newNodeIP  
  newNodeIP - This is the IP address of the new node that you want to join the system.

Data Operations

  1. Setup system nodes.
  2. Start the bootstrap server to add nodes into the system using Joining Protocol
  3. Start inserting data objects through file upload endpoint.
  4. Perform the file lookup operations on the files inserted.

System Info: System consists multiple (say k) virtual groups and uses a cryptographic hash function SHA-1 on node identifier to ensure workload balancing across these groups. With high probability, every group holds N/k nodes. In addition, object insertion uses the same method to place the files having each group holds F/k files.

Failure Detection

  1. Run the setup on participating nodes. Start the server on all such nodes.
  2. Add these nodes into the system using node join operation
  3. Crash stop one running/participating node
  4. CTRL+c on node’s runserver and celery terminal

After 48 seconds (i.e. 2 * T_fail seconds, T_fail is configured in gossip.yaml), all the members (to this failed node) should delete this failed node entry from their membership list. Failure detection messages can also be observed on the terminal.

System Info: Failure detection service uses heartbeat mechanism to detect cash-stop failures. It progresses as follows:

  • Every node updates its own heatbeat in its own local membership list in every second.
  • After every Gossip Period, it gossips its updated mem_list to a set of gossip targets to inform other members about its liveliness. These target node selection uses spatial gossip method i.e. nodes that are present closer to the given node are picked for gossip (uses RTT field on mem_list).
  • On receipt, the receiver updates its mem_list against the receieved list and keeping updated records from deletion. It gossips the same list to its target nodes and heartbeat disseminate like a fire in a network.
  • Every node runs a failure detection periodic task using celery and check for last updated timestamp on every member heartbeat.

quick-store's People

Contributors

akash-pateria avatar omkarkulkarni1 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.