SlideShare a Scribd company logo
1 of 25
Download to read offline
Rate Limits &
Performance
Handling Rate limits, boosting
performance
Gustavo Moreira
<Presenter>
Agenda
● API best practices
● What are rate limits?
● How to handle rate limits?
Best Practices
Some simple things to speed up your applications
Batch operations together
● Requests to the API have certain costs
○ Network transfer, serialisation, auth, etc.
● Batching operations into a single request
● mutate methods accept operation arrays
Group operations by target
● Multiple operations on the same
AdGroup/Campaign are faster
● Subsequent edits can cause
CONCURRENT_MODIFICATION errors
○ Backend can take time to do its work
○ Try all edits to AdGroups/Campaigns at once
Only update what you need
● Updating an object?
○ Only send the values that will change!
○ Sending all other values wastes time
■ System validation
■ DB storing
■ etc.
A couple of other things...
● Compress your traffic with
gzip
○ User-Agent: has "gzip"
○ Accept-Encoding: "gzip"
● Use partial failure
○ Tells API to serialise those ops
that succeeded
○ Returns list of those that failed
Defining Rate Limits
Rate Limits
● Not fixed
● Vary on server load
● Vary per feature area
● Will change over time
● Differs per AdWords Service
Limit based on Access Level
● This limit doesn't fluctuate
● The access level can be Basic or Standard
Standard: More than 10K
Basic: 10K operations per day
operations per day allowed
Rate Limit Errors
● RATE_EXCEEDED
○ 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
How to Handle
Rate Limits
Basic Example
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);
}
}
Basic Example - Explained
● Any request can generate a
RateExceededError
● Handle these errors!
● Best strategy: wait and retry
● Even more important when
doing multiple requests
Important points - 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
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 the
communication layer
Message Queues - Cont.
● 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...
1. Single Queue
Consume
rs
Queue
Producer
Producer
Producer
Consume
rs
Throttling
Producers will create tasks to
be executed using the API, and
add them to the queue
Consumers will retrieve the
messages/tasks from the queue
with a controlled rate limit
X
Error
Consumers
Logging
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
2. Single Queue with Selectors
Queue
Producers
Producers
Producers
Producers
Consumer
Consumer
Consumer
Consumer
Throttling
Producers will create specific tasks
to be executed, and add them to
the queue with a specific header
Each specific consumer can group
the operations, and execute within
your own rate limit using selectors
X
X
X
X
Error
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
3. Multiple Queues
Queues
Producers
Producers
Producers
Producers
Consumer
Consumer
Consumer
ConsumerThrottling
X
X
X
X
Error
Executors
Throttling
Logging
Producers just
spawn a lot of tasks
Consumers just group the tasks
Executors do the request
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
Message Queues - Takeaway
● 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...
Resources
● API Best Practices - https://developers.
google.
com/adwords/api/docs/guides/bestpractic
es
● ActiveMQ - http://activemq.apache.org/
● RabbitMQ - http://www.rabbitmq.com/

More Related Content

What's hot

NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and TuningNGINX, Inc.
 
MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks EDB
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to RedisDvir Volk
 
Data engineering zoomcamp introduction
Data engineering zoomcamp  introductionData engineering zoomcamp  introduction
Data engineering zoomcamp introductionAlexey Grigorev
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013mumrah
 
RabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryRabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryMohammed Shaban
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.Taras Matyashovsky
 
REST API 설계
REST API 설계REST API 설계
REST API 설계Terry Cho
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking VN
 
Elasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveElasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveSematext Group, Inc.
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesJonathan Katz
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLRamakant Soni
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and ImplementationVarun Talwar
 
Wide Column Store NoSQL vs SQL Data Modeling
Wide Column Store NoSQL vs SQL Data ModelingWide Column Store NoSQL vs SQL Data Modeling
Wide Column Store NoSQL vs SQL Data ModelingScyllaDB
 
HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...DataWorks Summit
 
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
 Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit... Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...Databricks
 

What's hot (20)

NGINX Installation and Tuning
NGINX Installation and TuningNGINX Installation and Tuning
NGINX Installation and Tuning
 
MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks MongoDB vs. Postgres Benchmarks
MongoDB vs. Postgres Benchmarks
 
Introduction to Redis
Introduction to RedisIntroduction to Redis
Introduction to Redis
 
Data engineering zoomcamp introduction
Data engineering zoomcamp  introductionData engineering zoomcamp  introduction
Data engineering zoomcamp introduction
 
Apache Airflow
Apache AirflowApache Airflow
Apache Airflow
 
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
Introduction and Overview of Apache Kafka, TriHUG July 23, 2013
 
RabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client libraryRabbitMQ and AMQP with .net client library
RabbitMQ and AMQP with .net client library
 
