diff --git a/service_capacity_modeling/models/org/netflix/kafka.py b/service_capacity_modeling/models/org/netflix/kafka.py index c792360..218ff0b 100644 --- a/service_capacity_modeling/models/org/netflix/kafka.py +++ b/service_capacity_modeling/models/org/netflix/kafka.py @@ -149,6 +149,8 @@ def _kafka_read_io(rps, io_size_kib, size_gib, recovery_seconds: int) -> float: return (read_ios + int(round(recovery_ios))) * 1.5 +# pylint: disable=too-many-locals +# pylint: disable=too-many-return-statements def _estimate_kafka_cluster_zonal( instance: Instance, drive: Drive, @@ -165,12 +167,8 @@ def _estimate_kafka_cluster_zonal( min_instance_memory_gib: int = 12, ) -> Optional[CapacityPlan]: - # Kafka doesn't like to deploy on single CPU instances - if instance.cpu < min_instance_cpu: - return None - - # Kafka doesn't like to deploy to instances with < 7 GiB of ram - if instance.ram_gib < min_instance_memory_gib: + # Kafka doesn't like to deploy on single CPU instances or with < 12 GiB of ram + if instance.cpu < min_instance_cpu or instance.ram_gib < min_instance_memory_gib: return None # if we're not allowed to use attached disks, skip EBS only types @@ -377,9 +375,7 @@ def capacity_plan( max_local_disk_gib: int = extra_model_arguments.get( "max_local_disk_gib", 1024 * 5 ) - min_instance_cpu: int = extra_model_arguments.get( - "min_instance_cpu", 2 - ) + min_instance_cpu: int = extra_model_arguments.get("min_instance_cpu", 2) min_instance_memory_gib: int = extra_model_arguments.get( "min_instance_memory_gib", 12 ) diff --git a/tests/netflix/test_kafka.py b/tests/netflix/test_kafka.py index ce8fee0..8bed809 100644 --- a/tests/netflix/test_kafka.py +++ b/tests/netflix/test_kafka.py @@ -209,6 +209,7 @@ def test_kafka_high_throughput_ebs(): disk = clstr.attached_drives[0].size_gib * clstr.count assert expected_disk[0] < disk < expected_disk[1] * 2.5 + def test_kafka_model_constraints(): # 2.8 GiB / second throughput = 2.8 * 1024 * 1024 * 1024 @@ -239,7 +240,7 @@ def test_kafka_model_constraints(): "retention": "PT3H", "require_attached_disks": require_attached_disks, "min_instance_cpu": min_instance_cpu, - "required_zone_size": required_zone_size + "required_zone_size": required_zone_size, }, num_results=3, ) @@ -261,7 +262,7 @@ def test_kafka_model_constraints(): "retention": "PT3H", "require_local_disks": True, "min_instance_cpu": min_instance_cpu, - "required_zone_size": required_zone_size + "required_zone_size": required_zone_size, }, num_results=3, )