SlideShare a Scribd company logo
1 of 27
Download to read offline
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

What's hot

A/B testing platform on Elixir
A/B testing platform on Elixir A/B testing platform on Elixir
A/B testing platform on Elixir Dmitry Tymchuk
 
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersJitendra Zaa
 
2º Encontro GUG Rio de Janeiro/2010
2º Encontro GUG Rio de Janeiro/20102º Encontro GUG Rio de Janeiro/2010
2º Encontro GUG Rio de Janeiro/2010Nataniel Strack
 
The A, B, Cs of What to Expect
The A, B, Cs of What to ExpectThe A, B, Cs of What to Expect
The A, B, Cs of What to ExpectAgnes Meilhac
 
Gcp cloud certification training course
Gcp cloud certification training courseGcp cloud certification training course
Gcp cloud certification training coursesrip30
 
Tesla final presentation ent
Tesla final presentation entTesla final presentation ent
Tesla final presentation entMohammedAmmar51
 
Episode 9 - Building soap integrations in salesforce
Episode 9 - Building soap integrations  in salesforceEpisode 9 - Building soap integrations  in salesforce
Episode 9 - Building soap integrations in salesforceJitendra Zaa
 

What's hot (9)

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

Similar to Rate limits and performance Talk

AdWords API - How to build a platform
AdWords API - How to build a platformAdWords API - How to build a platform
AdWords API - How to build a platformTimoBoz
 
How_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfHow_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfskimorod
 
API Update Rundown
API Update RundownAPI Update Rundown
API Update Rundownmarcwan
 
AwReporting Tool
AwReporting ToolAwReporting Tool
AwReporting Toolmarcwan
 
Client-Side Performance Testing
Client-Side Performance TestingClient-Side Performance Testing
Client-Side Performance TestingAnand Bagmar
 
Why use ad words api
Why use ad words apiWhy use ad words api
Why use ad words apisupergigas
 
Reporting tips & tricks
Reporting tips & tricksReporting tips & tricks
Reporting tips & tricksmarcwan
 
Nginx Conference 2016 - Learnings and State of the Industry
Nginx Conference 2016 - Learnings and State of the IndustryNginx Conference 2016 - Learnings and State of the Industry
Nginx Conference 2016 - Learnings and State of the IndustryBenjamin Scholler
 
QTP Automation Testing Tutorial 1
QTP Automation Testing Tutorial 1QTP Automation Testing Tutorial 1
QTP Automation Testing Tutorial 1Akash Tyagi
 
A differnt Type of Supermarket Delivery
A differnt Type of Supermarket DeliveryA differnt Type of Supermarket Delivery
A differnt Type of Supermarket DeliveryThoughtworks
 
Performance testing with JMeter
Performance testing with JMeterPerformance testing with JMeter
Performance testing with JMeterMikael Kundert
 
Api gateway : To be or not to be
Api gateway : To be or not to beApi gateway : To be or not to be
Api gateway : To be or not to beJaewoo Ahn
 
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...MysoreMuleSoftMeetup
 
AdWords Scripts
AdWords ScriptsAdWords Scripts
AdWords Scriptsmarcwan
 
Reporting tips & tricks
Reporting tips & tricks  Reporting tips & tricks
Reporting tips & tricks marcwan
 
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
WSO2Con Asia 2014 - Effective Test Automation in an Agile EnvironmentWSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
WSO2Con Asia 2014 - Effective Test Automation in an Agile EnvironmentWSO2
 
Training Webinar: Detect Performance Bottlenecks of Applications
Training Webinar: Detect Performance Bottlenecks of ApplicationsTraining Webinar: Detect Performance Bottlenecks of Applications
Training Webinar: Detect Performance Bottlenecks of ApplicationsOutSystems
 
AdWords API Feed Services
AdWords API Feed ServicesAdWords API Feed Services
AdWords API Feed Servicesmarcwan
 

Similar to Rate limits and performance Talk (20)

AdWords API - How to build a platform
AdWords API - How to build a platformAdWords API - How to build a platform
AdWords API - How to build a platform
 
How_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdfHow_to_create_modular_microservice_test_projects.pdf
How_to_create_modular_microservice_test_projects.pdf
 
API Update Rundown
API Update RundownAPI Update Rundown
API Update Rundown
 
