The client library for Perl eases interactions with the Google Ads API, with minimal configuration on your part. However, performance highly depends on how the library is used and integrated.
Most of these best practices are applicable to all languages. This guide goes through the ones that are specific to Perl.
Profiling your application
Profile your application both for CPU and memory usage to identify performance bottlenecks. Devel::NYTProf is a powerful feature-rich Perl source code profiler that you can explore.
Perl version
It is a good practice to regularly upgrade to a newer Perl version as it usually comes with better overall performance. See here for the latest Perl version, and the minimum required version for the library in this page.
Logging
Extensive logging can incur significant execution time penalties and memory
consumption. We recommend setting the logging level to WARN
for any code in
production.
See the Logging guide for more details about the configuration of summary and detail loggers.
Search or SearchStream method
Google Ads API provides two main methods to retrieve objects --
Search
(which uses pagination) and
SearchStream
(which uses streaming).
SearchStream
provides better performance over Search
method, but there might
be certain scenarios where Search
method might be preferred.
You can learn more about the two methods here.
HTTP timeout
The Perl client library provides a surface for setting HTTP timeouts on the client level:
my $api_client = Google::Ads::GoogleAds::GoogleAdsClient->new({
# Set HTTP timeout to 5 minutes.
http_timeout => 300
});
The default value is set based on the DEFAULT_HTTP_TIMEOUT
setting in
Constants.pm.
Set a lower value if you
need to enforce a shorter limit on the maximum time for an API call.
You can set the timeout to 2 hours or more, but the API may still time out
extremely long-running requests and return a
DEADLINE_EXCEEDED
error.
If you encounter that error, split the request up and execute the chunks in
parallel; this avoids the situation where a long running request fails and
the only way to recover is to trigger the request again from the start.