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

Adding support for multiregion aurora #97

Merged
merged 2 commits into from
Dec 9, 2024
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
23 changes: 1 addition & 22 deletions service_capacity_modeling/models/org/netflix/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from typing import Tuple

from .aurora import nflx_aurora_capacity_model
from .crdb import nflx_cockroachdb_capacity_model
from service_capacity_modeling.interface import AccessConsistency
from service_capacity_modeling.interface import AccessPattern
from service_capacity_modeling.interface import CapacityDesires
Expand Down Expand Up @@ -34,35 +33,15 @@ def capacity_plan(
if desires.service_tier == 0:
return None

require_multi_region: bool = context.num_regions > 1
plan = None
if Platform.aurora_postgres in instance.platforms and not require_multi_region:
if Platform.aurora_postgres in instance.platforms:
plan = nflx_aurora_capacity_model.capacity_plan(
instance=instance,
drive=drive,
context=context,
desires=desires,
extra_model_arguments=extra_model_arguments,
)

if plan is not None:
return plan

if set(nflx_cockroachdb_capacity_model.allowed_platforms()).intersection(
instance.platforms
):
plan = nflx_cockroachdb_capacity_model.capacity_plan(
instance=instance,
drive=drive,
context=context,
desires=desires,
extra_model_arguments=extra_model_arguments,
)
if plan is not None:
# We want to lower the rank so this plan will only be chosen when no other
# workaround
plan.rank = 1

return plan

@staticmethod
Expand Down
9 changes: 3 additions & 6 deletions tests/netflix/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def test_small_footprint_multi_region():
desires=small_footprint,
num_regions=3,
)
assert cap_plan[0].candidate_clusters.zonal[0].instance.name == "m5d.xlarge"
assert cap_plan[0].candidate_clusters.regional[0].instance.name == "db.r5.large"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider adding more validation on if the capacity planner is able to provide a multi-region plan

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after conversation we decided its okay


assert 2000 < cap_plan[0].candidate_clusters.total_annual_cost < 4000

Expand All @@ -126,11 +126,8 @@ def test_large_footprint():
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"
assert cap_plan[0].candidate_clusters.zonal[0].count == 41

assert 100_000 < cap_plan[0].candidate_clusters.total_annual_cost < 150_000
# Aurora cannot handle the scale, so don't recommend anything
assert cap_plan == []


def test_tier_3():
Expand Down
Loading