From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.From cache to in-memory data grid. Introduction to Hazelcast.
From cache to in-memory data grid. Introduction to Hazelcast.
 
REST API 설계
REST API 설계REST API 설계
REST API 설계
 
Grokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKIGrokking TechTalk #33: High Concurrency Architecture at TIKI
Grokking TechTalk #33: High Concurrency Architecture at TIKI
 
RabbitMQ
RabbitMQ RabbitMQ
RabbitMQ
 
Elasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep diveElasticsearch for Logs & Metrics - a deep dive
Elasticsearch for Logs & Metrics - a deep dive
 
Operating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with KubernetesOperating PostgreSQL at Scale with Kubernetes
Operating PostgreSQL at Scale with Kubernetes
 
NOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQLNOSQL- Presentation on NoSQL
NOSQL- Presentation on NoSQL
 
Message Broker System and RabbitMQ
Message Broker System and RabbitMQMessage Broker System and RabbitMQ
Message Broker System and RabbitMQ
 
gRPC Design and Implementation
gRPC Design and ImplementationgRPC Design and Implementation
gRPC Design and Implementation
 
Wide Column Store NoSQL vs SQL Data Modeling
Wide Column Store NoSQL vs SQL Data ModelingWide Column Store NoSQL vs SQL Data Modeling
Wide Column Store NoSQL vs SQL Data Modeling
 
HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...HBase Tales From the Trenches - Short stories about most common HBase operati...
HBase Tales From the Trenches - Short stories about most common HBase operati...
 
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
 Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit... Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
Near Real-Time Netflix Recommendations Using Apache Spark Streaming with Nit...
 
Caching
CachingCaching
Caching
 

Similar to Rate limits and Performance

Rate limits and performance Talk
Rate limits and performance TalkRate limits and performance Talk
Rate limits and performance Talkmarcwan
 
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
 
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...InfluxData
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Startupfest
 
Netflix SRE perf meetup_slides
Netflix SRE perf meetup_slidesNetflix SRE perf meetup_slides
Netflix SRE perf meetup_slidesEd Hunter
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUGslandelle
 
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra TagareActionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra TagareApache Apex
 
PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux Neotys
 
iFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with ScyllaiFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with ScyllaScyllaDB
 
Three Perspectives on Measuring Latency
Three Perspectives on Measuring LatencyThree Perspectives on Measuring Latency
Three Perspectives on Measuring LatencyScyllaDB
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionSteve Hogg
 
Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3LibbySchulze
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With GatlingKnoldus Inc.
 
Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Omid Vahdaty
 
IBM MQ - better application performance
IBM MQ - better application performanceIBM MQ - better application performance
IBM MQ - better application performanceMarkTaylorIBM
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesAlexander Penev
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uberconfluent
 

Similar to Rate limits and Performance (20)

Rate limits and performance Talk
Rate limits and performance TalkRate limits and performance Talk
Rate limits and performance Talk
 
BAXTER phase 1b
BAXTER phase 1bBAXTER phase 1b
BAXTER phase 1b
 
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
 
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
Wayfair Storefront Performance Monitoring with InfluxEnterprise by Richard La...
 
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
Jeremy Edberg (MinOps ) - How to build a solid infrastructure for a startup t...
 
Netflix SRE perf meetup_slides
Netflix SRE perf meetup_slidesNetflix SRE perf meetup_slides
Netflix SRE perf meetup_slides
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUG
 
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra TagareActionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
Actionable Insights with Apache Apex at Apache Big Data 2017 by Devendra Tagare
 
PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux PAC 2019 virtual Bruno Audoux
PAC 2019 virtual Bruno Audoux
 
iFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with ScyllaiFood on Delivering 100 Million Events a Month to Restaurants with Scylla
iFood on Delivering 100 Million Events a Month to Restaurants with Scylla
 
Three Perspectives on Measuring Latency
Three Perspectives on Measuring LatencyThree Perspectives on Measuring Latency
Three Perspectives on Measuring Latency
 
Serverless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From ProductionServerless - DevOps Lessons Learned From Production
Serverless - DevOps Lessons Learned From Production
 
Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3Scaling Monitoring At Databricks From Prometheus to M3
Scaling Monitoring At Databricks From Prometheus to M3
 
