Skip to content

Commit 1f35091

Browse files
Merge pull request #296721 from craigshoemaker/aca/cold-start
[Container Apps] New: Reducing cold starts
2 parents bcf3898 + 0d26047 commit 1f35091

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

articles/container-apps/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
href: planned-maintenance.md
7171
- name: Build and deliver apps with Container Apps (video)
7272
href: https://youtu.be/OxmVds31qL8
73+
- name: Reduce cold-start times
74+
href: cold-start.md
7375
- name: Develop & deploy
7476
items:
7577
- name: Deployment options

articles/container-apps/cold-start.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Reducing cold-start time on Azure Container Apps
3+
description: Learn best practices for creating rapid response times for container apps that have scaled to zero.
4+
services: container-apps
5+
author: craigshoemaker
6+
ms.service: azure-container-apps
7+
ms.topic: conceptual
8+
ms.date: 03/20/2025
9+
ms.author: cshoe
10+
---
11+
12+
# Reducing cold-start time on Azure Container Apps
13+
14+
When your container app scales to zero during periods of inactivity, the next incoming request triggers a *cold start*. A cold-start is the time-consuming process of pulling your container image, provisioning resources, and starting your application code.
15+
16+
This delay impacts user experience, especially for applications that require rapid response times. Cold-starts are often most noticeable in scenarios involving large container images, complex application initialization, or ML/AI workloads.
17+
18+
This guide helps you mitigate cold-start times in Azure Container Apps.
19+
20+
## Optimize container image size
21+
22+
Machine learning and AI-heavy workloads are often associated with large container images. Whenever possible, reduce the size of these images as much as possible and eliminate any use of unnecessary libraries.
23+
24+
Often images transition training to inference usage with only minimal tweaks. Make sure to audit your containers to remove development tools and dependencies only required for model development as you prepare your container for inference use.
25+
26+
## Avoid far away image registries
27+
28+
Use container registries close to your Container Apps environment. Usually this means you want to use an Azure Container Registry deployed in the same region as your environment, or a premium registry that features global distribution.
29+
30+
## Use artifact streaming
31+
32+
Azure Container Registry [offers image streaming](/azure/container-apps/serverless-gpu-nim#enable-artifact-streaming-recommended-but-optional) which can speed up image startup by up to 15%.
33+
34+
## Implement custom liveness health probe or start listening early
35+
36+
Azure Container Apps automatically sets up a [liveness probe](health-probes.md) when ingress is enabled. Images and applications take a long time to start after the image is launched can cause issues with the container. Container Apps could kill the starting application because it fails the liveness probe.
37+
38+
To solve stop Container Apps from prematurely killing an image, implement a custom liveness probe to allow for longer startups. Alternatively, you can listen on the dedicated target port for simple connections earlier in the startup cycle to initialize your application after the port is open.
39+
40+
## Client-side accommodations
41+
42+
Cold-start times vary depending on your application. To reduce the perception of this time as much as possible, fine-tune your clients to accommodate the delay.
43+
44+
Signaling to users that a certain request could take longer and implementing retries is essential. You can also harden your code to avoid unexpected time-outs which exceed what your application can gracefully handle.
45+
46+
## Application-side instrumentation
47+
48+
For troubleshooting performance issues, implement application-side performance metrics and logging for every stage in your application lifecycle.
49+
50+
## Proactively wake your app
51+
52+
If the above recommendations don’t provide the desired performance, wake your app ahead of any actual usage. For example, consider setting up a job at 9am to wake the application ahead of employees starting their work day. This approach could eliminate lengthy cold-starts while still allowing for scale-to-zero cost-savings whenever the app isn't in use.
53+

0 commit comments

Comments
 (0)