SlideShare a Scribd company logo
AdWords API Workshops – All rights reserved
API SERVER

Rate Limits
and API Best Practices

<SPEAKER>, Google, Inc.

AdWords API Workshops – All rights reserved
Agenda
● API Best Practices
● What are Rate Limits?
● How to handle Rate Limits

AdWords API Workshops – All rights reserved
Best Practices
Some simple things to speed up your applications

AdWords API Workshops – All rights reserved
Batch Operations Together

AdWords API Workshops – All rights reserved

● Requests to the API have certain costs
● Network transfer, serialisation, auth, etc.

● Batching operations into a single request reduces these
● mutate methods accept arrays of operations
● MutateJobService for batching

AdWords API Workshops – All rights reserved
Group Operations by Target
● Multiple operations on the same AdGroup / Campaign
are faster
● Subsequent edits to same AdGroup or Campaign can
cause CONCURRENT_MODIFICATION errors
● Backend systems can take time to do their work
● Try to do all edits on AdGroups/Campaigns at once

AdWords API Workshops – All rights reserved
Only Update What you Need to
● Updating an object?
● Only send the values that will change!
● Sending in all the other values wastes
time
●

The system still validates them, stores to DB, etc.

AdWords API Workshops – All rights reserved
A Couple of Other Ideas …
● Compress your requests / response
with gzip
● Make sure User-Agent: has “gzip”
● Accept-Encoding: lists gzip

● Use partial failure feature
● Tells API to serialise those ops that
succeeded
● Returns list of those that failed
AdWords API Workshops – All rights reserved
Defining Rate Limits

AdWords API Workshops – All rights reserved
Rate Limits
● Are not fixed
● Vary on server load
● Vary per feature area
● Will change over time
● Different per AdWords service

AdWords API Workshops – All rights reserved

Defining Rate Limits
Rate Limit Errors
● RATE_EXCEEDED
○ at least wait retryAfterSeconds seconds

● CONCURRENT_MODIFICATIONS
○ Exponential backoff, few retries only

● UNEXPECTED_INTERNAL_API_ERROR
○ Exponential back off, few retries only
○ Report the issue to your CSR or forum
AdWords API Workshops – All rights reserved

Defining Rate Limits
How to Handle Rate Limits
Careful coding...

AdWords API Workshops – All rights reserved
Basic Example
Java

ApiError[] errorArray = apiException.getErrors();
for (ApiError apiError : errorArray) {
if (apiError instanceof RateExceededError) {
int seconds = ((RateExceededError) apiError)
.getRetryAfterSeconds();
// wait the amount of seconds the server asked
Thread.sleep(seconds * 1000);
}
}
AdWords API Workshops – All rights reserved

How to handle Rate Limits
Basic Example - Explained
● Any request can generate a RateExceededError
● Handling these errors is very important
● Wait and retry is the best strategy in
this case
● Even more important when
doing multiple requests

AdWords API Workshops – All rights reserved
Important Points About the Basic Solution
● Synchronous solution to the problem
● Blocks the thread until it succeeds, or fails completely
● No control over request rate speed
● Very difficult to group operations

AdWords API Workshops – All rights reserved
A More Advanced Solution
● Message Queues
● The perfect solution to distribute load and do
throttling
● Very good out of the box solutions available
●

ActiveMQ, RabbitMQ, … etc.

● A lot of tools / client libraries to handle
comms layer

AdWords API Workshops – All rights reserved
Message Queues (cont’d)
● More control over the rates and limits
● Better break down into specialized modules
● Let’s take a look to three possible approaches to the
problem...

AdWords API Workshops – All rights reserved
1. Single Queue
Producer

Producers will create tasks to be
executed using the API, and add
them to the queue

Producer

Consumers
Consumers
Consumers

X

Queue

Throttling

Producer

Logging

Error

Consumers will retrieve the messages/tasks
from the queue with a controlled rate limit
AdWords API Workshops – All rights reserved

How to handle Rate Limits
First Approach - Pros & Cons
● Pros:
● Very easy to implement
● Only one control point to change rate speed
● Easy to handle errors

● Cons:
●
●
●
●

Only one control point to change rate speed
Hard to group operations
Tasks can take too long to be executed
Not all MQs deal with message priority

AdWords API Workshops – All rights reserved
2. Single Queue with Selectors
Producers
Producers

Producers will create specific tasks
to be executed, and add them to
the queue with a specific header

Producers
Producers

Each specific consumer can group
the operations, and execute within
your own rate limit using selectors
X
X
X
X

Producers
Producers

Queue

Throttling

Producers
Producers

Producers
Consumer

