SlideShare a Scribd company logo
1 of 35
Scaling APIs
Feeding your Speeds


April 5, 2012




Greg Brail       @gbrail
Brian Pagano     @brianpagano
@gbrail   @brianpagano
groups.google.com/group/api-craft
youtube.com/apigee
New!

       IRC Channel
         #api-craft
        on freenode
What is scale to an API?


Developers: Lots of developers building apps
Apps: Lots of apps for end users to use
End users: Millions and millions of app users
Versions: Lots of API versions to manage
API calls: All of these things result in API calls…
Today’s Topic: API Calls

Today we are going to focus on handling huge numbers
of API calls in an API infrastructure

        Ever been in a meeting where someone said,
“let’s not talk about ‘speeds and feeds’ today?”

                               This is not that meeting.
Why do APIs need to scale?

Thousands of app developers…
                                      Each one must be managed, signed up, etc.
Thousands of apps…
                               Each one has credentials that need to be validated
Millions of end users…
                                  Each one has one or more OAuth access tokens


Result in lots of API calls. For example:
                                                         One million end users,
                                                     Making 1000 API calls a day,
                               Results in one billion API calls a day,
                   Or about 11,000 API calls per second on average
Tracking API calls

Today we’ll mainly talk about throughput

Measured in API calls or transactions per second (tps)
  For an API, usually as the number of users increases,
  throughput increases


As throughput increases, latency often increases too
  It’s not enough just to handle lots of throughput – it’s
  important to handle it with a reasonable amount of latency
What Limits Scale?


Disk                 Database

Network              App server

CPU                  API Proxy

Memory               Load balancer

                     Cache servers
What are some limits?


Seek time               Database design & tuning
Rotational speed        App server coding & config
Transfer speed          Proxy configuration
Clock speed             Load balancer policies
Number of cores         Cache configuration
Amount of RAM           And many more…
Some examples

We’re going to talk about things to look at as
throughput grows from one level of traffic to another…
                         1 tps
                         10 tps
                        100 tps
                       1000 tps
                     10,000 tps
                   100,000 tps
                  and beyond…..
Image from valdosta.edu
At 1 transaction per second

86,400 per day / 2.5 million per month

Almost everything can handle this.

What about the database?
   If each API call makes several big SQL queries, it may not!
Strategies for 1 tps


Test (always)
Tune the database installation
Tune the database design
Monitor query performance
Test again!
image from istockphoto.com
At 10 transactions per second

864,000 per day / 25 million per month

Most infrastructure can still handle this.

What about the application server?
   Is the app well-designed enough?
   Does it make an excessive number of database calls?
Strategies for 10 tps


Ensure that the app server is properly optimized
  Do API calls make the minimum number of database calls?
  Do API calls depend on large numbers of external services?
image from istockphoto.com
At 100 transactions per second

8.6 million per day / 259 million per month

(Now we are starting to get somewhere)

RDBMS systems may struggle
Less-efficient app servers may struggle
“Free” tiers on hosting platforms aren’t an option
Strategies for 100 tps

Database optimization and tuning is critical here
  Allocate fast storage, and lots of it
  Allocate lots of memory
  Tune the database to use it!
  Find bad queries and fix them or optimize them


App server tuning is critical here
  Are there enough threads in the thread pool?
  Are there enough processes?
Image from http://www.jigzone.com
At 1000 transactions per second

86 million per day / 2.5 billion per month

Now everything may start to break…

What is the mix between reads and writes?
Strategies for 1000 tps

Understand the mix between reads and writes
  Cache the reads as much as you can
  If you can cache them closer to the client, better


Understand your app server performance
  Faster app servers should still be able to handle (like Java)
  RoR, Python, PHP, etc will require much bigger clusters
  Stateless app servers are your friend!
More strategies for 1000 tps

Can the database handle the load?
  It can if most transactions are reads
  And you cache as much as you can


Otherwise it’s time to scale the database layer
  Sharded RDBMSes
  Or a scalable NoSQL database works here
At 10,000 transactions per second

864 million per day / 25 billion per month

If most transactions are reads, caching is your friend

Otherwise, this is serious business
  No single database can handle this
  Few single app servers can handle this
  If API calls are large, what will the bandwidth be?
Strategies for 10,000 tps

