-
Notifications
You must be signed in to change notification settings - Fork 6
feat: server setup + refactor #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
techsavvyash
wants to merge
51
commits into
ChakshuGautam:main
Choose a base branch
from
techsavvyash:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
725d596
fix: installation steps in README
techsavvyash 44e646d
Words and command were not properly defined in customEval cli.js
rahul-shrimali ad52775
Merge pull request #1 from rahul-shrimali/improveGet_Set
techsavvyash 1ef5153
chore: refactor
techsavvyash 55722b6
feat: setup server and refactor code
techsavvyash 968d787
docs: update README, TODO AND CONTRIBUTING .mds
techsavvyash fd1c6b3
changes regarding message in server.js
rahul-shrimali 7f1359b
feat(wip): changes
techsavvyash 304b071
merge
techsavvyash e7a4dd0
fix(maybe): append_fail error
techsavvyash d89ebd8
feat(wip): figure out get set
techsavvyash 074f22c
Initial configuration of set
rahul-shrimali 29025c3
set resolve errors
rahul-shrimali d9cc375
Closing the db on EXIT command
rahul-shrimali f00c254
sequential calls for set
rahul-shrimali 1a9d084
Merge pull request #2 from techsavvyash/dev
techsavvyash 53ee440
feat(maybe unstable): get func for leader
techsavvyash d17224f
get client implementation
rahul-shrimali 67b661f
working get and set on all nodes
rahul-shrimali ad77243
fix: allow for multiple socket writes at a time
techsavvyash 905c245
fix: working get set and node consensus
techsavvyash 88d2a58
Merge pull request #3 from techsavvyash/dev
techsavvyash b444812
feat: get proxy working, fix the clients and make sure everything works
techsavvyash 272aa66
resolve bug of data not being set in batches
rahul-shrimali 8d0bfbb
Another connection bug resolved
rahul-shrimali d166c85
get using one node only
rahul-shrimali 3d8228e
Merge pull request #5 from techsavvyash/dev
techsavvyash d98dbb2
feat: setup mprocs
techsavvyash 3d3d88e
feat: non race conditions working impl
techsavvyash 4c8da23
Merge pull request #6 from techsavvyash/dev
techsavvyash bfb176f
idk what's going on
techsavvyash c8f7290
feat: we finally have a folder structure
techsavvyash e651d31
Merge pull request #7 from techsavvyash/dev
techsavvyash 0bfc55e
feat: more refactoring
techsavvyash 80dc785
feat: add simdjson for JSON.parse
techsavvyash 944cdc9
Merge pull request #8 from techsavvyash/dev
techsavvyash 439c923
docs: update README (still needs work but has basics out the way)
techsavvyash a272c04
feat: try adding benchmarking
techsavvyash c0decba
Completed benchmark.js
rahul-shrimali 4ae6e81
graph for json
rahul-shrimali 4132fbe
fix: benchmark and comment out simd
techsavvyash 8514625
Merge branch 'dev' of https://github.com/techsavvyash/stylusdb-js int…
techsavvyash df70b5e
Merge pull request #13 from techsavvyash/dev
techsavvyash 2c82110
feat: setup gitpod
techsavvyash fc4d8ac
fix: update benchmark.js
techsavvyash 48db276
docs: new graphs
techsavvyash 7506956
fix: redundant packages
techsavvyash 979873d
feat: simd benchmarks
techsavvyash b4927cd
docs: add README for appendix
techsavvyash 1143908
fix: file names in appendix
techsavvyash 5589266
chore: changes
techsavvyash File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| node_modules | ||
| db | ||
| log | ||
| log | ||
| benchmarks | ||
| data | ||
|
|
||
| commit-errors.txt | ||
| events.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| # This configuration file was automatically generated by Gitpod. | ||
| # Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) | ||
| # and commit this file to your remote git repository to share the goodness with others. | ||
|
|
||
| # Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart | ||
|
|
||
| tasks: | ||
| - init: npm install | ||
| command: npm run prepare && npm run start:dev | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| v16.19.0 | ||
| v18.18.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| # StylusDB | ||
|
|
||
| ## Project Structure | ||
|
|
||
| This project is a normal NodeJS project with a target of using as less NPM dependencies as much possible. | ||
|
|
||
| ### Directories | ||
|
|
||
| - [`./raft`](./raft/) - This directory contains a very light weight implementation of the Raft Protocol. The code inside this folder has been taken from [unshitio/liferaft](https://github.com/unshiftio/liferaft) | ||
| - [`./reference`](./reference/) - This folder is for experimentation purposes this is where the contributors store the code for WIP experiments which are to be referenced later. | ||
| - [`./scripts`](./scripts/) - This folder contains a few scripts to avoid the hassle of manually running the cluster and clients | ||
|
|
||
| ### Files | ||
|
|
||
| - [`./cli.js`](./cli.js) - This file contains the implementation for a minimalistic REPL or CLI for StylusDB cause what is a DB without a CLI 🤓. | ||
| - [`./client.js`](./client.js) - This is a small implementation of a sample client to send messages to the nodes in the cluster. | ||
| - [`./db.js`](./db.js) - This contains the implementation for connecting and storing data to our storage engine. Presently this acts as an interface to `LMDB` but in future this will be a generic interface to a host of storage engines. | ||
| - [`./index.js`](./index.js) - Contains the implementation of the class defining the structure and callbacks for a node in the `StylusDB` Raft Node Cluster. | ||
| - [`./raft-node.js`](./raft-node.js) - This file contains functions to instantiate a node using the class defined in index.js. This exists as a separate file for ease of understanding right now, might be merged with `index.js` later. | ||
| - [`./server.js`](./server.js) - This file setsup a server to accept connections and respond to requests from client. This is the file where the Raft Node is instantiated and connected to the other nodes in the cluster. | ||
|
|
||
| ## How to Contribute? | ||
| - Refer to issue tickets on [Github](https://github.com/techsavvyash/stylusdb-js) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Change remote |
||
| - A list of high level goals and roadmap can be found in [TODO.md](./TODO.md) | ||
| - Rest of the steps remain same as how you'd contribute to any other open source project | ||
| - Fork the repository | ||
| - Make the required changes | ||
| - Raise a PR and ask for reviews | ||
| - In case of doubts or guidance reach out to [Yash Mittal](https://github.com/techsavvyash) | ||
|
|
||
| ## Pre-requisties | ||
| - Understanding of the [Raft Distributed Consensus Algorithm](ft.github.io/raft.pdf) | ||
| - Working knowledge of [NodeJS](https://nodejs.com) | ||
| - Knowledge of Distributed Systems and Distributed Databases | ||
| - Knowledge of Database Internals | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| procs: | ||
| raft-node-1: | ||
| shell: "node ./src/server.js --port 8081" | ||
| raft-node-2: | ||
| shell: "node ./src/server.js --port 8082" | ||
| raft-node-3: | ||
| shell: "node ./src/server.js --port 8083" | ||
| raft-node-4: | ||
| shell: "node ./src/server.js --port 8084" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| procs: | ||
| raft-node-1: | ||
| shell: "node ./src/server.js --port 8081" | ||
| raft-node-2: | ||
| shell: "node ./src/server.js --port 8082" | ||
| raft-node-3: | ||
| shell: "node ./src/server.js --port 8083" | ||
| raft-node-4: | ||
| shell: "node ./src/server.js --port 8084" | ||
| proxy: | ||
| shell: "node ./src/proxy.js" | ||
| user-shell: | ||
| cmd: ["zsh"] |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # StylusDB Protocol | ||
|
|
||
| This is a set of rules that we use to distinguish between different kinds of messages we are sending. | ||
|
|
||
| ## Proxy | ||
| This defines the types of messages we need in the proxy. | ||
| We use the '\n' as the delimiter for the messages | ||
|
|
||
| ### 1. Request from Client | ||
|
|
||
| Legend: "?" | ||
|
|
||
| ### 2. Response from Cluster Node | ||
|
|
||
| Legend: "+" | ||
|
|
||
|
|
||
| ### 3. Information response from Cluster Node | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| ## Raft Node Server | ||
| - Normal raft node data/commands | ||
| - Information Requests -- information about who is the current cluster leader and how to figure out which nodes are alive and which are not ; how many members are a member of the cluster |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| # TODO | ||
|
|
||
| ## Resources | ||
| To browse the DB: https://www.mdbopener.com/ | ||
| -- Refer: Pelican -- This is rebuilding Pelican in JS | ||
|
|
||
| ## Roadmap / Things to try out | ||
|
|
||
| - [ ] Turn message saving into a batch process | ||
| - [ ] Fine tune `server.js` to expose set and get via CLI | ||
| - [ ] Turn setInterval directly via sockets | ||
| - [ ] Fine tune LMDB Manager | ||
| - [ ] Compress commands together and in memory calculate the final process | ||
| - [ ] Let candidates run the `GET` commands | ||
| - [ ] Make sure there are no race conditions here | ||
| - [ ] Run RAFT on the browser - [Mozilla Docs on Socket](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API) | ||
| - [ ] Demo with message inter-play between nodes and other benchmarking | ||
| - [ ] Large Keys and Small Keys optimisation | ||
|
|
||
|
|
||
|
|
||
| ## Doubts :- | ||
| - [ ] In message of raft when we are sending "SET" as what it should be giving error as in raft.on("data", packet) the packet is bound to be an object which is not so in this case, (sending message in server is ambiguous, the what must be in the form of a raft packet) | ||
|
|
||
| - [ ] When we send a message from follower to leader to set a value, there is no case to command all followers to save that message | ||
|
|
||
|
|
||
|
|
||
| ## List -- 27/03/24 | ||
|
|
||
| - [ ] Implement the orchestrator | ||
| - [ ] Fix the key skipping error | ||
| - [ ] Add the load balancer -- figure out if proxy can do it on its on or if we need a dedicated load balancer | ||
| - [ ] Implement updating Get-Set based on keys in a batch | ||
| - [ ] Figure out batch size -- because we get already connected error | ||
|
|
||
|
|
||
| ## Observations | ||
|
|
||
| - we get pauses in between sets -- is there a settimeout in teh -- log entries/indexes are getting mised | ||
| - figure out why are log entries are not getting updated and throwing not found error. | ||
| - make the proxy connect to all the nodes in the cluster | ||
| make this fault tolerant so that there is a exponential retry incase some node goes off | ||
| - edit the "leader" fn to send a message to the proxy when the leader changes for it to know who the current leader is | ||
| - implement a sort of load balancing to delegate requests between the raft nodes | ||
| - figure out vs-code crashing with a lot of requests -- better memory management for the app maybe? | ||
|
|
||
| ## question | ||
|
|
||
| - Load Balancing -- Should we have a separate load balancer? or is rotating queries at a proxy level enough? | ||
| - Bug: Data is not being stored between restarts |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Response Times | ||
|
|
||
| This folder contains the response time of each request that is sent out during the testing for reference purposes. | ||
|
|
||
|
|
||
| | File Name | Description | Link to file | ||
| |-----------|-------------|------------- | ||
| | `set_simd_1000.json`| Response times for each SET request in the batch of 1000 requests | [Link](./set_simd_1000.json) | | ||
| | `get_simd_1000.json`| Response times for each GET request in the batch of 1000 requests | [Link](./get_simd_1000.json) | |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May not be the goal here. Building the fastest JS implementation is.