Created
June 23, 2021 22:31
-
-
Save JensRantil/dd607ffa88832c725c2e2b21302f7934 to your computer and use it in GitHub Desktop.
Small script to simulate rack-aware Cassandra reads/writes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
original = [ | |
["RAC1"], | |
["az-A-0", "az-A-1"], | |
["az-B-0", "az-B-1"], | |
["az-C-0", "az-C-1"], | |
] | |
remove_rac1 = [ | |
["az-A-0", "az-A-1"], | |
["az-B-0", "az-B-1"], | |
["az-C-0", "az-C-1"], | |
] | |
add_new_node = [ | |
["RAC1"], | |
["az-A-0", "az-A-1", "az-A-2"], | |
["az-B-0", "az-B-1"], | |
["az-C-0", "az-C-1"], | |
] | |
nodes = add_new_node | |
a = dict() | |
consistency = 1 | |
N = 10000 | |
for i in range(N): | |
random.shuffle(nodes) | |
racks = nodes[:consistency] | |
for rack in racks: | |
node = random.choice(rack) | |
if node not in a: | |
a[node] = 0 | |
a[node] += 1 | |
print "Consistency:", consistency | |
for k, v in a.items(): | |
print "{0}: {1}%".format(k, 100.*v/(consistency*N)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment