{"id":16797163,"url":"https://github.com/jdockerty/dnd","last_synced_at":"2025-03-17T03:45:02.861Z","repository":{"id":213381197,"uuid":"731781788","full_name":"jdockerty/dnd","owner":"jdockerty","description":"Definitely Not Dynamo is a toy distributed key-value store, inspired by Amazon's Dynamo.","archived":false,"fork":false,"pushed_at":"2023-12-20T20:41:24.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-23T13:29:41.270Z","etag":null,"topics":["distributed-key-value-database","distributed-systems","dynamodb","kv-store","learning-by-doing","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdockerty.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-14T21:38:55.000Z","updated_at":"2024-12-11T05:22:59.000Z","dependencies_parsed_at":"2024-10-13T09:21:22.986Z","dependency_job_id":null,"html_url":"https://github.com/jdockerty/dnd","commit_stats":null,"previous_names":["jdockerty/dnd"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdockerty%2Fdnd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdockerty%2Fdnd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdockerty%2Fdnd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdockerty%2Fdnd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdockerty","download_url":"https://codeload.github.com/jdockerty/dnd/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243971157,"owners_count":20376784,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["distributed-key-value-database","distributed-systems","dynamodb","kv-store","learning-by-doing","rust"],"created_at":"2024-10-13T09:21:20.523Z","updated_at":"2025-03-17T03:45:02.837Z","avatar_url":"https://github.com/jdockerty.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dnd (definitely not dynamo)\n\nA toy implementation of a distributed key-value store, inspired by [Amazon's Dynamo](https://www.amazon.science/publications/dynamo-amazons-highly-available-key-value-store).\n\nAfter reading their paper, I wanted to implement something similar so I whipped up a stripped down version with my own quirks - `dnd` is the result of that.\n\n## Functionality\n\nAs `dnd` is inspired by Dynamo, it matches some of their initial criteria:\n\n- Symmetry: There are no specific _roles_ for nodes, i.e. there is no concept of a leader node with followers. Instead, all nodes communicate peer-to-peer via a gossip protocol.\n- Replication: The current implementation does not use consistent hashing, the trade-off here is that the entire K-V store is replicated to all nodes, based on the latest `AtomicU64` counter. This would have major downsides in a huge cluster of nodes; however, it does mean that any node can respond to a `get(key)`.\n- Availability: Writes are never rejected, the \"last write wins\".\n\n\n_TODO:_\n\n- Failure detection, currently a node is not considered unhealthy if it goes away, UDP packets are simply sent into the void.\n- Consistent hashing (mentioned above).\n- Key deletion.\n\n\n## How it works\n\nThe `gossip` implementation and a HTTP server run on separate threads. The HTTP server is used to accept `get` and `put` operations\nvia HTTP requests. For example\n\n```bash\ncurl -X POST localhost:6000/kv/user1 -d '{\"name\": \"Jack\"}'\n```\n\nThe above will _put_ a key called `user1` with the JSON payload provided into the store, provided via [`dashmap`](https://docs.rs/dashmap/latest/dashmap/).\n\nWhilst the HTTP server waits for requests to cover `get(key)` and `put(key, data)` operations, the distributed key-value store functionality is handled by my stripped down implementation of [SWIM](https://www.cs.cornell.edu/projects/Quicksilver/public_pdfs/SWIM.pdf), a gossip protocol.\nA node can either `start` a new cluster or `join` an existing one by specifying a known `Peer`. At every interval, either a `read` or `write` operation will occur:\n\n- Write means that a random peer node will be selected to send an `Update` to, containing the store and its current atomic counter.\n- Read means that a UDP datagram will be read from the bound socket and unmarshaled, this does not always contain new information in which case nothing happens.\n\nThe most up to date `DashMap` will always win, this is tracked by an [`AtomicU64`](https://doc.rust-lang.org/std/sync/atomic/index.html) counter. When a put operation occurs, the counter is incremented. This means that when a read\nsees that the incoming data is more up to date than its own, its `DashMap` will be replaced by the one contained in the `Update`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdockerty%2Fdnd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdockerty%2Fdnd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdockerty%2Fdnd/lists"}