blink_182
blink_182

Reputation: 67

Error: quota exceeded (Quota exceeded for quota group 'DNSResolutionsNonbillable' and limit 'DNS resolutions per day'

I'm testing a background function that counts the number of documents that are created which a specific field but I get this error.

I have understood I have 2 million invocations per month (includes both background and HTTP invocations by the project because of this and I just have 24 k. I use transaction because I'm testing the reliability of the results with transactions and from google.cloud.firestore_v1 import Increment.

From little data, I got the wrong count with an Increment approach. For example, from 15 projects the function gets 14, and also with 500 the function counts me one less but with more data, I got worst results (bigger difference) so I was hoping that this would not happen with transactions. However, now I can't test for this error, how could it be happening? Thank you for your time. This is the error:

Error: quota exceeded (Quota exceeded for quota group 'DNSResolutionsNonbillable' and limit 'DNS resolutions per day' of service 'cloudfunctions.googleapis.com' for consumer 'project_number:xxxx'.); to increase quotas, enable billing in your project at https://console.cloud.google.com/billing?project=xxxxx. Function cannot be executed.

This is the function it just decrease a number when a document is deleted:

def increase_total_documents(data,context):
    """ Triggered by a creation to a Firestore document.
        Args:
            data (dict): The event payload.
            context (google.cloud.functions.Context): Metadata for the event.
        """
    trigger_resource = context.resource
    print('Function triggered by change to: %s' % trigger_resource)
    value = data["value"]
    field = value["fields"]["FIELD"]["stringValue"]
    if field == "xfield":
        doc_ref = FIRESTORE_CLIENT.document('metadata/path')
        result = doc_ref.set({"count":Increment(1)},merge=True)
        number = result.transform_results[0].integer_value
        mensaje = "Number increased {}".format(number)
        print(mensaje)
        return mensaje

Upvotes: 2

Views: 666

Answers (1)

Dustin Ingram
Dustin Ingram

Reputation: 21550

In addition to the invocation limits, Cloud Functions limits the number of external addresses it will resolve when billing is not enabled. Like the error message is telling you, you need to enable billing in your project to raise the quota.

Upvotes: 0

Related Questions