Skip to content

Commit

Permalink
Determine postgres region topology by using num_regions instead of ex…
Browse files Browse the repository at this point in the history
…tra arguments
  • Loading branch information
ShengweiWang committed Sep 15, 2023
1 parent 822bde0 commit 3599b25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
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"

0 comments on commit 3599b25

Please sign in to comment.