AdWords API Workshops – All rights reserved

Producers
Consumer
Producers
Consumer
Producers
Consumer

Error

How to handle Rate Limits
Second Approach - Pros & Cons
● Pros:
● Group operations by type
● Some control over throttling depending on type
● More efficient - better parallel access to the API

● Cons:
●
●
●
●

Only one queue - difficult to administer
No main control on how fast the API is called
Managing all the pieces can be difficult
Operation logging might be complicated

AdWords API Workshops – All rights reserved
3. Multiple Queues
Executors do the request

Producers
Consumer

Producers
Producers

Producers
Consumer

Throttling

Producers
Producers

Producers
Producers
Producers
Producers

Producers
Consumer
Producers
Executors
Executors
Executors

Producers
Consumer
Queues

Consumers just group the tasks
Error

Logging

X
X
X
X

Producers just spawn
a lot of tasks

Throttling

AdWords API Workshops – All rights reserved

How to handle Rate Limits
Third Approach - Pros & Cons
● Pros:
●
●
●
●
●
●

Total control over rate limits
Very robust - very easy to add new parts
Complete picture on what is happening with the queues
Easy to scale based on demand
If done properly, easy to do maintenance!
Super efficient - Parallel grouping; Parallel access to the API

● Cons:
● Hard to implement properly - experience required

AdWords API Workshops – All rights reserved
Message Queues - Takeaways
● Complexity of your platform dictates the best solution
● You can combine parts of other solutions!
● It is a complex subject, but will save you in the long run
● Invest a lot in monitoring. A lot!
● There is no silver bullet...

AdWords API Workshops – All rights reserved
Resources
API Best Practices - https://developers.google.
com/adwords/api/docs/guides/bestpractices
ActiveMQ - http://activemq.apache.org/
RabbitMQ - http://www.rabbitmq.com/
AdWords API Workshops – All rights reserved
Questions?
Thank you!

AdWords API Workshops – All rights reserved
AdWords API Workshops – All rights reserved

More Related Content

PDF
Rate limits and Performance
PPTX
Using AWS Services
KEY
New relic
PPTX
Using Processes and Timers for Long-Running Asynchronous Tasks
PPTX
Measure Customer Experience of Your OutSystems Web and Mobile Applications
PPTX
Sensor Fusion Study - Ch14. The Unscented Kalman Filter [Sooyoung Kim]
PPTX
Episode 2 conditional flows & loops
PPTX
Static analysis by tools
Rate limits and Performance
Using AWS Services
New relic
Using Processes and Timers for Long-Running Asynchronous Tasks
Measure Customer Experience of Your OutSystems Web and Mobile Applications
Sensor Fusion Study - Ch14. The Unscented Kalman Filter [Sooyoung Kim]
Episode 2 conditional flows & loops
Static analysis by tools

What's hot (9)

PPT
Hp bpt
PDF
A/B testing platform on Elixir
PPTX
Episode 19 - Asynchronous Apex - Batch apex & schedulers
PPTX
2º Encontro GUG Rio de Janeiro/2010
PDF
The A, B, Cs of What to Expect
PPTX
Gcp cloud certification training course
PPT
Q-Plan
PDF
Tesla final presentation ent
PPTX
Episode 9 - Building soap integrations in salesforce
Hp bpt
A/B testing platform on Elixir
Episode 19 - Asynchronous Apex - Batch apex & schedulers
2º Encontro GUG Rio de Janeiro/2010
The A, B, Cs of What to Expect
Gcp cloud certification training course
Q-Plan
Tesla final presentation ent
Episode 9 - Building soap integrations in salesforce
Ad

Similar to Rate limits and performance Talk (20)

PDF
AdWords API - How to build a platform
PDF
How_to_create_modular_microservice_test_projects.pdf
PDF
API Update Rundown
PDF
AwReporting Tool
PDF
Client-Side Performance Testing
PDF
Why use ad words api
PDF
Reporting tips & tricks
PPTX
Nginx Conference 2016 - Learnings and State of the Industry
PPTX
QTP Automation Testing Tutorial 1
PDF
A differnt Type of Supermarket Delivery
PDF
Performance testing with JMeter
PPT
Test Automation
PPT
Test Automation for QTP
PPTX
Api gateway : To be or not to be
PPTX
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
PPTX
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
PDF
AdWords Scripts
PDF
Reporting tips & tricks
PDF
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
PPTX
Training Webinar: Detect Performance Bottlenecks of Applications
AdWords API - How to build a platform
How_to_create_modular_microservice_test_projects.pdf
API Update Rundown
AwReporting Tool
Client-Side Performance Testing
Why use ad words api
Reporting tips & tricks
Nginx Conference 2016 - Learnings and State of the Industry
QTP Automation Testing Tutorial 1
A differnt Type of Supermarket Delivery
Performance testing with JMeter
Test Automation
Test Automation for QTP
Api gateway : To be or not to be
WSO2Con 2025 - AI-Driven API Design, Development, and Consumption with Enhanc...
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
AdWords Scripts
Reporting tips & tricks
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
Training Webinar: Detect Performance Bottlenecks of Applications
Ad

More from marcwan (20)

PDF
Mcc scripts deck (日本語)
PDF
Getting started with Google Analytics and the AdWords API
PDF
Bid Estimation with the AdWords API (v2)
PDF
Opportunity Analysis with Kratu (v2)
PDF
Opportunity Analysis with Kratu
PDF
07. feeds update
PDF
AdWords API & OAuth 2.0, Advanced
PDF
AdWords Scripts and MCC Scripting
PDF
AwReporting Update
PDF
Getting Started with AdWords API and Google Analytics
PDF
Shopping Campaigns and AdWords API
PDF
API Updates for v201402
PDF
AdWords API Targeting Options
PDF
Reporting Tips and Tricks (Spanish)
PDF
Rate limits and performance (Spanish)
PDF
OAuth 2.0 (Spanish)
PDF
End to-end how to build a platform (Spanish)
PDF
AwReporting tool introduction (Spanish)
PDF
Api update rundown (Spanish)
PDF
AdWords Scripts (Spanish)
Mcc scripts deck (日本語)
Getting started with Google Analytics and the AdWords API
Bid Estimation with the AdWords API (v2)
Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu
07. feeds update
AdWords API & OAuth 2.0, Advanced
AdWords Scripts and MCC Scripting
AwReporting Update
Getting Started with AdWords API and Google Analytics
Shopping Campaigns and AdWords API
API Updates for v201402
AdWords API Targeting Options
Reporting Tips and Tricks (Spanish)
Rate limits and performance (Spanish)
OAuth 2.0 (Spanish)
End to-end how to build a platform (Spanish)
AwReporting tool introduction (Spanish)
Api update rundown (Spanish)
AdWords Scripts (Spanish)

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Big Data Technologies - Introduction.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
Agricultural_Statistics_at_a_Glance_2022_0.pdf
A Presentation on Artificial Intelligence
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Mobile App Security Testing_ A Comprehensive Guide.pdf
Review of recent advances in non-invasive hemoglobin estimation
Building Integrated photovoltaic BIPV_UPV.pdf
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
NewMind AI Weekly Chronicles - August'25 Week I
Big Data Technologies - Introduction.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm

