SlideShare a Scribd company logo
1 of 33
500Startups
Giving  a talk about ou   r APIs and our
sc ale to the visitin g 500Startups
class.
28 Mar via Twitter for iPhone



  from Twitter
  795 Folsom Street
  San Francisco, CA
   View Tweets at this place
>750K client applications +
Officially Owned and Operated
Twitter is just three things:
Tweets,relationships between those three
And the users, anD Timelines
What is the TwitterAPI?
REST API
- provides basic Twitter functionality
- Read / Write (Tweet, Follow, DM, etc.)

Search API
- real-time search index

Streaming API
- HTTP long poll connection
- Tweets in real-time
Using the system


   10B API calls       115,000 calls
        per day    ≈   per second
Three main objects

Status Objects - the Tweet (text, author, and metadata)
User objects - username, screen name, avatar
Timelines - orderings of Tweets
Quick note on timelines

user - a the tweets a given user has authored
home - the main timeline you would see in a client
Mentions - all the tweets that @mention a user
Causing change

Tweeting - a POST to status/update
Following - a POST to friendships/create
DM-ing - a POST to direct_messages/new
Authentication
OAuth 1.0a
- signature based requests
- user driven access to the API
- client differentiated access to the API

Applications don’t have passwords
- applications store tokens for their users
- users can change passwords, but tokens still work

OAuth 2.0
- coming soon!
Limits
350 OAuth calls / user / hour / IP
- authenticated calls goes against calling user
- unauthenticated calls goes against calling IP

“Natural” limits
- limits on number of Tweets / DMs sent
- limits on number of follows / unfollows a day

Status Limits
- can’t send “duplicate” tweets
Streaming API
Persistent connections
- get pushed a tweet, in real-time, that matches your predicate
- “push” version of search
- read-only

User streams / Site streams
- re-create the client experience using streams
- great for “client” experiences
Latency

200ms

100ms

 0ms
Streaming API’s Track and follow
Track
- watch a particular keyword
- up to 200 can be sent

Follow
- get all the tweets (RTs, etc.) from a particular user
- up to 400 can be issued
Tools of the Trade
dev.twitter.com
- documentation central

twurl
- OAuth enabled version of curl
- allows you to manually test authenticated and unauthenticated REST

Twitter for Mac
- built in “developer console”
Is that it? ... YES! ... sorta ...
things get more complicated at scale
And scaling “real-time” is hard
How many Tweets are there?
How many Tweets are there?   140M!



                             off the chart
140M tweets       1600 tweets
    per day   ≈   per second
Tweets multiply




                   8,080 people
                  need to see my
                           tweet
@ladygaga
mother mons†er
8.9 million followers

@justinbieber
Justin Bieber
8.3 million followers

@BarackObama
44th President of the United States
7.1 million followers

@raffi
me!
8.5 thousand followers
@ladygaga
       mother mons†er
       8.9 million followers

       @raffi
       me!
       8.5 thousand followers



                     30,000 tweets
1 tweet from
               ≈ 10
         scaling for delivered
1000x more followers
  @ladygaga
                       6than me

                     per second
A System is only as strong as its
weakest link
200M registered users




       2006    2008     2010   2011
Lots of deliveries
MySQL
         Can’t generate IDs fast enough
Centralized and a single point of failure




                                     snowflake
                                    Highly available and uncoordinated (10kqps)
                                    Compatible with the           ecosystem
                                    http://github.com/twitter/snowflake
Photo used under Creative Commons from jurvetson




          Distributed graph database

flockdb   High rate of CRUD operations
          Complex set arithmetic queries
          http://github.com/twitter/flockdb
Follow me at
Questions?   twitter.com/raffi

More Related Content

Similar to 500Startups @ Twitter

Facebook, Robert Johnson
Facebook, Robert JohnsonFacebook, Robert Johnson
Facebook, Robert Johnson
Fuenteovejuna
 

Similar to 500Startups @ Twitter (20)

Twitter Awesomeness
Twitter AwesomenessTwitter Awesomeness
Twitter Awesomeness
 
[System design] Design a tweeter-like system
[System design] Design a tweeter-like system[System design] Design a tweeter-like system
[System design] Design a tweeter-like system
 
Twitter System Design
Twitter System DesignTwitter System Design
Twitter System Design
 
Evolution of The Twitter Stack
Evolution of The Twitter StackEvolution of The Twitter Stack
Evolution of The Twitter Stack
 
Social Media Data
Social Media DataSocial Media Data
Social Media Data
 
Twitter - Guest Lecture UC Berkeley CS10 Fall 2010
Twitter - Guest Lecture UC Berkeley CS10 Fall 2010Twitter - Guest Lecture UC Berkeley CS10 Fall 2010
Twitter - Guest Lecture UC Berkeley CS10 Fall 2010
 
Stringcast Open
Stringcast OpenStringcast Open
Stringcast Open
 
