vmware / node-replication

An operation-log based approach for data replication.
Apache License 2.0
62 stars 19 forks source link

Dynamic Replication #52

Open gz opened 2 years ago

gz commented 2 years ago

Is your feature request related to a problem? Please describe.

Static replication can consume too much memory.

Currently CNR/NR set-up the replication factor at data-structure instantiation and doesn't allow it to change which is sub-optimal: as the workload changes a program might want to invest less memory in replication (at the cost of read-performance) but instead use the memory for something else.

Describe the solution you'd like

Varying replicas

[random thoughts in no-particular order of how this should be implemented]

Remove replica

Add a new replica:

API pseudo-code: adding and removing replicas

NodeReplicated {
  max_replicas: 4 // #NUMA nodes
  active: Vec<usize> // currently active replicas
  routing: HashMap<tid, rid> // maps threads to replicas
}

fn add_replica(rid: usize) -> Result {
  assert(rid < max_replicas);
  assert(!active.contains(rid), “not already active”);

  // possible thread routing policy:
  // migrates tids that were originally registered to `rid` back to execute against `rid`
  ensures(active.contains(rid));
}

fn remove_replica(rid: usize, new_tid_affinity: usize) {
  assert(rid < max_replicas);
  assert(new_tid_affinity < max_replicas);
  assert(active.contains(rid));
  assert(active.contains(new_tid_affinity));

  // route all threads registered with rid to `new_tid_affinity`
  // should it be possible to do more complex assignment?
  // then maybe we can provide a function that implements a routing
  // policy and assigns them or provide a HashMap with tid->new_rid mappings 
  // and a default?

  ensures(!active.contains(rid));
  ensures(active.contains(new_tid_affinity));
  ensures(!routing.values.contains(rid));
  ensures(routing.len == old(routing).len);
}

How do we show it works

NR micro-benchmarks: measure mem consumption and read-tput, vary replicas over time

Integration with network and IO

(this is mostly future work to connect IO + network once we have these mechanism in place)

Describe alternatives you've considered

Alternative approaches

Additional context

No response

MarcPaquette commented 1 year ago

I've started work on this issue in this branch: nr-dymanic-replication