Built a causally consistent, replicated and sharded key value store with a REST API.

go_KeyValueStore

A causally consistent, replicated and sharded key value store built in Golang with a RESTful API. Runs through the use of a Docker container.

Given a system that is replicated and sharded across numerous nodes, we have an interface that practices Representational State Transfer (REST), wherein certain endpoints, when accessed, can either:

  • Add a key value pair to the store
  • Update a key value pair to the store
  • Delete a key value pair in the store
  • Print out all key value pairs in the store (across all shards)

All operations are completely causually consistent, where causal order of events are enforeced (similar to a Distributed System).

Mechanism Description:

How the system detects when a replica goes down:

The system can detect when a replica is down when we broadcast messages (and we only broadcast messages that we receive from the client that also change our database i.e. we don't broadcast GETs). It detects a down replica when it first pings that replica whilst waiting for a timeout -- if the ping times out within 1 second, then we consider the replica down. After this step we then update the views of all other replicas to reflect this.

How the system tracks causal dependencies:

Our system is very similar to CBCAST Vector Clocks, wherein vector clocks increment at the sender index on Sends. In order to detect violations, we first check if the metadata is nil, if it isnt, then we check if the metadata is from the client. If it is, we make sure that the request vector is <= the local vector at all indexes or else there's a consistency violation. If the metadata is from a replica, then we make sure the vector clock's value at the senders index is 1 greater than the local vector's and <= at all other indexes or else there is another violation.

How the system divides nodes into shards:

Our system divides nodes into shards by first keeping all the node IP's in an array. We then modulo the index of each of these IP's by the number of shards, which will return a number from 0 to shardCount - 1. We then decide which shard the node belongs to based off of that (we essentially evenly distribute the nodes to shards).

How the system shards keys across nodes:

First we created a hash function, which takes a go hash library and returns an integer which we then modulo with the shard count to produce an integer between 0 and shardCount-1 (lets call this value x). we then have variable 'hashToIndexArr' which is an array of all the shard ID's. We can find the key to shard mapping by indexing the array by the value x we got earlier to know what shard the key belongs to.

Owner
Dennis Pang
Fourth Year Computer Science Major at UCSC who enjoys using algorithmic thinking to solve complex puzzles.
Dennis Pang
Similar Resources

Instagram Backend HTTP REST API using GO Lang and Mongo DB

Instagram Backend HTTP REST API using GO Lang and Mongo DB Project for Appointy Summer Internship . Project built within 25 hrs, with no prior knowled

Oct 10, 2021

REST API of Instagram's functionalities; developed using GO (and Mongo).

REST API of Instagram's functionalities; developed using GO (and Mongo).

Instagram-backend-api REST API of Instagram's functionalities; developed using GO (and Mongo). Constraints: Complete API has been developed using Go M

Oct 9, 2021

REST API with Echo Framework and a JSON File

 REST API with Echo Framework and a JSON File

REST API with Echo Framework and a JSON File Run it in ./src with: go run server.go The documentation, here = echo.labstack.com. Fake data = mockar

Dec 27, 2021

A simple app that reads NBMiner status REST API data and sends it to InfluxDB

NBMiner Reporter A simple Go app that reads NBMiner status REST API data and sends it to InfluxDB. Usage Using the reporter is quite easy, specially i

Feb 8, 2022

REST API written in GO with PostgreSQL and Nginx Proxy + Certbot Let's Encrypt HTTPS certificates + Graphical Frontend in PHP. Deployed via docker-compose.

SSOA-PT REST APP Services Backend: REST API in Go Database: PostgreSQL Web Proxy: Nginx Let's Encrypt HTTPS certificates with certbot Frontend: PHP Ap

Mar 19, 2022

Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST Clean api rest with Go, Gin and GORM. Clean Architecture with DD

Oct 21, 2022

Go-restapi - Go REST API with mysql and docker

GET localhost:8080/polygons localhost:8080/polygons/:name localhost:8080/polygon

Jan 24, 2022

A CRUD Phone Book app by REST-API, Golang and PostgreSQL

A CRUD Phone Book app by REST-API, Golang and PostgreSQL

in this repository, I've created a CRUD Phone Book app by REST-API, Golang and PostgreSQL. in this app, you can: 1-Create a new contact 2-See all contacts 3-Search among the contacts 4-Delete a contact by it's name 5-Delete a contact by it's number 6-Delete all contacts

Oct 8, 2022

REST API for RabbitMQ, Write with Google Go(lang).

RabbitMQ HTTP API REST HTTP API for RabbitMQ, it's not RabbitMQ Management Plugin. Status: Under active development. Required: * RabbitMQ (2.8+) * Go(

Aug 29, 2022
REST API for a shoe store using Go and Gin Web Framework

REST API for a shoe store using Go and Gin Web Framework This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go

Dec 26, 2021
A fully-featured REST API developed in Golang for an online book store.

A fully-featured REST API developed in Golang for an online book store.

Oct 20, 2022
A fully-featured REST API developed in Golang for an online book store.

E-book Store A fully-featured REST API developed in Golang for an online book store. API Documentation Features Authentication (Sign up, Login and Res

Oct 20, 2022
REST-API specifically build to support online store system of Zahir
REST-API specifically build to support online store system of Zahir

Rest Test. • From Above ERD please create Rest full API. Create register API(Include Generate password). • Acceptance o Phone number and email is uniq

Nov 15, 2021
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Jul 19, 2022
Ecommerce-api - Rest api of e-commerce web application
Ecommerce-api - Rest api of e-commerce web application

E-commerce Rest API Swagger documentation to test api Domain diagram

Jan 2, 2023
A RESTful API written in Golang to store and retrieve ticket information.

Tickets-API A RESTful API written in Golang to store and retrieve ticket information. This is a RESTful API built on top of the gin-gonic/gin package

Jan 31, 2022
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.
A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

A Golang REST API to handle users and posts for a simple instagram backend. Uses MongoDB as the database. Tested using golang-testing and Postman.

Oct 10, 2021
GinGoExample - Implement rest api using gin and go and mongodb

GinGoExample Implement rest api using gin and go and mongodb Optimizations using Singlton pattern to avoid repetetive commiunication with mongodb . Fe

Mar 25, 2022
Simple vanilla Go CRUD application with mongoDB database with its mflix dataset that I use for my thesis about benchmarking REST API and GraphQL.

Go GraphQL Simple vanilla Go CRUD application with mongoDB database with its mflix dataset that I use for my thesis about benchmarking REST API and Gr

Oct 15, 2021