Skip to content

Master-slave replication suggestions #1403

@ammmir

Description

@ammmir

This is more of an application question than anything else, so please feel free to direct me elsewhere. Many thanks for this wonderful project!

I run a small service, KVdb, that I'd like to improve the read latency from various points around the Internet. Initially, I'm leaning into a single master + multiple slave setup as a stepping stone to a more proper distributed system :) The Badger API docs lead me to the Stream framework, which is used by the backup and restore functionality, so perhaps something like this would work?

Assumptions/tradeoffs:

  • Flat topology of 5~10 slaves
  • Master-slave network latencies of 50~200ms
  • Reads should be fast, writes can be an order of magnitude slower
  • All data will be blindly replicated for now

On the master, for each slave that connects:

  1. Create a new Stream
  2. Select keys since the slave's last version timestamp
  3. Send keys over the network to the slave

On the slave:

  1. Connect to master
  2. Request key stream since last version timestamp
  3. Use KVLoader to ingest keys into our local database
  4. Repeat

On the slave:

  • Redirect write activity to master. (I don't want to go down the Raft rabbit hole at this point.)
  • Refuse reads/softfail if slave is too far behind master (e.g., time delta) depending on desired consistency

Am I oversimplifying, plain wrong, or is this at least in the right direction?

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/questionSomething requiring a response

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions