From ee49c54525aae584a100e043713e6fd7e87070af Mon Sep 17 00:00:00 2001 From: Sigurd Pettersen Date: Thu, 21 Nov 2024 21:59:00 +0100 Subject: [PATCH] Add performance metrics to surface query service and adjust Radix configuration for scaling --- backend_py/primary/primary/main.py | 1 + .../surface_query_service.py | 18 +++++++++++++++++- radixconfig.yml | 10 +++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/backend_py/primary/primary/main.py b/backend_py/primary/primary/main.py index d2e9fa22e..6f12bf57a 100644 --- a/backend_py/primary/primary/main.py +++ b/backend_py/primary/primary/main.py @@ -46,6 +46,7 @@ logging.getLogger("primary.services.sumo_access").setLevel(logging.DEBUG) logging.getLogger("primary.services.user_session_manager").setLevel(logging.DEBUG) logging.getLogger("primary.services.user_grid3d_service").setLevel(logging.DEBUG) +logging.getLogger("primary.services.surface_query_service").setLevel(logging.DEBUG) logging.getLogger("primary.routers.grid3d").setLevel(logging.DEBUG) logging.getLogger("primary.routers.dev").setLevel(logging.DEBUG) diff --git a/backend_py/primary/primary/services/surface_query_service/surface_query_service.py b/backend_py/primary/primary/services/surface_query_service/surface_query_service.py index ca8e19f37..4841ac36c 100644 --- a/backend_py/primary/primary/services/surface_query_service/surface_query_service.py +++ b/backend_py/primary/primary/services/surface_query_service/surface_query_service.py @@ -11,6 +11,9 @@ from primary import config from primary.services.sumo_access.sumo_blob_access import get_sas_token_and_blob_store_base_uri_for_case +from webviz_pkg.core_utils.perf_metrics import PerfMetrics + + LOGGER = logging.getLogger(__name__) @@ -51,6 +54,9 @@ async def batch_sample_surface_in_points_async( x_coords: list[float], y_coords: list[float], ) -> List[RealizationSampleResult]: + + perf_metrics = PerfMetrics() + realization_object_ids = await _get_object_uuids_for_surface_realizations( sumo_access_token=sumo_access_token, case_uuid=case_uuid, @@ -59,9 +65,15 @@ async def batch_sample_surface_in_points_async( surface_attribute=surface_attribute, realizations=realizations, ) - + + perf_metrics.record_lap("get-obj-ids") + sas_token, blob_store_base_uri = get_sas_token_and_blob_store_base_uri_for_case(sumo_access_token, case_uuid) + #LOGGER.debug(f"Token: {sas_token}") + + perf_metrics.record_lap("sas-token") + request_body = _PointSamplingRequestBody( sasToken=sas_token, blobStoreBaseUri=blob_store_base_uri, @@ -74,6 +86,8 @@ async def batch_sample_surface_in_points_async( LOGGER.info(f"Running async go point sampling for surface: {surface_name}") response: httpx.Response = await client.post(url=SERVICE_ENDPOINT, json=request_body.model_dump()) + perf_metrics.record_lap("main-call") + json_data: bytes = response.content response_body = _PointSamplingResponseBody.model_validate_json(json_data) @@ -82,6 +96,8 @@ async def batch_sample_surface_in_points_async( values_np = np.asarray(res.sampledValues) res.sampledValues = np.where((values_np < response_body.undefLimit), values_np, np.nan).tolist() + LOGGER.debug(f"------------------ batch_sample_surface_in_points_async() took: {perf_metrics.to_string_s()}") + return response_body.sampleResultArr diff --git a/radixconfig.yml b/radixconfig.yml index ccd4a8d1e..4a2257e3e 100644 --- a/radixconfig.yml +++ b/radixconfig.yml @@ -134,7 +134,7 @@ spec: cpu: 2000m horizontalScaling: minReplicas: 1 - maxReplicas: 16 + maxReplicas: 8 resources: memory: averageUtilization: 60 @@ -145,13 +145,13 @@ spec: resources: requests: memory: 32Gi - cpu: 8000m + cpu: 32000m limits: memory: 32Gi - cpu: 8000m + cpu: 32000m horizontalScaling: - minReplicas: 16 - maxReplicas: 16 + minReplicas: 8 + maxReplicas: 8 resources: memory: averageUtilization: 60