AwReporting Tool
AwReporting ToolAwReporting Tool
AwReporting Tool
 
Client-Side Performance Testing
Client-Side Performance TestingClient-Side Performance Testing
Client-Side Performance Testing
 
Why use ad words api
Why use ad words apiWhy use ad words api
Why use ad words api
 
Reporting tips & tricks
Reporting tips & tricksReporting tips & tricks
Reporting tips & tricks
 
Nginx Conference 2016 - Learnings and State of the Industry
Nginx Conference 2016 - Learnings and State of the IndustryNginx Conference 2016 - Learnings and State of the Industry
Nginx Conference 2016 - Learnings and State of the Industry
 
QTP Automation Testing Tutorial 1
QTP Automation Testing Tutorial 1QTP Automation Testing Tutorial 1
QTP Automation Testing Tutorial 1
 
A differnt Type of Supermarket Delivery
A differnt Type of Supermarket DeliveryA differnt Type of Supermarket Delivery
A differnt Type of Supermarket Delivery
 
Performance testing with JMeter
Performance testing with JMeterPerformance testing with JMeter
Performance testing with JMeter
 
Test Automation for QTP
Test Automation for QTPTest Automation for QTP
Test Automation for QTP
 
Test Automation
Test AutomationTest Automation
Test Automation
 
Api gateway : To be or not to be
Api gateway : To be or not to beApi gateway : To be or not to be
Api gateway : To be or not to be
 
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
Designing Fault Tolerant APIs to keep Application Network Intact | MuleSoft M...
 
AdWords Scripts
AdWords ScriptsAdWords Scripts
AdWords Scripts
 
Reporting tips & tricks
Reporting tips & tricks  Reporting tips & tricks
Reporting tips & tricks
 
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
WSO2Con Asia 2014 - Effective Test Automation in an Agile EnvironmentWSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
WSO2Con Asia 2014 - Effective Test Automation in an Agile Environment
 
Training Webinar: Detect Performance Bottlenecks of Applications
Training Webinar: Detect Performance Bottlenecks of ApplicationsTraining Webinar: Detect Performance Bottlenecks of Applications
Training Webinar: Detect Performance Bottlenecks of Applications
 
AdWords API Feed Services
AdWords API Feed ServicesAdWords API Feed Services
AdWords API Feed Services
 

More from marcwan

Mcc scripts deck (日本語)
Mcc scripts deck (日本語)Mcc scripts deck (日本語)
Mcc scripts deck (日本語)marcwan
 
Getting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords APIGetting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords APImarcwan
 
Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)marcwan
 
Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)marcwan
 
Opportunity Analysis with Kratu
Opportunity Analysis with KratuOpportunity Analysis with Kratu
Opportunity Analysis with Kratumarcwan
 
07. feeds update
07. feeds update07. feeds update
07. feeds updatemarcwan
 
AdWords API & OAuth 2.0, Advanced
AdWords API & OAuth 2.0, Advanced AdWords API & OAuth 2.0, Advanced
AdWords API & OAuth 2.0, Advanced marcwan
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scriptingmarcwan
 
AwReporting Update
AwReporting UpdateAwReporting Update
AwReporting Updatemarcwan
 
Getting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google AnalyticsGetting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google Analyticsmarcwan
 
Shopping Campaigns and AdWords API
Shopping Campaigns and AdWords APIShopping Campaigns and AdWords API
Shopping Campaigns and AdWords APImarcwan
 
API Updates for v201402
API Updates for v201402API Updates for v201402
API Updates for v201402marcwan
 
AdWords API Targeting Options
AdWords API Targeting OptionsAdWords API Targeting Options
AdWords API Targeting Optionsmarcwan
 
Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)marcwan
 
Rate limits and performance (Spanish)
Rate limits and performance (Spanish)Rate limits and performance (Spanish)
Rate limits and performance (Spanish)marcwan
 
OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)marcwan
 
End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)marcwan
 
AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)marcwan
 
Api update rundown (Spanish)
Api update rundown (Spanish)Api update rundown (Spanish)
Api update rundown (Spanish)marcwan
 
AdWords Scripts (Spanish)
AdWords Scripts (Spanish)AdWords Scripts (Spanish)
AdWords Scripts (Spanish)marcwan
 

More from marcwan (20)

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

Recently uploaded

Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 

Recently uploaded (20)

DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 

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