- Sharding -> without knowledge of the kind of key it is better to shard by hash of key -> consistent hashing
- Replication
- Need to implement primary/replica pattern for shards
- Index always to primary, replicate to replicas
- Mark as ready when all have applied a change
- If primary shard is down, promote a replica
- Need of a leader to keep cluster state
- Routing/allocation algorithms
- Different layers/tiers of storage (cached/disk)
- Error handling
- Handle node failure
- Handle shard failure
- Handle write failure
- Route to healthy node/shard
- Transactions ?
- Entry versioning ?
- Represent nodes as separate in memory structs
- Single table approach
- In memory map used as backing store
- Main goroutine to act as master and track cluster state
- Only main node to receive requests
- Channels as node-node communication
- Constant number of nodes=5 and shards=10 (1- primary and 10 replicas)
- Handle some errors
- Node unavailable ->
- reroute request to replica
- turn replica into primary
- Create a new replica in another node
- Node unavailable ->
- Clone this repo
- Install docker: https://docs.docker.com/get-docker/
- Build the binaries by running:
make build-server && make build-client
- Run the server with:
docker run -p 1338:1338 kv-store-server:latest
- Run the client with:
docker run --network="host" kv-store-client:latest localhost:1338 put name luis
docker run --network="host" kv-store-client:latest localhost:1338 get name