SlideShare a Scribd company logo
1 of 52
Download to read offline
BatchJobService
A new approach to batch mutates
Agenda
● Sync vs. Async
● Batch job flow
● Temporary IDs
● Incremental Uploads
● Best practices
● Limitations
Synchronous
vs.
Asynchronous
Synchronous Requests
API Services Backend
Request
Response
RPC
RPC
return
Sends operation
OK: receives
status of the
operation
Asynchronous Requests
API Async
Services Backend
Request
Response
RPC
RPC
return
Operations
Operations
Op. return
Request
Sends all
Operations
OK: operations
will be processed
Check operations
status
Server sends the
results
Operations enter an
execution queue, and
release the request.
Response
Op. return
Async Processing Isn't Free
Asynchronous processes usually incur
additional overhead, such as:
● Scheduling
● Management/load-balancing of the job
queue
● Retry of failed operations
Synchronous vs. Asynchronous
Use Case Sync Async
Highly responsive user interface
Nightly bulk operations job
Fire-and-forget
Maximum throughput
AdWords API
Batch Job Flow
Batch Processing - Why Use It?
● Automatic retry of operations that
encounter transient errors such as:
○ CONCURRENT_MODIFICATION
○ UNEXPECTED_INTERNAL_API_ERROR
● Automatic retry of operations that
encounter rate limits
● Your application won't be blocked waiting
for a response.
Limitations of MutateJobService
● Error handling is difficult
○ Difficult to find the operation that failed
● Can't create dependent entities in a single
job
● MutateJobService has a much lower limit
on the number of operations (in the
thousands)
Introducing BatchJobService
● Allows setting temporary IDs on new
entities for dependent entity creation
● Each result contains an operation index
for correlating the result to its operation
● Much higher operations limit of 1 GB of
unprocessed operations
● Utilities are available in all client libraries
Farewell, MutateJobService
● BatchJobService is a
replacement for
MutateJobService
● MutateJobService is
going away
Supported Operations
AdGroupAdLabelOperation
AdGroupAdOperation
AdGroupBidModifierOperation
AdGroupCriterionLabelOperation
AdGroupCriterionOperation
AdGroupLabelOperation
AdGroupOperation
BudgetOperation
CampaignCriterionOperation
CampaignLabelOperation
CampaignOperation
FeedItemOperation
AdGroupAdService
AdGroupService
BudgetService
AdGroupBidModifierService
CampaignCriterionService
FeedItemService
CampaignService
AdGroupCriterionService
Basic Steps
Download the
results of the job
Upload the list
of operations
Poll the batch job's
status periodically
Operations
Results
2
3
4
Job
status
downloadUrl
Create a
BatchJob
BatchJobService
Job
1
uploadUrl
Creating the Batch Job
● Create the BatchJob object
BatchJobOperation addOp = new BatchJobOperation();
addOp.setOperator(Operator. ADD);
addOp.setOperand(new BatchJob());
BatchJob batchJob = batchJobService .mutate(
new BatchJobOperation[]{ addOp} ).getValue
(0);
● Make sure to grab the uploadUrl
// Get the upload URL from the new job.
String uploadUrl = batchJob.getUploadUrl().getUrl();
Creating the Batch Job (Cont.)
● Job status will be AWAITING_FILE
System.out.printf(
"Created BatchJob with ID %d, status '%s' and upload URL %s.%n" ,
batchJob.getId(),
batchJob.getStatus(),
uploadUrl);
$ Created BatchJob with ID <ID>, status 'AWAITING_FILE' and upload URL <URL>.
● Creating the BatchJob is a synchronous
operation!
Campaign campaign = new Campaign();
campaign.setName("Batch Campaign " + r.nextInt());
campaign.setStatus(CampaignStatus. PAUSED);
campaign.setAdvertisingChannelType(AdvertisingChannelType. SEARCH);
Budget budget = new Budget();
campaign.setBudget(budget);
BiddingStrategyConfiguration biddingStrategyConfiguration =
new BiddingStrategyConfiguration();
// Fill the biddingStrategyConfiguration
campaign.setBiddingStrategyConfiguration(
biddingStrategyConfiguration );
CampaignOperation operation = new CampaignOperation();
operation.setOperand(campaign);
operation.setOperator(Operator. ADD);
operations.add(operation); // Add to the list of operations
Uploading the Operations
● First, construct operations like usual
Uploading the Operations (Cont.)
● The next step is to send operations to the
uploadUrl
● uploadUrl is valid for one week
Request method POST
URL Upload URL returned by BatchJobService.mutate
Content-Type HTTP header application/xml
Request body A mutate element in XML form, as specified in
BatchJobOps.xsd
Uploading the Operations (Cont.)
● All libraries have utilities to help building
the request!
● BatchJobHelper for Java client library:
// Use a BatchJobHelper to upload all operations.
BatchJobHelper batchJobHelper = new BatchJobHelper( session);
batchJobHelper .uploadBatchJobOperations( operations, uploadUrl);
System.out.printf(
"Uploaded %d operations for batch job with ID %d.%n" ,
operations.size(), batchJob.getId());
Polling the Job Status
● After uploading operations, the BatchJob
status will move to ACTIVE.
AWAITING_FILE
ACTIVE
CANCELED
DONE
Polling the Job Status (Cont.)
● Check the job status
int pollAttempts = 0;
boolean isPending = true;
Selector selector =
new SelectorBuilder()
.fields(
BatchJobField.Id, BatchJobField.Status,
BatchJobField.DownloadUrl, BatchJobField.ProcessingErrors,
BatchJobField.ProgressStats)
.equalsId(batchJob.getId())
.build();
do {
long sleepSeconds = (long) Math.scalb(30, pollAttempts);
System.out.printf("Sleeping %d seconds...%n", sleepSeconds);
Thread.sleep(sleepSeconds * 1000);
batchJob = batchJobService.get(selector).getEntries(0);
System.out.printf(
"Batch job ID %d has status '%s'.%n",
batchJob.getId(), batchJob.getStatus());
pollAttempts++;
isPending = PENDING_STATUSES.contains(batchJob.getStatus());
} while (isPending && pollAttempts < MAX_POLL_ATTEMPTS);
Polling the Job Status (Cont.)
● Poll for completion of the batch job with
an exponential back off
● Check the job's status until it is CANCELED
or DONE
● Log progressStats for large sets of
operations
Downloading Results
● At this stage the job status can be DONE
or CANCELED
● Let's check out the details...
Downloading Results - DONE
● Status: DONE
● Description: BatchJobService
successfully parsed and attempted each of
the uploaded operations
● Actions to take: Download the results for
each operation from the batch job's
downloadUrl
Downloading Results - CANCELED
● Status: CANCELED
● Description: An unexpected error
occurred, or BatchJobService could not
parse the uploaded operations
● Actions to take:
○ Inspect the list of processingErrors
○ Download the results for any successfully parsed
operations from the batch job's downloadUrl
RARE
Downloading Results - CANCELED
● Some operations may still have been
attempted
● Always check the downloadUrl for the
results
● Details about the mutateResult object:
○ https://goo.gl/pXAhBS
Downloading Results (Cont.)
● downloadUrl returns mutateResults
● There is another utility to help!
if (batchJob.getDownloadUrl() != null &&
batchJob.getDownloadUrl().getUrl() != null) {
BatchJobMutateResponse mutateResponse =
batchJobUploadHelper.downloadBatchJobMutateResponse(
batchJob.getDownloadUrl().getUrl());
System.out.printf("Downloaded results from %s:%n" ,
batchJob.getDownloadUrl().getUrl());
for (MutateResult mutateResult :
mutateResponse .getMutateResults()) {
String outcome = mutateResult.getErrorList() == null ?
"SUCCESS" : "FAILURE";
System.out.printf(" Operation [%d] - %sn" ,
mutateResult.getIndex(), outcome);
}
}
Downloading Results (Cont.)
● A mutateResult will have either a
result or an errorList, but not both
○ result - The result of the corresponding
successful operation, e.g., a Campaign object
○ errorList - The error list for the corresponding
failed operation
○ index - The zero-based index of the
corresponding operation MutateResult
● result Operand
● errorList ErrorList
● index long
Errors
BatchJob.processingErrors (per job)
● Errors encountered while parsing uploaded
operations - FILE_FORMAT_ERROR
● Unexpected errors such as issues writing
results
MutateResult.errorList (per operation)
● Retrieved from BatchJob.downloadUrl
● Errors encountered while attempting to
execute a single successfully parsed operation.
Temporary IDs
Temporary IDs
● Did you ever want to create a complete
campaign in a single batch job?
● New feature introduced with
BatchJobService
○ A negative number of type long
○ Just create an ID and reuse it in
operations for dependent objects
Common Use Case
Create a Campaign in a single BatchJob:
Campaign
● id = -1
AdGroup
● id = -2
● campaignId = -1
CampaignLabel
● campaignId = -1
NegativeCampaignCriterion
● campaignId = -1
AdGroupAd
● adGroupId = -2
BiddableAdGroupCriterion
● adGroupId = -2
● criterion
○ text = "shoes"
BiddableAdGroupCriterion
● adGroupId = -2
● criterion
○ text = "jackets"
...
Important Notes
● The order of operations is very important!
● Keep this in mind when using temp IDs
● Create the parent object before
creating its child objects
Incremental
Uploads
Introduction
● Allows multiple operation upload requests
to the same BatchJob
● Job will start after last set of operations is
sent out
● Follows the Google Cloud storage
guidelines
Incremental Upload Use Cases
● You build your BatchJob operations in
phases or separate processes, so sending
all operations at once isn't feasible
● You have a large set of operations and you
don't want to send them all in one
enormous upload request
○ E.g.: you may not want to send 500 MB of
operations in a single POST request
Range of bytes in the request, followed by
total bytes. Total bytes will be * for the
first and intermediate requests.
The number of bytes in the contents of the
current request.
application/xmlContent-Type
HTTP Header
Request Attributes
Request method PUT
URL
Content-Length
HTTP Header
Content-Range
HTTP Range
Request body
Upload URL returned by
BatchJobService.mutate
Operations in XML form, as specified in
BatchJobOps.xsd.
More on the Request Body...
● BatchJobService will concatenate all the
requests
● You just need to send the first and last
markers:
Request Start mutate element End mutate element
First
Intermediate
Last
More on the Request Body (Cont.)
● All requests will be parsed as a single
document
● The concatenation of all requests has to
be a complete XML document
● The size of each request body must be a
multiple of 256K (262144) bytes
○ This rule does not apply to the last request
Request 1
Content-Range: 0-262143/*
<?xml version="1.0" encoding="UTF-8"?>
<ns1:mutate xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201509">
<operations xsi:type="ns1:CampaignOperation">
<operator xsi:type="ns1:Operator">ADD</operator>
<operand xsi:type="ns1:Campaign">
…
</operations>
<operations>
…
</operat
Content length of 262144, where the "t" in the
last line is the 262144th byte.
Request 3
Content-Range: 524288-524304/524305
rations></mutate>
● Content length without padding of 17 bytes,
where the closing > on </mutate> is the
17th byte
● Total content length across all requests for
the job is 262144+262144+17 = 524305
bytes
Request 2
Content-Range: 262144-524287/*
ions>
<operations xsi:type="ns1:AdGroupOperation">
<operator xsi:type="ns1:Operator">ADD</operator>
<operand xsi:type="ns1:AdGroup">
...
</operations>
<operations>
...
</ope
Content length of 262144, where the "e" in the
last line is the 262144th byte.
Use the Client Libraries!
● The client libraries have utilities to do all
the parsing
● No need to worry about size details
● Check out the online examples
○ https://goo.gl/wgywm1
Best Practices
General Guidelines
Improve Throughput
● Fewer larger jobs over many smaller jobs
● Exponential back off when
polling
● Don't poll job status too frequently
○ Might hit a rate limit
Dealing with Same Client ID
● Avoid different jobs working on the same
objects
○ Might result in deadlocks, followed by execution
failures
● Wait for the job to be DONE or CANCELED
One Last Tip...
● Avoid multiple mutates of the same object
in the same job
Limitations
Regarding Operations Size
● 1 Gb of unfinished operations per account
at any given time
○ Will throw DISK_QUOTA_EXCEEDED error
○ Operations from incremental uploads where the
last upload has not occurred do not count
towards this limit
● Just wait for some jobs to complete and
try again
Regarding Shopping Campaigns
● BJS similar to partialFailure = true
● Partial failure not supported for Shopping
campaign ad group criteria...
● ...so BJS does not support
AdGroupCriterionOperations on ad
groups of shopping campaigns
○ Will result in a
CAMPAIGN_TYPE_NOT_COMPATIBLE_WITH_PARTI
AL_FAILURE error
Cancelling the Job
BatchJob status is read-only:
● You can't cancel a job before the
operations upload is finished
● You can't cancel a job while it's executing
Resources
● BatchJobService API reference
○ https://goo.gl/J35rCm
● Client libraries
○ https://goo.gl/Ck7qK4
● BatchJobOps.xsd
○ https://goo.gl/pXAhBS
● Partial failure feature
○ https://goo.gl/TYXYjw
● Java code example
○ https://goo.gl/NeZb7l

More Related Content

Viewers also liked

C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...
C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...
C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...DataStax Academy
 
Promise Object in Windows Store App
Promise Object in Windows Store AppPromise Object in Windows Store App
Promise Object in Windows Store AppMindfire Solutions
 
Clases jasper report
Clases jasper reportClases jasper report
Clases jasper reportjbersosa
 
Jaspersoft Reporting v5
Jaspersoft Reporting v5Jaspersoft Reporting v5
Jaspersoft Reporting v5Ahmed Muzammil
 
Jasper Report - Lesson
Jasper Report - LessonJasper Report - Lesson
Jasper Report - LessonAlex Fernandez
 
Jaspersoft Studio Quick Start Guide
Jaspersoft Studio Quick Start GuideJaspersoft Studio Quick Start Guide
Jaspersoft Studio Quick Start GuideJeff Rix
 
Jasper reports in 3 easy steps
Jasper reports in 3 easy stepsJasper reports in 3 easy steps
Jasper reports in 3 easy stepsIvaylo Zashev
 
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces..."Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...hamidsamadi
 
Mobile Web Development from Scratch
Mobile Web Development from ScratchMobile Web Development from Scratch
Mobile Web Development from ScratchNokiaAppForum
 
Jasper Reports
Jasper ReportsJasper Reports
Jasper ReportsEnkitec
 
Jaspersoft Studioチュートリアル1 - レポートの作成
Jaspersoft Studioチュートリアル1 - レポートの作成Jaspersoft Studioチュートリアル1 - レポートの作成
Jaspersoft Studioチュートリアル1 - レポートの作成htshozawa
 
Introduction to java Jasper Report with Server & iReport
Introduction to java Jasper Report with Server & iReportIntroduction to java Jasper Report with Server & iReport
Introduction to java Jasper Report with Server & iReportArif Hosain
 
Embedding Jaspersoft into your PHP application
Embedding Jaspersoft into your PHP applicationEmbedding Jaspersoft into your PHP application
Embedding Jaspersoft into your PHP applicationMariano Luna
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012Mark Ginnebaugh
 
A Short Intorduction to JasperReports
A Short Intorduction to JasperReportsA Short Intorduction to JasperReports
A Short Intorduction to JasperReportsGuo Albert
 
Introduction to Jasper Reports
Introduction to Jasper ReportsIntroduction to Jasper Reports
Introduction to Jasper ReportsMindfire Solutions
 
How AdWords UI maps into adwords api
How AdWords UI maps into adwords apiHow AdWords UI maps into adwords api
How AdWords UI maps into adwords apisupergigas
 

Viewers also liked (19)

C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...
C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...
C* Summit EU 2013: Leveraging the Power of Cassandra: Operational Reporting a...
 
Promise Object in Windows Store App
Promise Object in Windows Store AppPromise Object in Windows Store App
Promise Object in Windows Store App
 
Clases jasper report
Clases jasper reportClases jasper report
Clases jasper report
 
Jaspersoft Reporting v5
Jaspersoft Reporting v5Jaspersoft Reporting v5
Jaspersoft Reporting v5
 
Jasper Report - Lesson
Jasper Report - LessonJasper Report - Lesson
Jasper Report - Lesson
 
Jaspersoft Studio Quick Start Guide
Jaspersoft Studio Quick Start GuideJaspersoft Studio Quick Start Guide
Jaspersoft Studio Quick Start Guide
 
Jasper reports in 3 easy steps
Jasper reports in 3 easy stepsJasper reports in 3 easy steps
Jasper reports in 3 easy steps
 
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces..."Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
"Analytics inside your Java application", Part 2, jDays 2015 Speaker: "Veaces...
 
Mobile Web Development from Scratch
Mobile Web Development from ScratchMobile Web Development from Scratch
Mobile Web Development from Scratch
 
Jasper Reports
Jasper ReportsJasper Reports
Jasper Reports
 
Jaspersoft Studioチュートリアル1 - レポートの作成
Jaspersoft Studioチュートリアル1 - レポートの作成Jaspersoft Studioチュートリアル1 - レポートの作成
Jaspersoft Studioチュートリアル1 - レポートの作成
 
Introduction to java Jasper Report with Server & iReport
Introduction to java Jasper Report with Server & iReportIntroduction to java Jasper Report with Server & iReport
Introduction to java Jasper Report with Server & iReport
 
Advanced Jasper Reports
Advanced Jasper ReportsAdvanced Jasper Reports
Advanced Jasper Reports
 
Embedding Jaspersoft into your PHP application
Embedding Jaspersoft into your PHP applicationEmbedding Jaspersoft into your PHP application
Embedding Jaspersoft into your PHP application
 
Microsoft Data Mining 2012
Microsoft Data Mining 2012Microsoft Data Mining 2012
Microsoft Data Mining 2012
 
A Short Intorduction to JasperReports
A Short Intorduction to JasperReportsA Short Intorduction to JasperReports
A Short Intorduction to JasperReports
 
Introduction to Jasper Reports
Introduction to Jasper ReportsIntroduction to Jasper Reports
Introduction to Jasper Reports
 
How AdWords UI maps into adwords api
How AdWords UI maps into adwords apiHow AdWords UI maps into adwords api
How AdWords UI maps into adwords api
 
Japer Reports
Japer ReportsJaper Reports
Japer Reports
 

Similar to BatchJobService

Troubleshooting Dashboard Performance
Troubleshooting Dashboard PerformanceTroubleshooting Dashboard Performance
Troubleshooting Dashboard PerformanceOutSystems
 
Test Automation: How to Succeed When Moving Beyond Manual Testing
Test Automation: How to Succeed When Moving Beyond Manual TestingTest Automation: How to Succeed When Moving Beyond Manual Testing
Test Automation: How to Succeed When Moving Beyond Manual TestingSmartBear
 
Page life cycle IN ASP.NET
Page life cycle IN ASP.NETPage life cycle IN ASP.NET
Page life cycle IN ASP.NETSireesh K
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts updatesupergigas
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5Alkacon Software GmbH & Co. KG
 
Automated Performance Testing
Automated Performance TestingAutomated Performance Testing
Automated Performance TestingLars Thorup
 
Sprint 48 review
Sprint 48 reviewSprint 48 review
Sprint 48 reviewManageIQ
 
Sprint 43 Review
Sprint 43 ReviewSprint 43 Review
Sprint 43 ReviewManageIQ
 
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...Puppet
 
2.1 Automation Nation: Keeping your Process Builders in Check
2.1 Automation Nation: Keeping your Process Builders in Check2.1 Automation Nation: Keeping your Process Builders in Check
2.1 Automation Nation: Keeping your Process Builders in CheckTargetX
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scriptingmarcwan
 
Meteor @ Sharethis
Meteor @ SharethisMeteor @ Sharethis
Meteor @ SharethisIshika Paul
 
AwReporting Update
AwReporting UpdateAwReporting Update
AwReporting Updatemarcwan
 
Angular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptxAngular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptxaccordv12
 
Introduction to Serverless and Google Cloud Functions
Introduction to Serverless and Google Cloud FunctionsIntroduction to Serverless and Google Cloud Functions
Introduction to Serverless and Google Cloud FunctionsMalepati Bala Siva Sai Akhil
 

Similar to BatchJobService (20)

fram^ TechTalk #1 - CQRS and Event Sourcing (ES)
fram^ TechTalk #1 - CQRS and Event Sourcing (ES)fram^ TechTalk #1 - CQRS and Event Sourcing (ES)
fram^ TechTalk #1 - CQRS and Event Sourcing (ES)
 
Troubleshooting Dashboard Performance
Troubleshooting Dashboard PerformanceTroubleshooting Dashboard Performance
Troubleshooting Dashboard Performance
 
Test Automation: How to Succeed When Moving Beyond Manual Testing
Test Automation: How to Succeed When Moving Beyond Manual TestingTest Automation: How to Succeed When Moving Beyond Manual Testing
Test Automation: How to Succeed When Moving Beyond Manual Testing
 
Page life cycle IN ASP.NET
Page life cycle IN ASP.NETPage life cycle IN ASP.NET
Page life cycle IN ASP.NET
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts update
 
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5OpenCms Days 2014 - User Generated Content in OpenCms 9.5
OpenCms Days 2014 - User Generated Content in OpenCms 9.5
 
Automated Performance Testing
Automated Performance TestingAutomated Performance Testing
Automated Performance Testing
 
Sprint 48 review
Sprint 48 reviewSprint 48 review
Sprint 48 review
 
Sprint 43 Review
Sprint 43 ReviewSprint 43 Review
Sprint 43 Review
 
Sprint 59
Sprint 59Sprint 59
Sprint 59
 
SAP workflow events
SAP workflow eventsSAP workflow events
SAP workflow events
 
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...
PuppetConf 2017: Puppet & Google Cloud: From Nothing to Production in 10 minu...
 
2.1 Automation Nation: Keeping your Process Builders in Check
2.1 Automation Nation: Keeping your Process Builders in Check2.1 Automation Nation: Keeping your Process Builders in Check
2.1 Automation Nation: Keeping your Process Builders in Check
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scripting
 
Meteor @ Sharethis
Meteor @ SharethisMeteor @ Sharethis
Meteor @ Sharethis
 
Dancing with websocket
Dancing with websocketDancing with websocket
Dancing with websocket
 
AwReporting Update
AwReporting UpdateAwReporting Update
AwReporting Update
 
Sprint 52
Sprint 52Sprint 52
Sprint 52
 
Angular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptxAngular 2 Unit Testing.pptx
Angular 2 Unit Testing.pptx
 
Introduction to Serverless and Google Cloud Functions
Introduction to Serverless and Google Cloud FunctionsIntroduction to Serverless and Google Cloud Functions
Introduction to Serverless and Google Cloud Functions
 

More from supergigas

How to build a platform
How to build a platformHow to build a platform
How to build a platformsupergigas
 
The AdWords api and mobile
The AdWords api and mobileThe AdWords api and mobile
The AdWords api and mobilesupergigas
 
Shopping Campaigns
Shopping CampaignsShopping Campaigns
Shopping Campaignssupergigas
 
Rate limits and Performance
Rate limits and PerformanceRate limits and Performance
Rate limits and Performancesupergigas
 
Extension Setting Services
Extension Setting ServicesExtension Setting Services
Extension Setting Servicessupergigas
 
Effective Reporting
Effective ReportingEffective Reporting
Effective Reportingsupergigas
 
Display Network criteria bidding
Display Network criteria biddingDisplay Network criteria bidding
Display Network criteria biddingsupergigas
 
Dev Token tips
Dev Token tipsDev Token tips
Dev Token tipssupergigas
 
Ad Customizers
Ad CustomizersAd Customizers
Ad Customizerssupergigas
 

More from supergigas (10)

How to build a platform
How to build a platformHow to build a platform
How to build a platform
 
Upgraded URLs
Upgraded URLsUpgraded URLs
Upgraded URLs
 
The AdWords api and mobile
The AdWords api and mobileThe AdWords api and mobile
The AdWords api and mobile
 
Shopping Campaigns
Shopping CampaignsShopping Campaigns
Shopping Campaigns
 
Rate limits and Performance
Rate limits and PerformanceRate limits and Performance
Rate limits and Performance
 
Extension Setting Services
Extension Setting ServicesExtension Setting Services
Extension Setting Services
 
Effective Reporting
Effective ReportingEffective Reporting
Effective Reporting
 
Display Network criteria bidding
Display Network criteria biddingDisplay Network criteria bidding
Display Network criteria bidding
 
Dev Token tips
Dev Token tipsDev Token tips
Dev Token tips
 
Ad Customizers
Ad CustomizersAd Customizers
Ad Customizers
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 

BatchJobService

  • 2. Agenda ● Sync vs. Async ● Batch job flow ● Temporary IDs ● Incremental Uploads ● Best practices ● Limitations
  • 4. Synchronous Requests API Services Backend Request Response RPC RPC return Sends operation OK: receives status of the operation
  • 5. Asynchronous Requests API Async Services Backend Request Response RPC RPC return Operations Operations Op. return Request Sends all Operations OK: operations will be processed Check operations status Server sends the results Operations enter an execution queue, and release the request. Response Op. return
  • 6. Async Processing Isn't Free Asynchronous processes usually incur additional overhead, such as: ● Scheduling ● Management/load-balancing of the job queue ● Retry of failed operations
  • 7. Synchronous vs. Asynchronous Use Case Sync Async Highly responsive user interface Nightly bulk operations job Fire-and-forget Maximum throughput
  • 9. Batch Processing - Why Use It? ● Automatic retry of operations that encounter transient errors such as: ○ CONCURRENT_MODIFICATION ○ UNEXPECTED_INTERNAL_API_ERROR ● Automatic retry of operations that encounter rate limits ● Your application won't be blocked waiting for a response.
  • 10. Limitations of MutateJobService ● Error handling is difficult ○ Difficult to find the operation that failed ● Can't create dependent entities in a single job ● MutateJobService has a much lower limit on the number of operations (in the thousands)
  • 11. Introducing BatchJobService ● Allows setting temporary IDs on new entities for dependent entity creation ● Each result contains an operation index for correlating the result to its operation ● Much higher operations limit of 1 GB of unprocessed operations ● Utilities are available in all client libraries
  • 12. Farewell, MutateJobService ● BatchJobService is a replacement for MutateJobService ● MutateJobService is going away
  • 14. Basic Steps Download the results of the job Upload the list of operations Poll the batch job's status periodically Operations Results 2 3 4 Job status downloadUrl Create a BatchJob BatchJobService Job 1 uploadUrl
  • 15. Creating the Batch Job ● Create the BatchJob object BatchJobOperation addOp = new BatchJobOperation(); addOp.setOperator(Operator. ADD); addOp.setOperand(new BatchJob()); BatchJob batchJob = batchJobService .mutate( new BatchJobOperation[]{ addOp} ).getValue (0); ● Make sure to grab the uploadUrl // Get the upload URL from the new job. String uploadUrl = batchJob.getUploadUrl().getUrl();
  • 16. Creating the Batch Job (Cont.) ● Job status will be AWAITING_FILE System.out.printf( "Created BatchJob with ID %d, status '%s' and upload URL %s.%n" , batchJob.getId(), batchJob.getStatus(), uploadUrl); $ Created BatchJob with ID <ID>, status 'AWAITING_FILE' and upload URL <URL>. ● Creating the BatchJob is a synchronous operation!
  • 17. Campaign campaign = new Campaign(); campaign.setName("Batch Campaign " + r.nextInt()); campaign.setStatus(CampaignStatus. PAUSED); campaign.setAdvertisingChannelType(AdvertisingChannelType. SEARCH); Budget budget = new Budget(); campaign.setBudget(budget); BiddingStrategyConfiguration biddingStrategyConfiguration = new BiddingStrategyConfiguration(); // Fill the biddingStrategyConfiguration campaign.setBiddingStrategyConfiguration( biddingStrategyConfiguration ); CampaignOperation operation = new CampaignOperation(); operation.setOperand(campaign); operation.setOperator(Operator. ADD); operations.add(operation); // Add to the list of operations Uploading the Operations ● First, construct operations like usual
  • 18. Uploading the Operations (Cont.) ● The next step is to send operations to the uploadUrl ● uploadUrl is valid for one week Request method POST URL Upload URL returned by BatchJobService.mutate Content-Type HTTP header application/xml Request body A mutate element in XML form, as specified in BatchJobOps.xsd
  • 19. Uploading the Operations (Cont.) ● All libraries have utilities to help building the request! ● BatchJobHelper for Java client library: // Use a BatchJobHelper to upload all operations. BatchJobHelper batchJobHelper = new BatchJobHelper( session); batchJobHelper .uploadBatchJobOperations( operations, uploadUrl); System.out.printf( "Uploaded %d operations for batch job with ID %d.%n" , operations.size(), batchJob.getId());
  • 20. Polling the Job Status ● After uploading operations, the BatchJob status will move to ACTIVE. AWAITING_FILE ACTIVE CANCELED DONE
  • 21. Polling the Job Status (Cont.) ● Check the job status int pollAttempts = 0; boolean isPending = true; Selector selector = new SelectorBuilder() .fields( BatchJobField.Id, BatchJobField.Status, BatchJobField.DownloadUrl, BatchJobField.ProcessingErrors, BatchJobField.ProgressStats) .equalsId(batchJob.getId()) .build(); do { long sleepSeconds = (long) Math.scalb(30, pollAttempts); System.out.printf("Sleeping %d seconds...%n", sleepSeconds); Thread.sleep(sleepSeconds * 1000); batchJob = batchJobService.get(selector).getEntries(0); System.out.printf( "Batch job ID %d has status '%s'.%n", batchJob.getId(), batchJob.getStatus()); pollAttempts++; isPending = PENDING_STATUSES.contains(batchJob.getStatus()); } while (isPending && pollAttempts < MAX_POLL_ATTEMPTS);
  • 22. Polling the Job Status (Cont.) ● Poll for completion of the batch job with an exponential back off ● Check the job's status until it is CANCELED or DONE ● Log progressStats for large sets of operations
  • 23. Downloading Results ● At this stage the job status can be DONE or CANCELED ● Let's check out the details...
  • 24. Downloading Results - DONE ● Status: DONE ● Description: BatchJobService successfully parsed and attempted each of the uploaded operations ● Actions to take: Download the results for each operation from the batch job's downloadUrl
  • 25. Downloading Results - CANCELED ● Status: CANCELED ● Description: An unexpected error occurred, or BatchJobService could not parse the uploaded operations ● Actions to take: ○ Inspect the list of processingErrors ○ Download the results for any successfully parsed operations from the batch job's downloadUrl RARE
  • 26. Downloading Results - CANCELED ● Some operations may still have been attempted ● Always check the downloadUrl for the results ● Details about the mutateResult object: ○ https://goo.gl/pXAhBS
  • 27. Downloading Results (Cont.) ● downloadUrl returns mutateResults ● There is another utility to help! if (batchJob.getDownloadUrl() != null && batchJob.getDownloadUrl().getUrl() != null) { BatchJobMutateResponse mutateResponse = batchJobUploadHelper.downloadBatchJobMutateResponse( batchJob.getDownloadUrl().getUrl()); System.out.printf("Downloaded results from %s:%n" , batchJob.getDownloadUrl().getUrl()); for (MutateResult mutateResult : mutateResponse .getMutateResults()) { String outcome = mutateResult.getErrorList() == null ? "SUCCESS" : "FAILURE"; System.out.printf(" Operation [%d] - %sn" , mutateResult.getIndex(), outcome); } }
  • 28. Downloading Results (Cont.) ● A mutateResult will have either a result or an errorList, but not both ○ result - The result of the corresponding successful operation, e.g., a Campaign object ○ errorList - The error list for the corresponding failed operation ○ index - The zero-based index of the corresponding operation MutateResult ● result Operand ● errorList ErrorList ● index long
  • 29. Errors BatchJob.processingErrors (per job) ● Errors encountered while parsing uploaded operations - FILE_FORMAT_ERROR ● Unexpected errors such as issues writing results MutateResult.errorList (per operation) ● Retrieved from BatchJob.downloadUrl ● Errors encountered while attempting to execute a single successfully parsed operation.
  • 31. Temporary IDs ● Did you ever want to create a complete campaign in a single batch job? ● New feature introduced with BatchJobService ○ A negative number of type long ○ Just create an ID and reuse it in operations for dependent objects
  • 32. Common Use Case Create a Campaign in a single BatchJob: Campaign ● id = -1 AdGroup ● id = -2 ● campaignId = -1 CampaignLabel ● campaignId = -1 NegativeCampaignCriterion ● campaignId = -1 AdGroupAd ● adGroupId = -2 BiddableAdGroupCriterion ● adGroupId = -2 ● criterion ○ text = "shoes" BiddableAdGroupCriterion ● adGroupId = -2 ● criterion ○ text = "jackets" ...
  • 33. Important Notes ● The order of operations is very important! ● Keep this in mind when using temp IDs ● Create the parent object before creating its child objects
  • 35. Introduction ● Allows multiple operation upload requests to the same BatchJob ● Job will start after last set of operations is sent out ● Follows the Google Cloud storage guidelines
  • 36. Incremental Upload Use Cases ● You build your BatchJob operations in phases or separate processes, so sending all operations at once isn't feasible ● You have a large set of operations and you don't want to send them all in one enormous upload request ○ E.g.: you may not want to send 500 MB of operations in a single POST request
  • 37. Range of bytes in the request, followed by total bytes. Total bytes will be * for the first and intermediate requests. The number of bytes in the contents of the current request. application/xmlContent-Type HTTP Header Request Attributes Request method PUT URL Content-Length HTTP Header Content-Range HTTP Range Request body Upload URL returned by BatchJobService.mutate Operations in XML form, as specified in BatchJobOps.xsd.
  • 38. More on the Request Body... ● BatchJobService will concatenate all the requests ● You just need to send the first and last markers: Request Start mutate element End mutate element First Intermediate Last
  • 39. More on the Request Body (Cont.) ● All requests will be parsed as a single document ● The concatenation of all requests has to be a complete XML document ● The size of each request body must be a multiple of 256K (262144) bytes ○ This rule does not apply to the last request
  • 40. Request 1 Content-Range: 0-262143/* <?xml version="1.0" encoding="UTF-8"?> <ns1:mutate xmlns:ns1="https://adwords.google.com/api/adwords/cm/v201509"> <operations xsi:type="ns1:CampaignOperation"> <operator xsi:type="ns1:Operator">ADD</operator> <operand xsi:type="ns1:Campaign"> … </operations> <operations> … </operat Content length of 262144, where the "t" in the last line is the 262144th byte.
  • 41. Request 3 Content-Range: 524288-524304/524305 rations></mutate> ● Content length without padding of 17 bytes, where the closing > on </mutate> is the 17th byte ● Total content length across all requests for the job is 262144+262144+17 = 524305 bytes
  • 42. Request 2 Content-Range: 262144-524287/* ions> <operations xsi:type="ns1:AdGroupOperation"> <operator xsi:type="ns1:Operator">ADD</operator> <operand xsi:type="ns1:AdGroup"> ... </operations> <operations> ... </ope Content length of 262144, where the "e" in the last line is the 262144th byte.
  • 43. Use the Client Libraries! ● The client libraries have utilities to do all the parsing ● No need to worry about size details ● Check out the online examples ○ https://goo.gl/wgywm1
  • 45. Improve Throughput ● Fewer larger jobs over many smaller jobs ● Exponential back off when polling ● Don't poll job status too frequently ○ Might hit a rate limit
  • 46. Dealing with Same Client ID ● Avoid different jobs working on the same objects ○ Might result in deadlocks, followed by execution failures ● Wait for the job to be DONE or CANCELED
  • 47. One Last Tip... ● Avoid multiple mutates of the same object in the same job
  • 49. Regarding Operations Size ● 1 Gb of unfinished operations per account at any given time ○ Will throw DISK_QUOTA_EXCEEDED error ○ Operations from incremental uploads where the last upload has not occurred do not count towards this limit ● Just wait for some jobs to complete and try again
  • 50. Regarding Shopping Campaigns ● BJS similar to partialFailure = true ● Partial failure not supported for Shopping campaign ad group criteria... ● ...so BJS does not support AdGroupCriterionOperations on ad groups of shopping campaigns ○ Will result in a CAMPAIGN_TYPE_NOT_COMPATIBLE_WITH_PARTI AL_FAILURE error
  • 51. Cancelling the Job BatchJob status is read-only: ● You can't cancel a job before the operations upload is finished ● You can't cancel a job while it's executing
  • 52. Resources ● BatchJobService API reference ○ https://goo.gl/J35rCm ● Client libraries ○ https://goo.gl/Ck7qK4 ● BatchJobOps.xsd ○ https://goo.gl/pXAhBS ● Partial failure feature ○ https://goo.gl/TYXYjw ● Java code example ○ https://goo.gl/NeZb7l