Caching is even more essential
  Even a simple cache can handle this load on one or two boxes


Database writes are problematic
  No single database server can write 10,000 times per second
  Scalable, eventually-consistent databases can scale this big,
  (like Cassandra)
More for 10,000

App servers
  You’ll need a cluster of app servers no matter what!
  What about session management?
  What about load balancing?
100,000 API calls per second

8.6 billion per day!

Now your API is truly impressive
  (either that or it is very poorly designed!)


You will need racks of infrastructure no matter what!
Some other considerations


API design

Client design

Latency

Bandwidth
What about API design?

Every API call has overhead:
      TCP connection / SSL handshake / load balancer CPU / API
        proxy CPU / App server CPU and thread pool / database
                                        connections / disk I/O…


Do you need to make so many?
 Can you design your APIs to support fewer high-value API calls?
                         Can you have “batch” calls in your API?
What about the client?

Can client apps use the API more efficiently?
  Don’t make the same API calls over and over
  Utilize compression
  Utilize conditional requests in HTTP
     Which means that the API server should support them!
  Request only the data that’s needed
     Which means that the API server should trim responses
     Or paginate them
What about latency?

Latency kills user experience!


How can the API server reduce it?
  Remove steps in the processing flow through caching
  Cache closer to the API clients
What about the network?

What kind of network connection to you have?
  For instance, in EC2 you get 1Gbps,
  Or about 122 megabytes / second
  At 10,000 tps, for instance, that’s 12K per API call
THANK YOU
Questions and ideas to:

@gbrail
@brianpagano

More Related Content

What's hot

Integrating Security into DevOps
Integrating Security into DevOpsIntegrating Security into DevOps
Integrating Security into DevOps
CloudPassage
 
Sahi Web Automation and Testing Tool
Sahi Web Automation and Testing ToolSahi Web Automation and Testing Tool
Sahi Web Automation and Testing Tool
Tyto Software
 

What's hot (20)

Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
Native, Hybrid, or Cross-platform Development? What Type of Mobile App is Bes...
 
Selenium test automation
Selenium test automationSelenium test automation
Selenium test automation
 
Automated Web Testing Using Selenium
Automated Web Testing Using SeleniumAutomated Web Testing Using Selenium
Automated Web Testing Using Selenium
 
Testing Applications with AWS Device Farm
Testing Applications with AWS Device FarmTesting Applications with AWS Device Farm
Testing Applications with AWS Device Farm
 
Refine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated testRefine your ci:cd pipeline with automated test
Refine your ci:cd pipeline with automated test
 
Test Automation Framework Designs
Test Automation Framework DesignsTest Automation Framework Designs
Test Automation Framework Designs
 
Firebase
FirebaseFirebase
Firebase
 
Azure DevOps
Azure DevOpsAzure DevOps
Azure DevOps
 
Integrating Security into DevOps
Integrating Security into DevOpsIntegrating Security into DevOps
Integrating Security into DevOps
 
Azure dev ops
Azure dev opsAzure dev ops
Azure dev ops
 
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
Jenkins Pipeline Tutorial | Continuous Delivery Pipeline Using Jenkins | DevO...
 
Android Platform Architecture
Android Platform ArchitectureAndroid Platform Architecture
Android Platform Architecture
 
OpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platformOpenShift 4, the smarter Kubernetes platform
OpenShift 4, the smarter Kubernetes platform
 
Ansible
AnsibleAnsible
Ansible
 
Sahi Web Automation and Testing Tool
Sahi Web Automation and Testing ToolSahi Web Automation and Testing Tool
Sahi Web Automation and Testing Tool
 
Test automation
Test automationTest automation
Test automation
 
Bn1006 demo ppt devops
Bn1006 demo ppt devopsBn1006 demo ppt devops
Bn1006 demo ppt devops
 
Continuous Security: Using Automation to Expand Security's Reach
Continuous Security: Using Automation to Expand Security's ReachContinuous Security: Using Automation to Expand Security's Reach
Continuous Security: Using Automation to Expand Security's Reach
 
Selenium Concepts
Selenium ConceptsSelenium Concepts
Selenium Concepts
 
DevOps Architecture Design
DevOps Architecture DesignDevOps Architecture Design
DevOps Architecture Design
 

