Skip to content

Commit 926b5b2

Browse files
authored
Adjust container apps to scale to zero (#2440)
* Adjust container app parameters to reduce costs * Change back to enough CPU/memory
1 parent 62f8b58 commit 926b5b2

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ The repo includes sample data so it's ready to try end to end. In this sample ap
8484
Pricing varies per region and usage, so it isn't possible to predict exact costs for your usage.
8585
However, you can try the [Azure pricing calculator](https://azure.com/e/e3490de2372a4f9b909b0d032560e41b) for the resources below.
8686

87-
- Azure Container Apps: Default host for app deployment as of 10/28/2024. See more details in [the ACA deployment guide](docs/azure_container_apps.md). Consumption plan with 1 CPU core, 2.0 GB RAM. Pricing with Pay-as-You-Go. [Pricing](https://azure.microsoft.com/pricing/details/container-apps/)
87+
- Azure Container Apps: Default host for app deployment as of 10/28/2024. See more details in [the ACA deployment guide](docs/azure_container_apps.md). Consumption plan with 1 CPU core, 2 GB RAM, minimum of 0 replicas. Pricing with Pay-as-You-Go. [Pricing](https://azure.microsoft.com/pricing/details/container-apps/)
8888
- Azure Container Registry: Basic tier. [Pricing](https://azure.microsoft.com/pricing/details/container-registry/)
8989
- Azure App Service: Only provisioned if you deploy to Azure App Service following [the App Service deployment guide](docs/azure_app_service.md). Basic Tier with 1 CPU core, 1.75 GB RAM. Pricing per hour. [Pricing](https://azure.microsoft.com/pricing/details/app-service/linux/)
9090
- Azure OpenAI: Standard tier, GPT and Ada models. Pricing per 1K tokens used, and at least 1K tokens are used per question. [Pricing](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/)

docs/productionizing.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,15 @@ We recommend using a Premium level SKU, starting with 1 CPU core.
7575
You can use auto-scaling rules or scheduled scaling rules,
7676
and scale up the maximum/minimum based on load.
7777

78+
### Azure Container Apps
79+
80+
The default container app uses a "Consumption" workload profile with 1 CPU core and 2 GB RAM,
81+
and scaling rules that allow for scaling all the way down to 0 replicas when idle.
82+
For production, consider either increasing the CPU cores and memory or
83+
[switching to a "Dedicated" workload profile](azure_container_apps.md#customizing-workload-profile),
84+
and configure the scaling rules to keep at least two replicas running at all times.
85+
Learn more in the [Azure Container Apps documentation](https://learn.microsoft.com/azure/container-apps).
86+
7887
## Additional security measures
7988

8089
* **Authentication**: By default, the deployed app is publicly accessible.

infra/core/host/container-app-upsert.bicep

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ param containerMaxReplicas int = 10
1414
@description('The amount of memory allocated to a single container instance, e.g., 1Gi')
1515
param containerMemory string = '1.0Gi'
1616

17-
@description('The minimum number of replicas to run. Must be at least 1.')
18-
@minValue(1)
17+
@description('The minimum number of replicas to run. Must be at least 1 for non-consumption workloads.')
1918
param containerMinReplicas int = 1
2019

2120
@description('The name of the container')

infra/main.bicep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,7 @@ module acaBackend 'core/host/container-app-upsert.bicep' = if (deploymentTarget
518518
targetPort: 8000
519519
containerCpuCoreCount: '1.0'
520520
containerMemory: '2Gi'
521+
containerMinReplicas: 0
521522
allowedOrigins: allowedOrigins
522523
env: union(appEnvVariables, {
523524
// For using managed identity to access Azure resources. See https://github.com/microsoft/azure-container-apps/issues/442

0 commit comments

Comments
 (0)