0

I made a test flask application that looks like the following:

from flask import Flask
from flask_cors import CORS
import os

app = Flask(__name__)
CORS(app)


@app.route('/')
def hello_word():
    return 'hello', 200


if __name__ == '__main__':
    app.run(threaded=True, host='0.0.0.0', port=int(os.environ.get("PORT", 8080)))

However, if i host this application on Azure Container Instance, the application never "stops". The memory usage is always at around 50mb and I'm constantly getting charged. If I host the same application on Google Cloud run, I'm only charged for the request time (20ms or so). The following is my dockerfile

FROM python:3.9-slim

RUN apt-get update -y
RUN apt-get install -y python-pip python-dev build-essential

COPY . /app
WORKDIR /app

RUN pip install -r requirements.txt
RUN pip install Flask gunicorn

ENV PORT=80

CMD exec gunicorn --bind :$PORT --workers 3 --threads 3 --timeout 100 main:app  --access-logfile -

Any thoughts on how to stop the container instance once the request is served on Azure?

1
  • 2
    It sounds like the Azure equivalent of what you want is function apps, not container service. stackoverflow.com/questions/55154608/… A function app only runs for the time that you need it. Commented Jan 31, 2021 at 0:00

1 Answer 1

2

Actually, the ACI just run the image for you and nothing else. It means if your image has an application that keeps running, then the ACI keeps running. And it seems you need to schedule to stop the ACI, maybe you can try the Azure logic App. You can use it to create the ACI and then stop it after a period that you need.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.