Similar to Scaling APIs: Predict, Prepare for, Overcome the Challenges

Similar to Scaling APIs: Predict, Prepare for, Overcome the Challenges (20)

Starting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for OpsStarting Your DevOps Journey – Practical Tips for Ops
Starting Your DevOps Journey – Practical Tips for Ops
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 
OSMC 2018 | What We Should All Worry About When Monitoring Serverless Applica...
OSMC 2018 | What We Should All Worry About When Monitoring Serverless Applica...OSMC 2018 | What We Should All Worry About When Monitoring Serverless Applica...
OSMC 2018 | What We Should All Worry About When Monitoring Serverless Applica...
 
Azure api management
Azure api managementAzure api management
Azure api management
 
Building a Great Web API - Evan Cooke - QCON 2011
Building a Great Web API - Evan Cooke - QCON 2011Building a Great Web API - Evan Cooke - QCON 2011
Building a Great Web API - Evan Cooke - QCON 2011
 
Big data and APIs for PHP developers - SXSW 2011
Big data and APIs for PHP developers - SXSW 2011Big data and APIs for PHP developers - SXSW 2011
Big data and APIs for PHP developers - SXSW 2011
 
Handling Data in Mega Scale Systems
Handling Data in Mega Scale SystemsHandling Data in Mega Scale Systems
Handling Data in Mega Scale Systems
 
apidays Australia 2023 - The Playful Bond Between REST And Data Streams, Warr...
apidays Australia 2023 - The Playful Bond Between REST And Data Streams, Warr...apidays Australia 2023 - The Playful Bond Between REST And Data Streams, Warr...
apidays Australia 2023 - The Playful Bond Between REST And Data Streams, Warr...
 
The Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data StreamsThe Playful Bond Between REST And Data Streams
The Playful Bond Between REST And Data Streams
 
Building collaborative HTML5 apps using a backend-as-a-service (HTML5DevConf ...
Building collaborative HTML5 apps using a backend-as-a-service (HTML5DevConf ...Building collaborative HTML5 apps using a backend-as-a-service (HTML5DevConf ...
Building collaborative HTML5 apps using a backend-as-a-service (HTML5DevConf ...
 
Sydney summit-lock note
Sydney summit-lock noteSydney summit-lock note
Sydney summit-lock note
 
Become a Performance Diagnostics Hero
Become a Performance Diagnostics HeroBecome a Performance Diagnostics Hero
Become a Performance Diagnostics Hero
 
Netflix Edge Engineering Open House Presentations - June 9, 2016
Netflix Edge Engineering Open House Presentations - June 9, 2016Netflix Edge Engineering Open House Presentations - June 9, 2016
Netflix Edge Engineering Open House Presentations - June 9, 2016
 
Building A Great API - Evan Cooke, Cloudstock, December 2010
Building A Great API - Evan Cooke, Cloudstock, December 2010Building A Great API - Evan Cooke, Cloudstock, December 2010
Building A Great API - Evan Cooke, Cloudstock, December 2010
 
Leveraging Microservice Architectures & Event-Driven Systems for Global APIs
Leveraging Microservice Architectures & Event-Driven Systems for Global APIsLeveraging Microservice Architectures & Event-Driven Systems for Global APIs
Leveraging Microservice Architectures & Event-Driven Systems for Global APIs
 
Big and fast a quest for relevant and real-time analytics
Big and fast a quest for relevant and real-time analyticsBig and fast a quest for relevant and real-time analytics
Big and fast a quest for relevant and real-time analytics
 
Big Data Use Cases and Solutions in the AWS Cloud
Big Data Use Cases and Solutions in the AWS CloudBig Data Use Cases and Solutions in the AWS Cloud
Big Data Use Cases and Solutions in the AWS Cloud
 
ConFoo 2017: Introduction to performance optimization of .NET web apps
ConFoo 2017: Introduction to performance optimization of .NET web appsConFoo 2017: Introduction to performance optimization of .NET web apps
ConFoo 2017: Introduction to performance optimization of .NET web apps
 
Tidal scale short_story_v2
Tidal scale short_story_v2Tidal scale short_story_v2
Tidal scale short_story_v2
 
Leveraging The Cloud In 2009
Leveraging The Cloud In 2009Leveraging The Cloud In 2009
Leveraging The Cloud In 2009
 

More from Apigee | Google Cloud

More from Apigee | Google Cloud (20)

How Secure Are Your APIs?
How Secure Are Your APIs?How Secure Are Your APIs?
How Secure Are Your APIs?
 
Magazine Luiza at a glance (1)
Magazine Luiza at a glance (1)Magazine Luiza at a glance (1)
Magazine Luiza at a glance (1)
 
Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs Monetization: Unlock More Value from Your APIs
Monetization: Unlock More Value from Your APIs
 
Apigee Demo: API Platform Overview
Apigee Demo: API Platform OverviewApigee Demo: API Platform Overview
Apigee Demo: API Platform Overview
 
Ticketmaster at a glance
Ticketmaster at a glanceTicketmaster at a glance
Ticketmaster at a glance
 
AccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First WorldAccuWeather: Recasting API Experiences in a Developer-First World
AccuWeather: Recasting API Experiences in a Developer-First World
 
Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?Which Application Modernization Pattern Is Right For You?
Which Application Modernization Pattern Is Right For You?
 
Apigee Product Roadmap Part 2
Apigee Product Roadmap Part 2Apigee Product Roadmap Part 2
Apigee Product Roadmap Part 2
 
The Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management MarketThe Four Transformative Forces of the API Management Market
The Four Transformative Forces of the API Management Market
 
Walgreens at a glance
Walgreens at a glanceWalgreens at a glance
Walgreens at a glance
 
Apigee Edge: Intro to Microgateway
Apigee Edge: Intro to MicrogatewayApigee Edge: Intro to Microgateway
Apigee Edge: Intro to Microgateway
 
Managing the Complexity of Microservices Deployments
Managing the Complexity of Microservices DeploymentsManaging the Complexity of Microservices Deployments
Managing the Complexity of Microservices Deployments
 
Pitney Bowes at a glance
Pitney Bowes at a glancePitney Bowes at a glance
Pitney Bowes at a glance
 
Microservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices SuccessMicroservices Done Right: Key Ingredients for Microservices Success
Microservices Done Right: Key Ingredients for Microservices Success
 
Adapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet KapoorAdapt or Die: Opening Keynote with Chet Kapoor
Adapt or Die: Opening Keynote with Chet Kapoor
 
Adapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg BrailAdapt or Die: Keynote with Greg Brail
Adapt or Die: Keynote with Greg Brail
 
Adapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant JhingranAdapt or Die: Keynote with Anant Jhingran
Adapt or Die: Keynote with Anant Jhingran
 
London Adapt or Die: Opening Keynot
London Adapt or Die: Opening KeynotLondon Adapt or Die: Opening Keynot
London Adapt or Die: Opening Keynot
 
London Adapt or Die: Lunch keynote
London Adapt or Die: Lunch keynoteLondon Adapt or Die: Lunch keynote
London Adapt or Die: Lunch keynote
 
London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!London Adapt or Die: Closing Keynote — Adapt Now!
London Adapt or Die: Closing Keynote — Adapt Now!
 

Recently uploaded

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Scaling APIs: Predict, Prepare for, Overcome the Challenges

  • 1. Scaling APIs Feeding your Speeds April 5, 2012 Greg Brail @gbrail Brian Pagano @brianpagano
  • 2. @gbrail @brianpagano
  • 5. New! IRC Channel #api-craft on freenode
  • 6. What is scale to an API? Developers: Lots of developers building apps Apps: Lots of apps for end users to use End users: Millions and millions of app users Versions: Lots of API versions to manage API calls: All of these things result in API calls…
  • 7. Today’s Topic: API Calls Today we are going to focus on handling huge numbers of API calls in an API infrastructure Ever been in a meeting where someone said, “let’s not talk about ‘speeds and feeds’ today?” This is not that meeting.
  • 8. Why do APIs need to scale? Thousands of app developers… Each one must be managed, signed up, etc. Thousands of apps… Each one has credentials that need to be validated Millions of end users… Each one has one or more OAuth access tokens Result in lots of API calls. For example: One million end users, Making 1000 API calls a day, Results in one billion API calls a day, Or about 11,000 API calls per second on average
  • 9. Tracking API calls Today we’ll mainly talk about throughput Measured in API calls or transactions per second (tps) For an API, usually as the number of users increases, throughput increases As throughput increases, latency often increases too It’s not enough just to handle lots of throughput – it’s important to handle it with a reasonable amount of latency
  • 10. What Limits Scale? Disk Database Network App server CPU API Proxy Memory Load balancer Cache servers
  • 11. What are some limits? Seek time Database design & tuning Rotational speed App server coding & config Transfer speed Proxy configuration Clock speed Load balancer policies Number of cores Cache configuration Amount of RAM And many more…
  • 12. Some examples We’re going to talk about things to look at as throughput grows from one level of traffic to another… 1 tps 10 tps 100 tps 1000 tps 10,000 tps 100,000 tps and beyond…..
  • 14. At 1 transaction per second 86,400 per day / 2.5 million per month Almost everything can handle this. What about the database? If each API call makes several big SQL queries, it may not!
  • 15. Strategies for 1 tps Test (always) Tune the database installation Tune the database design Monitor query performance Test again!
  • 17. At 10 transactions per second 864,000 per day / 25 million per month Most infrastructure can still handle this. What about the application server? Is the app well-designed enough? Does it make an excessive number of database calls?
  • 18. Strategies for 10 tps Ensure that the app server is properly optimized Do API calls make the minimum number of database calls? Do API calls depend on large numbers of external services?
  • 20. At 100 transactions per second 8.6 million per day / 259 million per month (Now we are starting to get somewhere) RDBMS systems may struggle Less-efficient app servers may struggle “Free” tiers on hosting platforms aren’t an option
  • 21. Strategies for 100 tps Database optimization and tuning is critical here Allocate fast storage, and lots of it Allocate lots of memory Tune the database to use it! Find bad queries and fix them or optimize them App server tuning is critical here Are there enough threads in the thread pool? Are there enough processes?
  • 23. At 1000 transactions per second 86 million per day / 2.5 billion per month Now everything may start to break… What is the mix between reads and writes?
  • 24. Strategies for 1000 tps Understand the mix between reads and writes Cache the reads as much as you can If you can cache them closer to the client, better Understand your app server performance Faster app servers should still be able to handle (like Java) RoR, Python, PHP, etc will require much bigger clusters Stateless app servers are your friend!
  • 25. More strategies for 1000 tps Can the database handle the load? It can if most transactions are reads And you cache as much as you can Otherwise it’s time to scale the database layer Sharded RDBMSes Or a scalable NoSQL database works here
  • 26. At 10,000 transactions per second 864 million per day / 25 billion per month If most transactions are reads, caching is your friend Otherwise, this is serious business No single database can handle this Few single app servers can handle this If API calls are large, what will the bandwidth be?
  • 27. Strategies for 10,000 tps Caching is even more essential Even a simple cache can handle this load on one or two boxes Database writes are problematic No single database server can write 10,000 times per second Scalable, eventually-consistent databases can scale this big, (like Cassandra)
  • 28. More for 10,000 App servers You’ll need a cluster of app servers no matter what! What about session management? What about load balancing?
  • 29. 100,000 API calls per second 8.6 billion per day! Now your API is truly impressive (either that or it is very poorly designed!) You will need racks of infrastructure no matter what!
  • 30. Some other considerations API design Client design Latency Bandwidth
  • 31. What about API design? Every API call has overhead: TCP connection / SSL handshake / load balancer CPU / API proxy CPU / App server CPU and thread pool / database connections / disk I/O… Do you need to make so many? Can you design your APIs to support fewer high-value API calls? Can you have “batch” calls in your API?
  • 32. What about the client? Can client apps use the API more efficiently? Don’t make the same API calls over and over Utilize compression Utilize conditional requests in HTTP Which means that the API server should support them! Request only the data that’s needed Which means that the API server should trim responses Or paginate them
  • 33. What about latency? Latency kills user experience! How can the API server reduce it? Remove steps in the processing flow through caching Cache closer to the API clients
  • 34. What about the network? What kind of network connection to you have? For instance, in EC2 you get 1Gbps, Or about 122 megabytes / second At 10,000 tps, for instance, that’s 12K per API call
  • 35. THANK YOU Questions and ideas to: @gbrail @brianpagano

Editor's Notes

  1. Creative Commons Attribution-Share Alike 3.0 United States License