diff --git a/src/domains/functions/env/prod/terraform.tfvars b/src/domains/functions/env/prod/terraform.tfvars index 63d5c37c1..977b7d9a5 100644 --- a/src/domains/functions/env/prod/terraform.tfvars +++ b/src/domains/functions/env/prod/terraform.tfvars @@ -23,7 +23,7 @@ cidr_subnet_services = ["10.0.139.0/26", "10.0.139.64/26"] function_services_kind = "Linux" function_services_sku_tier = "PremiumV3" function_services_sku_size = "P1v3" -function_services_autoscale_minimum = 6 +function_services_autoscale_minimum = 3 function_services_autoscale_maximum = 30 function_services_autoscale_default = 10 diff --git a/src/domains/functions/function_services.tf b/src/domains/functions/function_services.tf index 736ba2a78..82cbfdf6b 100644 --- a/src/domains/functions/function_services.tf +++ b/src/domains/functions/function_services.tf @@ -409,6 +409,110 @@ resource "azurerm_monitor_autoscale_setting" "function_services_autoscale" { } } } + + profile { + name = "wallet_gate0" + + capacity { + default = var.function_services_autoscale_default + minimum = 6 + maximum = var.function_services_autoscale_maximum + } + + fixed_date { + timezone = "W. Europe Standard Time" + start = "2024-10-15T08:00:00.000Z" + end = "2024-10-15T23:30:00.000Z" + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_services[count.index].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT1M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 3000 + divide_by_instance_count = true + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_services[count.index].app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT1M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 40 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "3" + cooldown = "PT2M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_services[count.index].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 300 + divide_by_instance_count = true + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_services[count.index].app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 15 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT2M" + } + } + } } # Cosmos container for subscription cidrs