googleads / google-ads-php

Google Ads API Client Library for PHP
https://developers.google.com/google-ads/api/docs/client-libs/php
Apache License 2.0
288 stars 260 forks source link

Question about performance (big datasets) #952

Open AlexRyabikov opened 11 months ago

AlexRyabikov commented 11 months ago

Hi! Team from Google ADS API forum send me here :)

I have a question about optimization: Our project is an advertising agency, and we use an API, which has been working fine for us. However, we now have a task to retrieve large sets of data (keywords, budgets) for building reports in BI. Unfortunately, the functions in the Google Ads PHP library that we are using are showing very low performance (1 request takes 1-2 seconds. With volumes in the tens of thousands of clients, this is a very resource-intensive operation). Could you please suggest alternatives for solving this issue?

fiboknacky commented 11 months ago

Generally, what's in the Optimization guide all apply in the client library as well. You might probably get suggested by the forum agents already. Make sure you check this out too.

1 request takes 1-2 seconds

How large is the result of your request?

AlexRyabikov commented 11 months ago

Hi! Request of keywords is around 30k - 45k requests to API (because of big amount accounts of our little clients), so that's a headache with php scripts :)

Thanks for links, I'll check it out

fiboknacky commented 11 months ago

I mean how many rows (in case of searching) or how many campaigns do you mutate per request--the one that you mentioned it takes 1-2 seconds?

AlexRyabikov commented 11 months ago

Well, unfortunately, its difficult to say about how request in case of keywords, but for getting budgets case - its ~1 second per 1 account. But its because out function looks like this: private function QueryGetData($customerId){ //here is the query etc } - 1 account per request

So, idk, is it possible to rewrite it to make possible to take data from several accounts per 1 request? How do you think?

hakimio commented 10 months ago

@AlexRyabikov you could use non-blocking searchAsync() method which returns PromiseInterface and call wait() on the promise after making multiple requests. You can find basic searchAsync() implementation in my feature request.

AlexRyabikov commented 10 months ago

@hakimio hi! Thanks, sounds good for me. I'll check it out :)

hakimio commented 3 months ago

This can be closed now, since searchAsync was added to the client library in v21.1.0.