Skip to content

Instantly share code, notes, and snippets.

@clayg
Last active July 4, 2018 02:21
Show Gist options
  • Save clayg/6879840 to your computer and use it in GitHub Desktop.
Save clayg/6879840 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""
This script is about telling want you need *today* - not what you want to hear
""" # noqa
import sys
import math
from argparse import ArgumentParser
parser = ArgumentParser(description=__doc__.lstrip())
parser.add_argument('-R', '--replicas', type=float, default=3.0,
help='specify number of replicas or fragments (k+m)')
parser.add_argument('num_devs', type=int, help='number of devices you '
'have in the real hardware you are going to deploy')
def best_options(num_devs, replicas):
reasonable_options = set()
for i in range(10):
i += 1
part_power = int(round(math.log(num_devs * (i * 1000) / replicas, 2)))
reasonable_options.add(part_power)
option_map = {}
for option in sorted(reasonable_options):
parts_per_dev = int(2 ** option * replicas / num_devs)
print '@%s number of parts per device is %s' % (
option, parts_per_dev)
option_map[option] = parts_per_dev
middle_of_the_road = sum(option_map.values()) / len(option_map)
best_options = sorted([
(abs(middle_of_the_road - per_dev), option)
for (option, per_dev) in option_map.items()
])
return [option for delta, option in best_options]
def main():
args = parser.parse_args()
num_devs = args.num_devs
replicas = args.replicas
options = best_options(num_devs, replicas)
right_answer = options[0]
print 'If you just use %s, you can easily scale up to...' % right_answer
max_devices = replicas * (2 ** right_answer) / 100
thin_nodes = max_devices / 12
dense_nodes = max_devices / 24
small_drives = max_devices * replicas
big_drives = max_devices * 5
print '%s drives in %s-%s servers storing %s-%s TBs' % tuple(
int(x) for x in (
max_devices,
dense_nodes,
thin_nodes,
small_drives,
big_drives))
if __name__ == "__main__":
sys.exit(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment