Search code examples
azuredockerfilecontainers

Azure Container Scaled Down to 0 Automatically


I am new to Azure docker container

I am building a docker image in VS code with the help of extensions, I have now published to ACR and I can see my container has been deployed.

I can hit the url and I can see logs as well but after few minutes container is automatically scaled down to 0 and stopped logging anything.

I could not see any scale setting in VSCode when building/deploying the image, so I am not sure where and how can I set it to always running.

I can share dockerFile but I am not typing any command and using VS code UI instead. I have also removed everything form my code and just log "hello world" so there is not exception or anything.

This container runs async which means a service bus queue receives a messages and then a function in a function app is triggered.

enter image description here

and this is what I see in system logs

enter image description here


Solution

  • When you first create a container app in Azure, the scale rule is set to Zero because Azure Container app is fully Server-less as given in this Microsoft Document.

    Practical 1: Quick Start - Hello World Container

    I have created the Azure Container App with the Quick Hello-World Image with the default “Http Scaling” rule and browsed the Azure Container App Site after deployment:

    enter image description here
    As it is in running state, the replica is 1.

    enter image description here


    I can hit the url and I can see logs as well but after few minutes container is automatically scaled down to 0 and stopped logging anything.

    Note: If any requests or traffic is not sent to the application URL within the cooling period of 5 minutes, then it automatically scales down to 0 replicas as mentioned in above MS document.


    Practical 2: Docker Container Image

    Following this tutorial of CoachDevOps, I uploaded the docker image to ACR that contains python application and this ACR Image to the Azure Container app.

    enter image description here

    If you see the scaling part, by default it is taken as 0 to 10 while provisioning the Azure Container App where you can edit the scale rule and method of scaling.
    enter image description here

    Here my application is not sending any traffic to the container so it is scaled down to 0.

    enter image description here

    so I am not sure where and how can I set it to always running.

    1. Try pinging to the uploaded image application using ApacheJMeter by giving some load and many requests, then it will automatically scales-up
    2. Edit the scale setting of minimum replicas to 1 and maximum replicas to the required number so that always 1 instance of Azure container app will be in running state.
    3. Configure the Health Probe so that it sends the TCP ping and checks it is healthy or not.
    4. Check the Scaling algorithm example given in this Microsoft Doc and define the appropriate the scaling rules to be in running state.