How to increase performance Http trigger azure function?

Marti Kevin 26 Reputation points
2020-10-19T08:51:32.047+00:00

Hello there

I was wondering, do you have an example how to decrease the latency of an http trigger response in a python azure function app? I want the function to return the http response as fast as possible and take its time for the backend process of saving the response to our blob storage account. how do I do that? I think with asyncio but I am not sure how to return the http response without awaiting the backendprocess of saving the response works.

import azure.functions as func


def main(req: func.HttpRequest, outputJson: func.Out[func.InputStream]) -> func.HttpResponse:


    business_logic = BusinessLogic()
    response = business_logic.get_response()


    outputJson.set(response.to_json())  #save the response to a storage blob 


    return func.HttpResponse(
             str(response),
             status_code=200
        )

Best regards

Kevin Marti

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
3,986 questions
0 comments No comments
{count} votes

Accepted answer
  1. Mike Urnun 8,996 Reputation points Microsoft Employee
    2020-10-19T20:42:13.647+00:00

    Hello Kevin,

    On the infra side, you can enable the Always On setting if you haven't. As for returning a response ASAP while processing the job in the background, you can switch to Azure Durable Functions and leverage a pattern called: Polling Consumer Pattern


1 additional answer

Sort by: Most helpful
  1. Marti Kevin 26 Reputation points
    2020-10-23T13:32:24.653+00:00

    Hi MikeUnun

    that was indeed helpful!I have no other Questions.

    Cheers

    Kevin Marti

    0 comments No comments