Gatling
Gatling Gatling
Gatling
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With Gatling
 
Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...Lessons learned from designing QA automation event streaming platform(IoT big...
Lessons learned from designing QA automation event streaming platform(IoT big...
 
Performance test
Performance testPerformance test
Performance test
 
IBM MQ - better application performance
IBM MQ - better application performanceIBM MQ - better application performance
IBM MQ - better application performance
 
Zero Downtime JEE Architectures
Zero Downtime JEE ArchitecturesZero Downtime JEE Architectures
Zero Downtime JEE Architectures
 
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ UberKafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
Kafka Summit NYC 2017 - Scalable Real-Time Complex Event Processing @ Uber
 

More from supergigas

Remarketing using customer match
Remarketing using customer matchRemarketing using customer match
Remarketing using customer matchsupergigas
 
What's new in reporting
What's new in reporting What's new in reporting
What's new in reporting supergigas
 
Location aware ad customizers
Location aware ad customizersLocation aware ad customizers
Location aware ad customizerssupergigas
 
GMB API (Google My Business)
GMB API (Google My Business)GMB API (Google My Business)
GMB API (Google My Business)supergigas
 
Uploading HTML5 ads
Uploading HTML5 adsUploading HTML5 ads
Uploading HTML5 adssupergigas
 
BatchJobService
BatchJobServiceBatchJobService
BatchJobServicesupergigas
 
Why use ad words api
Why use ad words apiWhy use ad words api
Why use ad words apisupergigas
 
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
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts updatesupergigas
 
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
 
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 (18)

Remarketing using customer match
Remarketing using customer matchRemarketing using customer match
Remarketing using customer match
 
What's new in reporting
What's new in reporting What's new in reporting
What's new in reporting
 
Location aware ad customizers
Location aware ad customizersLocation aware ad customizers
Location aware ad customizers
 
GMB API (Google My Business)
GMB API (Google My Business)GMB API (Google My Business)
GMB API (Google My Business)
 
Uploading HTML5 ads
Uploading HTML5 adsUploading HTML5 ads
Uploading HTML5 ads
 
BatchJobService
BatchJobServiceBatchJobService
BatchJobService
 
Why use ad words api
Why use ad words apiWhy use ad words api
Why use ad words api
 
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
 
MCC Scripts update
MCC Scripts updateMCC Scripts update
MCC Scripts update
 
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
 
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

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
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
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"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
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
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?
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
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
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"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
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

Rate limits and Performance

  • 1. Rate Limits & Performance Handling Rate limits, boosting performance Gustavo Moreira <Presenter>
  • 2. Agenda ● API best practices ● What are rate limits? ● How to handle rate limits?
  • 3. Best Practices Some simple things to speed up your applications
  • 4. Batch operations together ● Requests to the API have certain costs ○ Network transfer, serialisation, auth, etc. ● Batching operations into a single request ● mutate methods accept operation arrays
  • 5. Group operations by target ● Multiple operations on the same AdGroup/Campaign are faster ● Subsequent edits can cause CONCURRENT_MODIFICATION errors ○ Backend can take time to do its work ○ Try all edits to AdGroups/Campaigns at once
  • 6. Only update what you need ● Updating an object? ○ Only send the values that will change! ○ Sending all other values wastes time ■ System validation ■ DB storing ■ etc.
  • 7. A couple of other things... ● Compress your traffic with gzip ○ User-Agent: has "gzip" ○ Accept-Encoding: "gzip" ● Use partial failure ○ Tells API to serialise those ops that succeeded ○ Returns list of those that failed
  • 9. Rate Limits ● Not fixed ● Vary on server load ● Vary per feature area ● Will change over time ● Differs per AdWords Service
  • 10. Limit based on Access Level ● This limit doesn't fluctuate ● The access level can be Basic or Standard Standard: More than 10K Basic: 10K operations per day operations per day allowed
  • 11. Rate Limit Errors ● RATE_EXCEEDED ○ 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
  • 13. Basic Example 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); } }
  • 14. Basic Example - Explained ● Any request can generate a RateExceededError ● Handle these errors! ● Best strategy: wait and retry ● Even more important when doing multiple requests
  • 15. Important points - 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
  • 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 the communication layer
  • 17. Message Queues - Cont. ● 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...
  • 18. 1. Single Queue Consume rs Queue Producer Producer Producer Consume rs Throttling Producers will create tasks to be executed using the API, and add them to the queue Consumers will retrieve the messages/tasks from the queue with a controlled rate limit X Error Consumers Logging
  • 19. 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
  • 20. 2. Single Queue with Selectors Queue Producers Producers Producers Producers Consumer Consumer Consumer Consumer Throttling Producers will create specific tasks to be executed, and add them to the queue with a specific header Each specific consumer can group the operations, and execute within your own rate limit using selectors X X X X Error
  • 21. 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
  • 23. 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
  • 24. Message Queues - Takeaway ● 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...
  • 25. Resources ● API Best Practices - https://developers. google. com/adwords/api/docs/guides/bestpractic es ● ActiveMQ - http://activemq.apache.org/ ● RabbitMQ - http://www.rabbitmq.com/