|
1 | 1 | from service_capacity_modeling.capacity_planner import planner
|
| 2 | +from service_capacity_modeling.interface import AccessPattern |
2 | 3 | from service_capacity_modeling.interface import CapacityDesires
|
3 | 4 | from service_capacity_modeling.interface import certain_float
|
4 | 5 | from service_capacity_modeling.interface import CurrentClusters
|
5 | 6 | from service_capacity_modeling.interface import CurrentZoneClusterCapacity
|
| 7 | +from service_capacity_modeling.interface import DataShape |
| 8 | +from service_capacity_modeling.interface import Drive |
| 9 | +from service_capacity_modeling.interface import DriveType |
| 10 | +from service_capacity_modeling.interface import FixedInterval |
6 | 11 | from service_capacity_modeling.interface import Interval
|
7 | 12 | from service_capacity_modeling.interface import QueryPattern
|
8 | 13 | from service_capacity_modeling.models.common import normalize_cores
|
@@ -65,7 +70,7 @@ def test_kafka_large_scale():
|
65 | 70 | region="us-east-1",
|
66 | 71 | desires=desires,
|
67 | 72 | extra_model_arguments={
|
68 |
| - "cluster_type": "strong", |
| 73 | + "cluster_type": ClusterType.strong, |
69 | 74 | "retention": "PT4H",
|
70 | 75 | },
|
71 | 76 | )
|
@@ -339,3 +344,94 @@ def test_plan_certain():
|
339 | 344 | assert len(lr_clusters) >= 1
|
340 | 345 | print(lr_clusters[0].instance.name)
|
341 | 346 | assert lr_clusters[0].count == cluster_capacity.cluster_instance_count.high
|
| 347 | + |
| 348 | + |
| 349 | +def test_plan_certain_data_shape(): |
| 350 | + """ |
| 351 | + Use current clusters cpu utilization to determine instance types directly as |
| 352 | + supposed to extrapolating it from the Data Shape |
| 353 | + """ |
| 354 | + cluster_capacity = CurrentZoneClusterCapacity( |
| 355 | + cluster_instance_name="r7a.4xlarge", |
| 356 | + cluster_drive=Drive( |
| 357 | + name="gp3", |
| 358 | + drive_type=DriveType.attached_ssd, |
| 359 | + size_gib=5000, |
| 360 | + block_size_kib=16, |
| 361 | + ), |
| 362 | + cluster_instance_count=Interval(low=15, mid=15, high=15, confidence=1), |
| 363 | + cpu_utilization=Interval( |
| 364 | + low=5.441147804260254, |
| 365 | + mid=13.548842955300195, |
| 366 | + high=25.11203956604004, |
| 367 | + confidence=1, |
| 368 | + ), |
| 369 | + memory_utilization_gib=Interval(low=0, mid=0, high=0, confidence=1), |
| 370 | + network_utilization_mbps=Interval( |
| 371 | + low=4580.919447446355, |
| 372 | + mid=19451.59814477331, |
| 373 | + high=42963.441154527085, |
| 374 | + confidence=1, |
| 375 | + ), |
| 376 | + disk_utilization_gib=Interval( |
| 377 | + low=1341.579345703125, |
| 378 | + mid=1940.8741284013684, |
| 379 | + high=2437.607421875, |
| 380 | + confidence=1, |
| 381 | + ), |
| 382 | + ) |
| 383 | + |
| 384 | + desires = CapacityDesires( |
| 385 | + service_tier=1, |
| 386 | + current_clusters=CurrentClusters(zonal=[cluster_capacity]), |
| 387 | + query_pattern=QueryPattern( |
| 388 | + access_pattern=AccessPattern(AccessPattern.latency), |
| 389 | + # 2 consumers |
| 390 | + estimated_read_per_second=Interval(low=2, mid=2, high=4, confidence=1), |
| 391 | + # 1 producer |
| 392 | + estimated_write_per_second=Interval(low=1, mid=1, high=1, confidence=0.98), |
| 393 | + estimated_mean_read_latency_ms=Interval(low=1, mid=1, high=1, confidence=1), |
| 394 | + estimated_mean_write_latency_ms=Interval( |
| 395 | + low=1, mid=1, high=1, confidence=1 |
| 396 | + ), |
| 397 | + estimated_mean_read_size_bytes=Interval( |
| 398 | + low=1024, mid=1024, high=1024, confidence=1 |
| 399 | + ), |
| 400 | + estimated_mean_write_size_bytes=Interval( |
| 401 | + low=125000000, mid=579000000, high=1351000000, confidence=0.98 |
| 402 | + ), |
| 403 | + estimated_read_parallelism=Interval(low=1, mid=1, high=1, confidence=1), |
| 404 | + estimated_write_parallelism=Interval(low=1, mid=1, high=1, confidence=1), |
| 405 | + read_latency_slo_ms=FixedInterval(low=0.4, mid=4, high=10, confidence=0.98), |
| 406 | + write_latency_slo_ms=FixedInterval( |
| 407 | + low=0.4, mid=4, high=10, confidence=0.98 |
| 408 | + ), |
| 409 | + ), |
| 410 | + data_shape=DataShape( |
| 411 | + estimated_state_size_gib=Interval( |
| 412 | + low=44000, mid=86000, high=91000, confidence=1 |
| 413 | + ), |
| 414 | + ), |
| 415 | + ) |
| 416 | + |
| 417 | + cap_plan = planner.plan_certain( |
| 418 | + model_name="org.netflix.kafka", |
| 419 | + region="us-east-1", |
| 420 | + num_results=3, |
| 421 | + num_regions=4, |
| 422 | + desires=desires, |
| 423 | + extra_model_arguments={ |
| 424 | + "cluster_type": ClusterType.ha, |
| 425 | + "retention": "PT8H", |
| 426 | + "require_attached_disks": True, |
| 427 | + "required_zone_size": cluster_capacity.cluster_instance_count.mid, |
| 428 | + }, |
| 429 | + ) |
| 430 | + |
| 431 | + assert len(cap_plan) >= 1 |
| 432 | + lr_clusters = cap_plan[0].candidate_clusters.zonal |
| 433 | + assert len(lr_clusters) >= 1 |
| 434 | + print(lr_clusters[0].instance.name) |
| 435 | + assert lr_clusters[0].count == cluster_capacity.cluster_instance_count.high |
| 436 | + for lr in cap_plan: |
| 437 | + print(lr.candidate_clusters.zonal[0]) |
0 commit comments