Rate limits and performance Talk

  • 1. AdWords API Workshops – All rights reserved
  • 2. API SERVER Rate Limits and API Best Practices <SPEAKER>, Google, Inc. AdWords API Workshops – All rights reserved
  • 3. Agenda ● API Best Practices ● What are Rate Limits? ● How to handle Rate Limits AdWords API Workshops – All rights reserved
  • 4. Best Practices Some simple things to speed up your applications AdWords API Workshops – All rights reserved
  • 5. Batch Operations Together AdWords API Workshops – All rights reserved ● Requests to the API have certain costs ● Network transfer, serialisation, auth, etc. ● Batching operations into a single request reduces these ● mutate methods accept arrays of operations ● MutateJobService for batching AdWords API Workshops – All rights reserved
  • 6. Group Operations by Target ● Multiple operations on the same AdGroup / Campaign are faster ● Subsequent edits to same AdGroup or Campaign can cause CONCURRENT_MODIFICATION errors ● Backend systems can take time to do their work ● Try to do all edits on AdGroups/Campaigns at once AdWords API Workshops – All rights reserved
  • 7. Only Update What you Need to ● Updating an object? ● Only send the values that will change! ● Sending in all the other values wastes time ● The system still validates them, stores to DB, etc. AdWords API Workshops – All rights reserved
  • 8. A Couple of Other Ideas … ● Compress your requests / response with gzip ● Make sure User-Agent: has “gzip” ● Accept-Encoding: lists gzip ● Use partial failure feature ● Tells API to serialise those ops that succeeded ● Returns list of those that failed AdWords API Workshops – All rights reserved
  • 9. Defining Rate Limits AdWords API Workshops – All rights reserved
  • 10. Rate Limits ● Are not fixed ● Vary on server load ● Vary per feature area ● Will change over time ● Different per AdWords service AdWords API Workshops – All rights reserved Defining Rate Limits
  • 11. Rate Limit Errors ● RATE_EXCEEDED ○ at least wait retryAfterSeconds seconds ● CONCURRENT_MODIFICATIONS ○ Exponential backoff, few retries only ● UNEXPECTED_INTERNAL_API_ERROR ○ Exponential back off, few retries only ○ Report the issue to your CSR or forum AdWords API Workshops – All rights reserved Defining Rate Limits
  • 12. How to Handle Rate Limits Careful coding... AdWords API Workshops – All rights reserved
  • 13. Basic Example Java ApiError[] errorArray = apiException.getErrors(); for (ApiError apiError : errorArray) { if (apiError instanceof RateExceededError) { int seconds = ((RateExceededError) apiError) .getRetryAfterSeconds(); // wait the amount of seconds the server asked Thread.sleep(seconds * 1000); } } AdWords API Workshops – All rights reserved How to handle Rate Limits
  • 14. Basic Example - Explained ● Any request can generate a RateExceededError ● Handling these errors is very important ● Wait and retry is the best strategy in this case ● Even more important when doing multiple requests AdWords API Workshops – All rights reserved
  • 15. Important Points About the Basic Solution ● Synchronous solution to the problem ● Blocks the thread until it succeeds, or fails completely ● No control over request rate speed ● Very difficult to group operations AdWords API Workshops – All rights reserved
  • 16. A More Advanced Solution ● Message Queues ● The perfect solution to distribute load and do throttling ● Very good out of the box solutions available ● ActiveMQ, RabbitMQ, … etc. ● A lot of tools / client libraries to handle comms layer AdWords API Workshops – All rights reserved
  • 17. Message Queues (cont’d) ● More control over the rates and limits ● Better break down into specialized modules ● Let’s take a look to three possible approaches to the problem... AdWords API Workshops – All rights reserved
  • 18. 1. Single Queue Producer Producers will create tasks to be executed using the API, and add them to the queue Producer Consumers Consumers Consumers X Queue Throttling Producer Logging Error Consumers will retrieve the messages/tasks from the queue with a controlled rate limit AdWords API Workshops – All rights reserved How to handle Rate Limits
  • 19. First Approach - Pros & Cons ● Pros: ● Very easy to implement ● Only one control point to change rate speed ● Easy to handle errors ● Cons: ● ● ● ● Only one control point to change rate speed Hard to group operations Tasks can take too long to be executed Not all MQs deal with message priority AdWords API Workshops – All rights reserved
  • 20. 2. Single Queue with Selectors Producers Producers Producers will create specific tasks to be executed, and add them to the queue with a specific header Producers Producers Each specific consumer can group the operations, and execute within your own rate limit using selectors X X X X Producers Producers Queue Throttling Producers Producers Producers Consumer AdWords API Workshops – All rights reserved Producers Consumer Producers Consumer Producers Consumer Error How to handle Rate Limits
  • 21. Second Approach - Pros & Cons ● Pros: ● Group operations by type ● Some control over throttling depending on type ● More efficient - better parallel access to the API ● Cons: ● ● ● ● Only one queue - difficult to administer No main control on how fast the API is called Managing all the pieces can be difficult Operation logging might be complicated AdWords API Workshops – All rights reserved
  • 22. 3. Multiple Queues Executors do the request Producers Consumer Producers Producers Producers Consumer Throttling Producers Producers Producers Producers Producers Producers Producers Consumer Producers Executors Executors Executors Producers Consumer Queues Consumers just group the tasks Error Logging X X X X Producers just spawn a lot of tasks Throttling AdWords API Workshops – All rights reserved How to handle Rate Limits
  • 23. Third Approach - Pros & Cons ● Pros: ● ● ● ● ● ● Total control over rate limits Very robust - very easy to add new parts Complete picture on what is happening with the queues Easy to scale based on demand If done properly, easy to do maintenance! Super efficient - Parallel grouping; Parallel access to the API ● Cons: ● Hard to implement properly - experience required AdWords API Workshops – All rights reserved
  • 24. Message Queues - Takeaways ● Complexity of your platform dictates the best solution ● You can combine parts of other solutions! ● It is a complex subject, but will save you in the long run ● Invest a lot in monitoring. A lot! ● There is no silver bullet... AdWords API Workshops – All rights reserved
  • 25. Resources API Best Practices - https://developers.google. com/adwords/api/docs/guides/bestpractices ActiveMQ - http://activemq.apache.org/ RabbitMQ - http://www.rabbitmq.com/ AdWords API Workshops – All rights reserved
  • 26. Questions? Thank you! AdWords API Workshops – All rights reserved
  • 27. AdWords API Workshops – All rights reserved