Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created May 29, 2019 16:22
Show Gist options
  • Save toddlipcon/a92e41ad9e2d57c8c2f523d7137ce26a to your computer and use it in GitHub Desktop.
Save toddlipcon/a92e41ad9e2d57c8c2f523d7137ce26a to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import random
from collections import Counter
num_tservers = 30
num_hash_buckets = 16
repl_factor = 3
ts_buckets = [random.randrange(0, num_hash_buckets) for i in xrange(num_tservers)]
ts_load = Counter()
for i in range(10000):
tablet_locs = random.sample(range(num_tservers), repl_factor)
chosen_ts = max(tablet_locs, key=lambda idx:ts_buckets[idx])
ts_load[chosen_ts] += 1
print ts_load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment