SlideShare a Scribd company logo
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 (20)

PPTX
Windows Azure Virtual Machines
Clint Edmonson
 
PDF
Apache Kafka vs. Cloud-native iPaaS Integration Platform Middleware
Kai Wähner
 
PDF
OpenShift 4, the smarter Kubernetes platform
Kangaroot
 
PDF
Open shift 4 infra deep dive
Winton Winton
 
PDF
락플레이스 OpenShift Q&A 토크쇼 발표자료
rockplace
 
PDF
API Platform: A Framework for API-driven Projects
Les-Tilleuls.coop
 
PDF
IoT Architectures for Apache Kafka and Event Streaming - Industry 4.0, Digita...
Kai Wähner
 
PDF
Aws Architecture Fundamentals
2nd Watch
 
PPTX
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Riccardo Zamana
 
PDF
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
PPTX
Azure API Management
Daniel Toomey
 
PDF
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
QAware GmbH
 
PDF
Agile Integration eBook from 2018
Kim Clark
 
PPTX
A cheapskate's guide to Azure - Øredev 2022
Karl Syvert Løland
 
PPTX
Azure fundamentals
Raju Kumar
 
PPTX
Introduction to openshift
MamathaBusi
 
PPTX
Introduction to FIWARE Cloud & Context Broker
Fermin Galan
 
PDF
Shaping serverless architecture with domain driven design patterns
Asher Sterkin
 
PDF
Managing traffic routing with istio and envoy workshop
Opsta
 
PDF
Oracle api gateway overview
Oracle Corporation
 
Windows Azure Virtual Machines
Clint Edmonson
 
Apache Kafka vs. Cloud-native iPaaS Integration Platform Middleware
Kai Wähner
 
OpenShift 4, the smarter Kubernetes platform
Kangaroot
 
Open shift 4 infra deep dive
Winton Winton
 
락플레이스 OpenShift Q&A 토크쇼 발표자료
rockplace
 
API Platform: A Framework for API-driven Projects
Les-Tilleuls.coop
 
IoT Architectures for Apache Kafka and Event Streaming - Industry 4.0, Digita...
Kai Wähner
 
Aws Architecture Fundamentals
2nd Watch
 
Time series Analytics - a deep dive into ADX Azure Data Explorer @Data Saturd...
Riccardo Zamana
 
Designing a complete ci cd pipeline using argo events, workflow and cd products
Julian Mazzitelli
 
Azure API Management
Daniel Toomey
 
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
QAware GmbH
 
Agile Integration eBook from 2018
Kim Clark
 
A cheapskate's guide to Azure - Øredev 2022
Karl Syvert Løland
 
Azure fundamentals
Raju Kumar
 
Introduction to openshift
MamathaBusi
 
Introduction to FIWARE Cloud & Context Broker
Fermin Galan
 
Shaping serverless architecture with domain driven design patterns
Asher Sterkin
 
Managing traffic routing with istio and envoy workshop
Opsta
 
Oracle api gateway overview
Oracle Corporation
 

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

PDF
Is your API Naked? API Technology and Ops Considerations: Webinar slides
Apigee | Google Cloud
 
PDF
The ultimate api checklist by Blendr.io
Blendr.io
 
PDF
How to Design Scalable and Secure APIs: Essential Considerations for 2025
ScalaCode
 
PDF
Building a Great Web API - Evan Cooke - QCON 2011
Twilio Inc
 
PDF
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias
 
PDF
Designing your API Server for mobile apps
Mugunth Kumar
 
PDF
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
PDF
Five Ways to Scale your API Without Touching Your Code
3scale
 
PDF
JOSA TechTalks - RESTful API Concepts and Best Practices
Jordan Open Source Association
 
PPTX
A great api is hard to find
Dan Diephouse
 
PDF
Creating a RESTful api without losing too much sleep
Mike Anderson
 
PDF
Consumer centric api design v0.4.0
mustafa sarac
 
PDF
Architectural considerations when building an API
Rod Hemphill
 
PPTX
Microservices architecture overview v2
Dmitry Skaredov
 
PDF
Modern REST API design principles and rules.pdf
Aparna Sharma
 
PPTX
Api Design
Jason Harmon
 
KEY
Social dev camp_2011
Craig Ulliott
 
PDF
Mobile apps & Server Apis, the weak link? par Emanuele Pecorari
Olivier DASINI
 
PDF
Modern REST API design principles and rules.pdf
Aparna Sharma
 
PDF
Architecting &Building Scalable Secure Web API
SHAKIL AKHTAR
 
Is your API Naked? API Technology and Ops Considerations: Webinar slides
Apigee | Google Cloud
 
The ultimate api checklist by Blendr.io
Blendr.io
 
How to Design Scalable and Secure APIs: Essential Considerations for 2025
ScalaCode
 
Building a Great Web API - Evan Cooke - QCON 2011
Twilio Inc
 
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias
 
Designing your API Server for mobile apps
Mugunth Kumar
 
Service-Oriented Design and Implement with Rails3
Wen-Tien Chang
 
Five Ways to Scale your API Without Touching Your Code
3scale
 
JOSA TechTalks - RESTful API Concepts and Best Practices
Jordan Open Source Association
 
A great api is hard to find
Dan Diephouse
 
Creating a RESTful api without losing too much sleep
Mike Anderson
 
Consumer centric api design v0.4.0
mustafa sarac
 
Architectural considerations when building an API
Rod Hemphill
 
Microservices architecture overview v2
Dmitry Skaredov
 
Modern REST API design principles and rules.pdf
Aparna Sharma
 
Api Design
Jason Harmon
 
Social dev camp_2011
Craig Ulliott
 
Mobile apps & Server Apis, the weak link? par Emanuele Pecorari
Olivier DASINI
 
Modern REST API design principles and rules.pdf
Aparna Sharma
 
Architecting &Building Scalable Secure Web API
SHAKIL AKHTAR
 
Ad

More from Apigee | Google Cloud (20)

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

Recently uploaded (20)

PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
Designing Production-Ready AI Agents
Kunal Rai
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
PDF
Advancing WebDriver BiDi support in WebKit
Igalia
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
Designing Production-Ready AI Agents
Kunal Rai
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Future Tech Innovations 2025 – A TechLists Insight
TechLists
 
Advancing WebDriver BiDi support in WebKit
Igalia
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 

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

  • #2: Creative Commons Attribution-Share Alike 3.0 United States License