Skip to content

Instantly share code, notes, and snippets.

@dboitnot
Last active January 11, 2022 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dboitnot/4ea1393801ce32a451e059fce05f4365 to your computer and use it in GitHub Desktop.
Save dboitnot/4ea1393801ce32a451e059fce05f4365 to your computer and use it in GitHub Desktop.
Simulate packing to size an container cluster
#!/usr/bin/env python3
containers = [
3172, # UI Gateway
5196, # UI tomcat
1224, # Transit UI
1224, # Controller
1224, # ScribeUI
1224, # Applicant API
1224, # Composer
1224, # API Services
]
containers = containers * 12 # There will be 12 instances of DW hosted in this cluster.
instance_size = 32768 # t2/t3.2xlarge
instances = []
def place(n):
if n > instance_size:
raise ValueError("n greater than instances size")
for i in range(len(instances)):
if instances[i] >= n:
instances[i] = instances[i] - n
return
instances.append(instance_size - n)
for c in containers:
place(c)
print(instances)
print("instance count:", len(instances))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment