Page Summary
-
Performance of the Perl client library for the Google Ads API depends on how it is used and integrated.
-
Profiling your application for CPU and memory usage can identify performance bottlenecks, and
Devel::NYTProfis a useful tool for this. -
Regularly upgrading to a newer Perl version is recommended for better overall performance.
-
Setting the logging level to
WARNfor production code is advised to avoid performance penalties from extensive logging. -
SearchStreamgenerally offers better performance thanSearchfor retrieving objects, although there may be specific scenarios whereSearchis preferred. -
HTTP timeouts can be set on the client level, and for extremely long-running requests that might time out, splitting the request into parallel chunks is recommended.
The client library for Perl eases interactions with the Google Ads API, with minimal configuration on your part. However, performance depends significantly on how the library is used and integrated.
Most general best practices are applicable to all languages. This page covers performance guidance specific to Perl.
Profile your application
Profile your application for both CPU and memory usage to identify performance
bottlenecks. Devel::NYTProf is a feature-rich Perl source code
profiler that you can use to analyze execution time.
Perl version
Regularly upgrade to a newer Perl version to benefit from runtime performance improvements. Download the latest release from the CPAN Perl source releases, and check the minimum required version for the library in the README requirements.
Logging
Extensive logging can incur significant execution time penalties and memory
consumption. Set the logging level to WARN for any code in production.
See the Logging guide for more details about configuring summary and detail loggers.
SearchStream versus Search
The Google Ads API provides two main methods to retrieve objects:
Search (which uses pagination) and
SearchStream (which uses streaming). SearchStream
provides better performance than Search, though there are certain scenarios
where Search might be preferred.
For a detailed comparison of the two methods, see the Streaming guide.
Payload optimization and batching
To minimize network overhead and memory consumption:
- Request only the specific fields your application needs in your Google Ads Query Language (GAQL) queries.
- Group multiple mutate operations into a single
mutaterequest rather than sending individual requests for each change.
HTTP timeout
The Perl client library provides a setting for configuring HTTP timeouts at the client level:
my $api_client = Google::Ads::GoogleAds::Client->new({
# Set HTTP timeout to 5 minutes (300 seconds).
http_timeout => 300,
});
The default value is 3600 seconds (1 hour), set based on the
DEFAULT_HTTP_TIMEOUT constant in Constants.pm.
Set a custom client timeout 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 this error, split the request into smaller chunks and execute them 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.