Hotspot: Openness and API's
Hotspot: Openness and API'sHotspot: Openness and API's
Hotspot: Openness and API's
 
Scaling Microblogging Services with Divergent Traffic Demands
Scaling Microblogging Services with Divergent Traffic DemandsScaling Microblogging Services with Divergent Traffic Demands
Scaling Microblogging Services with Divergent Traffic Demands
 
Real-Time Web Apps & .NET - What are your options?
Real-Time Web Apps & .NET - What are your options?Real-Time Web Apps & .NET - What are your options?
Real-Time Web Apps & .NET - What are your options?
 
Twitter by the Numbers
Twitter by the NumbersTwitter by the Numbers
Twitter by the Numbers
 
Seattle bot + Twitter data prezo
Seattle bot + Twitter data prezoSeattle bot + Twitter data prezo
Seattle bot + Twitter data prezo
 
Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013Twitter API, Streaming and SharePoint 2013
Twitter API, Streaming and SharePoint 2013
 
Semantic Web Science
Semantic Web ScienceSemantic Web Science
Semantic Web Science
 
Facebook, Robert Johnson
Facebook, Robert JohnsonFacebook, Robert Johnson
Facebook, Robert Johnson
 
We are losing our tweets!
We are losing our tweets!We are losing our tweets!
We are losing our tweets!
 
Twarfing: Malicious Tweets
Twarfing: Malicious TweetsTwarfing: Malicious Tweets
Twarfing: Malicious Tweets
 
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
 
Solbase & Real-time Activity
Solbase & Real-time ActivitySolbase & Real-time Activity
Solbase & Real-time Activity
 
Web 2
Web 2Web 2
Web 2
 

More from Raffi Krikorian

Twitter: Engineering for Real-Time (Stanford ACM 2011)
Twitter: Engineering for Real-Time (Stanford ACM 2011)Twitter: Engineering for Real-Time (Stanford ACM 2011)
Twitter: Engineering for Real-Time (Stanford ACM 2011)
Raffi Krikorian
 
Developing for @twitterapi (Techcrunch Disrupt Hackathon)
Developing for @twitterapi (Techcrunch Disrupt Hackathon)Developing for @twitterapi (Techcrunch Disrupt Hackathon)
Developing for @twitterapi (Techcrunch Disrupt Hackathon)
Raffi Krikorian
 
Intro to developing for @twitterapi
Intro to developing for @twitterapiIntro to developing for @twitterapi
Intro to developing for @twitterapi
Raffi Krikorian
 
"What's Happening" to "What's Happening Here" @ Chirp
"What's Happening" to "What's Happening Here" @ Chirp"What's Happening" to "What's Happening Here" @ Chirp
"What's Happening" to "What's Happening Here" @ Chirp
Raffi Krikorian
 
WattzOn @ ETech 2009
WattzOn @ ETech 2009WattzOn @ ETech 2009
WattzOn @ ETech 2009
Raffi Krikorian
 

More from Raffi Krikorian (20)

Hacking Conway's Law
Hacking Conway's LawHacking Conway's Law
Hacking Conway's Law
 
Re-architecting on the Fly #OReillySACon
Re-architecting on the Fly #OReillySACon Re-architecting on the Fly #OReillySACon
Re-architecting on the Fly #OReillySACon
 
Real-time systems at Twitter (Velocity 2012)
Real-time systems at Twitter (Velocity 2012)Real-time systems at Twitter (Velocity 2012)
Real-time systems at Twitter (Velocity 2012)
 
Twitter: Engineering for Real-Time (Stanford ACM 2011)
Twitter: Engineering for Real-Time (Stanford ACM 2011)Twitter: Engineering for Real-Time (Stanford ACM 2011)
Twitter: Engineering for Real-Time (Stanford ACM 2011)
 
Developing for @twitterapi (Techcrunch Disrupt Hackathon)
Developing for @twitterapi (Techcrunch Disrupt Hackathon)Developing for @twitterapi (Techcrunch Disrupt Hackathon)
Developing for @twitterapi (Techcrunch Disrupt Hackathon)
 
#rtgeo (Where 2.0 2011)
#rtgeo (Where 2.0 2011)#rtgeo (Where 2.0 2011)
#rtgeo (Where 2.0 2011)
 
Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)Twitter by the Numbers (Columbia University)
Twitter by the Numbers (Columbia University)
 
Users and Geo
Users and GeoUsers and Geo
Users and Geo
 
Twitter and the Real-Time Web
Twitter and the Real-Time WebTwitter and the Real-Time Web
Twitter and the Real-Time Web
 
Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)Intro to developing for @twitterapi (updated)
Intro to developing for @twitterapi (updated)
 
How to use Geolocation in your webapp @ FOWA Dublin 2010
How to use Geolocation in your webapp @ FOWA Dublin 2010How to use Geolocation in your webapp @ FOWA Dublin 2010
How to use Geolocation in your webapp @ FOWA Dublin 2010
 
