google-cloud-platformgoogle-cloud-functions

Google Cloud Function The request was aborted because there was no available instance


When running some cloud functions, I am getting sometimes the error:

The request was aborted because there was no available instance.

I have seen other questions being asked with similar error but for Cloud Run where you can specify the number of instances available, but it doesnt look like there is such a thing with Cloud Function. So how to solve this problem?

I can see on the quotas page that there are limits for background functions but none for HTTP functions. I am calling the lambda function via HTTP, and it is deployed in us-central1


Solution

  • According to GCP dashboard, there's a currently ongoing deployment failures for both region us-central1 and europe-west1. For now there are two reasons I can think of behind the error:

    1. The ongoing issue has an indirect effect where no instances can currently handle the request.
    2. There's an initial bursts of requests coming, to the point where Cloud Functions cannot scale fast enough despite not hitting max_instances.

    Solution for #1 is to temporarily re-deploy your function to another region. The solution for #2 is to implement some sort of retry logic into your function. Note that automatic retries are not available in HTTP functions, so you will have to implement it with your own logic.

    If it doesn't work for you, then there's another option to implement a queuing mechanism with Cloud Tasks to handle sudden bursts of traffic and handle retries if the request fails.