# Explore how load based and sized based splitting occur in isolation. In this
# example, there is only one store so no rebalancing activity should occur. 
gen_cluster nodes=1
----

gen_ranges ranges=1 repl_factor=1
----

# Create a load generator, where there is higher ops/s than the qps split
# threshold set above. Also set to use only reads, to avoid size based splits
# (we could also disable this via setting the range max size).
gen_load rate=10000 rw_ratio=1
----

setting split_qps_threshold=2500
----

# Assert that the number of replicas should not change at all during the last 6
# ticks of the simulation.
assertion stat=replicas type=steady ticks=6 upper_bound=0.00
----

eval duration=5m samples=2 seed=42
----
OK

# Examine the number of replicas. Here there were 5 load based splits. This
# roughly lines up with expectations, given a rate of 10,000 QPS and 2,500 QPS
# split threshold.
plot stat=replicas sample=2
----
----

 5.00 ┤         ╭─────────────────────────────────────────────────────────────────────
 4.73 ┤         │
 4.47 ┤         │
 4.20 ┤         │
 3.93 ┤      ╭──╯
 3.67 ┤      │
 3.40 ┤      │
 3.13 ┤      │
 2.87 ┤      │
 2.60 ┤      │
 2.33 ┤      │
 2.07 ┤   ╭──╯
 1.80 ┤   │
 1.53 ┤   │
 1.27 ┤   │
 1.00 ┼───╯
                                           replicas
----
----

# Update the load generator to use a zipfian distribution instead of a uniform.
# Now the load based splitter must find a split key from a skewed distribution
# repeatedly - if the load split algorithm is good, we should expect the same
# number of splits as the uniform workload. However, that is not the case as we
# require more splits with a zipfian distribution.
gen_load rate=10000 rw_ratio=1 access_skew=true
----

eval duration=5m samples=2 seed=42
----
OK

plot stat=replicas sample=4
----
----

 9.00 ┤                          ╭────────────────────────────────────────────────────
 8.47 ┤                          │
 7.93 ┤                      ╭───╯
 7.40 ┤                      │
 6.87 ┤                   ╭──╯
 6.33 ┤                   │
 5.80 ┤               ╭───╯
 5.27 ┤               │
 4.73 ┤            ╭──╯
 4.20 ┤         ╭──╯
 3.67 ┤         │
 3.13 ┤      ╭──╯
 2.60 ┤      │
 2.07 ┤   ╭──╯
 1.53 ┤   │
 1.00 ┼───╯
                                           replicas
----
----

# vim:ft=sh
