ResourceExhausted: 429 Resource has been exhausted

1,756 views
Skip to first unread message

Vamsee Srinivas

unread,
Aug 7, 2024, 4:20:51 PM8/7/24
to Google Ads API and AdWords API Forum
Hi Team, 

I am using the google ads api service in my project and I follow the below given format inside the python function where I request metrics for keywords.

googleads_service = client.get_service("GoogleAdsService") keyword_plan_idea_service = client.get_service("KeywordPlanIdeaService") request = client.get_type("GenerateKeywordHistoricalMetricsRequest") request.customer_id = customer_id request.keywords = keywords request.geo_target_constants.append(googleads_service.geo_target_constant_path(geotarget_id)) request.keyword_plan_network = (client.enums.KeywordPlanNetworkEnum.GOOGLE_SEARCH) request.language = googleads_service.language_constant_path(language_id) request.historical_metrics_options = year_month_range response = keyword_plan_idea_service.generate_keyword_historical_metrics(request=request)

And I just wanna know how to calculate the operation in my scenario.

Upon checking the documentation, it says 15,000 API operations per day and 1 QPS is calculated as 60 requests per 60 seconds.

So in my scenario, I am using the function to fetch the keyword volumes of keywords per country and language combination. 

For example, if we consider United States and English, for this set I have 15,000 keywords and like this I have 36 unique country and language combinations. And the total keyword count is 2,50,000.

So  I have applied the chunking logic inside my code where I process 8000 keywords per group and last week upon running for the whole data, it ran and there was no issue.

But upon running this today, within 33 min I received the error below:
google.api_core.exceptions.ResourceExhausted: 429 Resource has been exhausted (e.g. check quota). [type_url: "type.googleapis.com/google.ads.googleads.v15.errors.GoogleAdsFailure"
value: "\n-\n\002X\002\022\'Too many requests. Retry in 30 seconds.
And I have used time.sleep(3) in my code.

So I am confused right now and more skeptical on how the google ads operations are being calculated here.

Is 1 operation equals 24 keywords per country and language or it is just per country.

If you could suggest some possible best practices it will be really helpful.

Best Regards,
Vamsee

Google Ads API Forum Advisor

unread,
Aug 8, 2024, 4:43:53 AM8/8/24
to vams...@gmail.com, adwor...@googlegroups.com
Hi,

Thank you for reaching out to the Google Ads API support team.

I understand that you have encountered the "RESOURCE_EXHAUSTED" error, which means that a system frequency limit has been exceeded. Kindly prevent sending too many requests in a short period of time and also ensure to set up short delays between requests or combine more operations in fewer requests. Also, please check this sample code for how to Handle a Rate Exceeded Error for more information.

Regarding operation calculation, each request is considered a single operation for the KeywordPlanIdeaService.GenerateKeywordHistoricalMetrics resource. In order to investigate the issue further, provide us with the complete API logs (request and response with request-id and request header) generated at your end to assist you better.

If you are using a client library and haven't enabled the logging yet, I would request you to enable logging for the specific client library that you are using. You can refer to the guides Java.NetPHPPythonRuby or Perl to enable logging at your end. For REST interface requests, you can enable logging via the curl command by using the -i flag.

You can send the details via Reply privately to the author option, or direct private reply to this email.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vEfdv:ref" (ADR-00262407)

Thanks,
 
Google Logo Google Ads API Team


 

Vamsee Srinivas

unread,
Nov 21, 2024, 5:40:11 AM11/21/24
to Google Ads API and AdWords API Forum
Hi,

Thank you for your prompt response.

When you mentioned that a "request" refers to an API call, could you please provide the specific link highlighted in the documentation for further clarification?

Regarding the resource, I am using the `KeywordPlanIdeaService` and the `GenerateKeywordHistoricalMetrics` method to generate historical metrics. This involves obtaining Google search volumes for a large set of keywords within specific country and language combinations.

To manage this, I have partitioned the dataset into 64 partitions, each containing a minimum of 10 million keywords for the given country and language. For the API calls, I have preprocessed the data into multiple groups, with each group containing 25,000 keywords. When making the API call, I request metrics for these 25,000 keywords per country and language.

Could you please confirm if each of these requests is considered a single operation?

Thank you for your assistance.

Best regards,  
Vamsee

Vamsee Srinivas

unread,
Nov 21, 2024, 5:42:54 AM11/21/24
to Google Ads API and AdWords API Forum
Additionally, do we have any specific limit on the maximum number of keywords that can be sent per API call?

On Thursday, 8 August 2024 at 14:13:53 UTC+5:30 Google Ads API Forum Advisor wrote:

Google Ads API Forum Advisor

unread,
Nov 21, 2024, 11:30:22 AM11/21/24
to vams...@gmail.com, adwor...@googlegroups.com
Hi,

Kindly note that the 1 QPS is calculated as 60 requests per 60 seconds and it is limited to 1 request per second per CID. If the requests that violate these limitations are rejected with the error: RESOURCE_EXHAUSTED. Also, note that the maximum of 10,000 keywords can be sent to the GenerateKeywordIdeasRequest. I would recommend you to check this documentation Planning services and article for more information. 

Also, note that you are using 'v15' which is deprecated and about to sunset on September 25, 2024. After this date, all v15 API requests will begin to fail. I would suggest you upgrade to the latest version, 'v18', as soon as possible to benefit from new features. You may refer to this documentation on deprecation and sunset for more information regarding the specific deprecation and sunset dates for each available version.
 
This message is in relation to case "ref:!00D1U01174p.!5004Q02vEfdv:ref" (ADR-00262407)

Thanks,
 
Google Logo Google Ads API Team

Feedback
How was our support today?

rating1    rating2    rating3    rating4    rating5



Reply all
Reply to author
Forward
0 new messages