Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine postgres region topology by using num_regions #68

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion service_capacity_modeling/models/org/netflix/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def capacity_plan(
if desires.service_tier == 0:
return None

require_multi_region: bool = extra_model_arguments.get("require_multi_region", False)
require_multi_region: bool = context.num_regions > 1
plan = None
if Platform.aurora_postgres in instance.platforms and not require_multi_region:
plan = nflx_aurora_capacity_model.capacity_plan(
Expand Down
11 changes: 6 additions & 5 deletions tests/netflix/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def test_tier_0_not_supported():
model_name="org.netflix.postgres",
region="us-east-1",
desires=tier_0,
num_regions=1,
)
# Aurora can't support tier 0 service
assert len(cap_plan) == 0
Expand All @@ -77,6 +78,7 @@ def test_small_footprint():
model_name="org.netflix.postgres",
region="us-east-1",
desires=small_footprint,
num_regions=1,
)
assert cap_plan[0].candidate_clusters.regional[0].instance.name == "db.r5.large"

Expand All @@ -95,7 +97,7 @@ def test_small_footprint_multi_region():
model_name="org.netflix.postgres",
region="us-east-1",
desires=small_footprint,
extra_model_arguments={"require_multi_region": True}
num_regions=3,
)
assert cap_plan[0].candidate_clusters.zonal[0].instance.name == "m5d.xlarge"

Expand All @@ -105,16 +107,13 @@ def test_small_footprint_multi_region():
< 4000
)

planner.plan(model_name="org.netflix.postgres", region="us-east-1", desires=small_footprint,
extra_model_arguments={"require_multi_region": False})


def test_small_footprint_plan_uncertain():
cap_plan = planner.plan(
model_name="org.netflix.postgres",
region="us-east-1",
desires=small_footprint,
extra_model_arguments={"require_multi_region": False},
num_regions=1,
simulations=256
)
plan_a = cap_plan.least_regret[0]
Expand All @@ -133,6 +132,7 @@ def test_large_footprint():
model_name="org.netflix.postgres",
region="us-east-1",
desires=large_footprint,
num_regions=1,
)
# Aurora cannot handle the scale, so pick crdb
assert cap_plan[0].candidate_clusters.zonal[0].instance.name == "i3.xlarge"
Expand All @@ -150,5 +150,6 @@ def test_tier_3():
model_name="org.netflix.postgres",
region="us-east-1",
desires=tier_3,
num_regions=1,
)
assert cap_plan[0].candidate_clusters.regional[0].instance.name == "db.r5.2xlarge"
Loading