Intro to developing for @twitterapi
Intro to developing for @twitterapiIntro to developing for @twitterapi
Intro to developing for @twitterapi
 
Twitter API Annotations
Twitter API AnnotationsTwitter API Annotations
Twitter API Annotations
 
"What's Happening" to "What's Happening Here" @ Chirp
"What's Happening" to "What's Happening Here" @ Chirp"What's Happening" to "What's Happening Here" @ Chirp
"What's Happening" to "What's Happening Here" @ Chirp
 
Energy / Tweet
Energy / TweetEnergy / Tweet
Energy / Tweet
 
Handling Real-time Geostreams
Handling Real-time GeostreamsHandling Real-time Geostreams
Handling Real-time Geostreams
 
Adding the "Where" to the "When"
Adding the "Where" to the "When"Adding the "Where" to the "When"
Adding the "Where" to the "When"
 
What's happening here?
What's happening here?What's happening here?
What's happening here?
 
WattzOn @ ETech 2009
WattzOn @ ETech 2009WattzOn @ ETech 2009
WattzOn @ ETech 2009
 
Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....Scala + WattzOn, sitting in a tree....
Scala + WattzOn, sitting in a tree....
 

Recently uploaded

Recently uploaded (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

500Startups @ Twitter

  • 2. Giving a talk about ou r APIs and our sc ale to the visitin g 500Startups class. 28 Mar via Twitter for iPhone from Twitter 795 Folsom Street San Francisco, CA View Tweets at this place
  • 3. >750K client applications + Officially Owned and Operated
  • 4. Twitter is just three things: Tweets,relationships between those three And the users, anD Timelines
  • 5. What is the TwitterAPI? REST API - provides basic Twitter functionality - Read / Write (Tweet, Follow, DM, etc.) Search API - real-time search index Streaming API - HTTP long poll connection - Tweets in real-time
  • 6. Using the system 10B API calls 115,000 calls per day ≈ per second
  • 7. Three main objects Status Objects - the Tweet (text, author, and metadata) User objects - username, screen name, avatar Timelines - orderings of Tweets
  • 8. Quick note on timelines user - a the tweets a given user has authored home - the main timeline you would see in a client Mentions - all the tweets that @mention a user
  • 9. Causing change Tweeting - a POST to status/update Following - a POST to friendships/create DM-ing - a POST to direct_messages/new
  • 10. Authentication OAuth 1.0a - signature based requests - user driven access to the API - client differentiated access to the API Applications don’t have passwords - applications store tokens for their users - users can change passwords, but tokens still work OAuth 2.0 - coming soon!
  • 11. Limits 350 OAuth calls / user / hour / IP - authenticated calls goes against calling user - unauthenticated calls goes against calling IP “Natural” limits - limits on number of Tweets / DMs sent - limits on number of follows / unfollows a day Status Limits - can’t send “duplicate” tweets
  • 12. Streaming API Persistent connections - get pushed a tweet, in real-time, that matches your predicate - “push” version of search - read-only User streams / Site streams - re-create the client experience using streams - great for “client” experiences
  • 14. Streaming API’s Track and follow Track - watch a particular keyword - up to 200 can be sent Follow - get all the tweets (RTs, etc.) from a particular user - up to 400 can be issued
  • 15. Tools of the Trade dev.twitter.com - documentation central twurl - OAuth enabled version of curl - allows you to manually test authenticated and unauthenticated REST Twitter for Mac - built in “developer console”
  • 16. Is that it? ... YES! ... sorta ...
  • 17. things get more complicated at scale And scaling “real-time” is hard
  • 18. How many Tweets are there?
  • 19. How many Tweets are there? 140M! off the chart
  • 20. 140M tweets 1600 tweets per day ≈ per second
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Tweets multiply 8,080 people need to see my tweet
  • 26. @ladygaga mother mons†er 8.9 million followers @justinbieber Justin Bieber 8.3 million followers @BarackObama 44th President of the United States 7.1 million followers @raffi me! 8.5 thousand followers
  • 27. @ladygaga mother mons†er 8.9 million followers @raffi me! 8.5 thousand followers 30,000 tweets 1 tweet from ≈ 10 scaling for delivered 1000x more followers @ladygaga 6than me per second
  • 28. A System is only as strong as its weakest link
  • 29. 200M registered users 2006 2008 2010 2011
  • 31. MySQL Can’t generate IDs fast enough Centralized and a single point of failure snowflake Highly available and uncoordinated (10kqps) Compatible with the ecosystem http://github.com/twitter/snowflake
  • 32. Photo used under Creative Commons from jurvetson Distributed graph database flockdb High rate of CRUD operations Complex set arithmetic queries http://github.com/twitter/flockdb
  • 33. Follow me at Questions? twitter.com/raffi