SlideShare une entreprise Scribd logo
1  sur  54
Fixing Twitter
... and Finding your own Fail Whale




            John Adams
        Twitter Operations
        <jna@twitter.com>
Operations
• Small team, growing rapidly.
• What do we do?
 • Software Performance (back-end)
 • Availability
 • Capacity Planning (metrics-driven)
 • Configuration Management
• We don’t deal with the physical plant.
Managed Services
• Dedicated team (NTTA)
• 24/7 Hands on remote support
• No clouds. We tried that!
 • Need raw processing power, latency too
     high in existing cloud offerings
• Frees us to deal with real, intellectual,
  computer science problems.
752%
2008 Growth




              Unique Visitors (in Millions)
752%
2008 Growth
           5



         3.75



          2.5



         1.25



           0
                Dec 07    Feb 08   Apr 08       Jun 08   Aug 08   Oct 08 Dec 08
                Unique Visitors (in Millions)
That was only the beginning...




previous
 graph!
Uniques




 Not slowing down, despite what outsiders say.
  Hard for outsiders to measure API usage!
Growth = Pain
 + an appreciation for Institutionalized Fear
Mantra!


   Find Weakest
       Point




   Metrics +
Logs + Science =
    Analysis
Mantra!


   Find Weakest    Take Corrective
       Point           Action




   Metrics +         Process
Logs + Science =
    Analysis
Mantra!


   Find Weakest    Take Corrective    Move to Next
       Point           Action         Weakest Point




   Metrics +         Process         Repeatability
Logs + Science =
    Analysis
Find the Weakest Point

  • Metrics + Graphs
   • Individual metrics are irrelevant
  • Logs
  • SCIENCE!
  • Find out what the actionable items are.
Instrument Everything




                        (cc) seenoevil@flickr
Monitoring

 • Graph and report critical metrics in as near
   real time as possible
 • You already have the tools.
  • RRD
  • Ganglia + custom gMetric scripts
  • MRTG
Dashboards
 • “Criticals” view
 • Smokeping/MRTG
 • Google Analytics
  • Not just for
     HTTP 200s/SEO
 • XML Feeds from
   managed services
 • Data Porn!
Analyze
  • Turn data into information
   • Where is the code base going?
   • Are things worse than they were?
     • Understand the impact of the last
        software deploy
      • Run check scripts during and after
        deploys
  • Capacity Planning, not Fire Fighting!
Forecasting                   Curve-fitting for capacity planning
                               (R, fityk, Mathematica, CurveFit)



              unsigned int (32 bit)
                Twitpocolypse



  status_id

                                      signed int (32 bit)
                                        Twitpocolypse




                                                  r2=0.99
Deploys

  • Graph time-of-deploy along side server
      CPU and Latency
  • Display time-of-last-deploy on dashboard


 last deploy times
Whale-Watcher
•   Simple shell script,
    •   MASSIVE WIN.
•   Whale = HTTP 503 (timeout)
•   Robot = HTTP 500 (error)
•   Examines last 100,000 lines of aggregated
    daemon / www logs
•   “Whales per Second” > Wthreshold
    •   Thar be whales! Call in ops.
Take Action !
Feature “Darkmode”
 • Specific site controls to enable and
   disable computationally or IO-Heavy site
   function
 • The “Emergency Stop” button
 • Changes logged and reported to all teams
 • Around 60 switches we can throw
 • Static / Read-only mode
Configuration
Management
• Start automated configuration management
  EARLY in your company.
• Don’t wait until it’s too late.
• Twitter started within the first few months.
Configuration
Management
   • Complex Environment
   • Multiple Admins
   • Unknown Interactions
   • Solution: 2nd set of eyes.
Process through Reviews
Reviewboard
         www.review-board.org

 • SVN pre-commit hook causes a failure if
   the log message doesn’t include
   ‘reviewed’
 • SVN post-commit hook informs people
   what changed via email
 • Watches the entire SVN tree
Improve
Communication


                Campfire
Subsystems
Many limiting factors in the request pipeline

        Apache                      Rails
      MPM Model                  (mongrel)
      MaxClients            2:1 oversubscribed
 TCP Listen queue depth
                                  to cores

                                 Memcached
                                # connections


                                    MySQL
   Varnish (search)            # db connections
      # threads
Make an attack plan.
 Symptom    Bottleneck      Vector       Solution

                            HTTP
Bandwidth   Network                     Servers++
                           Latency
                                          Better
 Timeline   Database     Update Delay
                                        algorithm
                                         DBs++
  Search    Database        Delays
                                          Code
 Updates    Algorithm      Latency      Algorithms
Make an attack plan.
 Symptom    Bottleneck      Vector       Solution

                            HTTP
Bandwidth   Network                     Servers++
                           Latency
                                          Better
 Timeline   Database     Update Delay
                                        algorithm
                                         DBs++
  Search    Database        Delays
                                          Code
 Updates    Algorithm      Latency      Algorithms
Make an attack plan.
 Symptom    Bottleneck      Vector       Solution

                            HTTP
Bandwidth   Network                     Servers++
                           Latency
                                          Better
 Timeline   Database     Update Delay
                                        algorithm
                                         DBs++
  Search    Database        Delays
                                          Code
 Updates    Algorithm      Latency      Algorithms
Make an attack plan.
 Symptom    Bottleneck      Vector       Solution

                            HTTP
Bandwidth   Network                     Servers++
                           Latency
                                          Better
 Timeline   Database     Update Delay
                                        algorithm
                                         DBs++
  Search    Database        Delays
                                          Code
 Updates    Algorithm      Latency      Algorithms
Make an attack plan.
 Symptom    Bottleneck      Vector       Solution

                            HTTP
Bandwidth   Network                     Servers++
                           Latency
                                          Better
 Timeline   Database     Update Delay
                                        algorithm
                                         DBs++
  Search    Database        Delays
                                          Code
 Updates    Algorithm      Latency      Algorithms
CPU: More with Less
• Reduction in 40% of CPU by replacing dual
  and quad core machines with 8 core
• Switching from AMD to Intel Xeon = 30%
  gain
• Saved data center space, power, cost per
  month.
• Not the best option if you own machines.
  Capital expenditure = hard to realize new
  technology gains.
Rails
• Stop blaming Rails.
• Analysis found:
 • Caching + Cache invalidation problems
 • Bad queries generated by ActiveRecord,
    resulting in slow queries against the db
 • Queue Latency
 • Memcache / Page Cache Corruption
 • Replication Lag
Disk is the new Tape.
• Social Networking application profile has
  many   O(ny)   operations.
• Page requests have to happen in < 500mS
  or users start to notice. Goal: 250-300mS
• Web 2.0 isn’t possible without lots of RAM
• What to do?
Caching
  • We’re the real-time web, but lots of caching
    opportunity
  • Most caching strategies rely on long TTLs
    (>60 s)
  • Separate memcache pools for different data
    types to prevent eviction
  • Optimize Ruby Gem to libmemcached +
    FNV Hash instead of Ruby + MD5
  • Twitter now largest contributor to
    libmemcached
Caching   50% decrease in load with Native C
                gem + libmemcached
Cache Money!
• Active Record Plugin
 • Cache when reading from the DB
 • Cache when writing to the DB
• Transparently provides caching
 • Removes need for set/get cache code
 • Open Source!
Caching

 • “Cache Everything!” not the best policy
 • Invalidating caches at the right time is
   difficult.
 • Cold Cache problem
 • Network Memory Bus != Infinite
Memcached
• memcached isn’t perfect.
 • Memcached SEGVs hurt us early on.
• Evictions make the cache unreliable for
  important configuration data
  (loss of darkmode flags, for example)
• Data and Hash Corruption (even in 1.2.6)
 • Exposed corruption issue with specific
    inputs causing SEGV and unexpected
    behavior
API + Caching (search)
• Cache and control abusive clients
• Varnish between two Apache Virtual Hosts
  (failover to another backend if Varnish
  dies)
• Remove Cache busting query strings before
  applying hash algorithm
• Using ESI to cache jQuery requests when
  specifying a callback= parameter - big win.
Relational Databases
not a Panacea
• Good for:
 • Users, Relational Data, Transactions
• Bad:
 • Queues. Polling operations. Caching.
• You don’t need ACID for everything.
• Enter the message queue...
Queues
• Many message queue solutions on the
  market
• At high loads, most perform poorly when
  used in ‘durable’ mode.
• Erlang based queues work well
  (RabbitMQ), but you need in house Erlang
  experience.
• We wrote our own.
 • Kestrel to the rescue!
Kestrel
Falco tinnunculus




  • Works like memcache (same protocol)
  • SET = enqueue | GET = dequeue
  • No strict ordering of jobs
  • No shared state between servers
  • Written in Scala.
Asynchronous
Requests
• Inbound traffic consumes a mongrel
• Outbound traffic consumes a mongrel
• The request pipeline should not be used to
  handle 3rd party communications or
  back-end work.
• Daemons, Daemons, Daemons.
Don’t make services
dependent
• Move operations out of the synchronous
  request cycle
 • Email
 • Complex object generation (timelines)
 • 3rd party services (bit.ly, sms, etc.)
Daemons
• Many different types at Twitter.
• # of daemons have to match the workload
 • Early Kestrel would crash if queues filled
• “Seppaku” patch
 • Kill daemons after n requests
• Long-running daemons = low memory
MySQL Challenges
• Replication Delay
 • Single threaded. Slow.
• Social Networking not good for RDBMS
 • N x N relationships and social graph /
    tree traversal
 • Sharding importance
 • Disk issues (FS Choice, noatime,
    scheduling algorithm)
MySQL

• Replication delay and cache eviction
  produce inconsistent results to the end
  user.
• Locks create resource contention for
  popular data
Database Replication
  • Major issues around users and statuses
    tables
  • Multiple functional masters (FRP, FWP)
  • Make sure your code reads and writes to
    the write DBs. Reading from master = slow
    death
    • Monitor the DB. Find slow / poorly
      designed queries
  • Kill long running queries before they kill
    you (mkill)
status.twitter.com

• Keep users in the loop, or suffer.
• Hosted on different service (Tumblr)
• No matter how little information you have
  available.
Key Points

• Databases not always the best store.
• Instrument everything.
• Use metrics to make decisions, not guesses.
• Don’t make services dependent
• Process asynchronously when possible
Thanks!
Twitter Open Source (Apache License):

- CacheMoney Gem (Write through Caching)
http://github.com/nkallen/cache-money/tree/master

- Libmemcached
http://tangent.org/552/libmemcached.html

- Kestrel (Memcache-like message queue)
http://github.com/robey/kestrel

- mod_memcache_block (Apache 2.x Limiter/blocker)
http://github.com/netik/mod_memcache_block

Contenu connexe

Tendances

The Real AWS Migration Opportunity
The Real AWS Migration OpportunityThe Real AWS Migration Opportunity
The Real AWS Migration OpportunityAmazon Web Services
 
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...Amazon Web Services
 
Migrating your Data Centre to AWS
Migrating your Data Centre to AWSMigrating your Data Centre to AWS
Migrating your Data Centre to AWSAmazon Web Services
 
From On-Premises to Cloud: Modernize Data Protection with Druva Phoenix and AWS
From On-Premises to Cloud:  Modernize Data Protection with Druva Phoenix and AWSFrom On-Premises to Cloud:  Modernize Data Protection with Druva Phoenix and AWS
From On-Premises to Cloud: Modernize Data Protection with Druva Phoenix and AWSAmazon Web Services
 
How to Plan a Migration to AWS: The Cox Automotive Story
 How to Plan a Migration to AWS: The Cox Automotive Story How to Plan a Migration to AWS: The Cox Automotive Story
How to Plan a Migration to AWS: The Cox Automotive StoryAmazon Web Services
 
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)Amazon Web Services
 
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...Amazon Web Services
 
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek  Mah...AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek  Mah...
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...Amazon Web Services Korea
 
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)Amazon Web Services
 
Compute Without Servers – Building Applications with AWS Lambda - Technical 301
Compute Without Servers – Building Applications with AWS Lambda - Technical 301Compute Without Servers – Building Applications with AWS Lambda - Technical 301
Compute Without Servers – Building Applications with AWS Lambda - Technical 301Amazon Web Services
 
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...Amazon Web Services
 
Amazon.com Corporate IT apps Migration to AWS
Amazon.com Corporate IT apps Migration to AWSAmazon.com Corporate IT apps Migration to AWS
Amazon.com Corporate IT apps Migration to AWSAmazon Web Services
 
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...Amazon Web Services
 
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)AWS re:Invent 2016: Cost Optimization at Scale (ENT209)
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)Amazon Web Services
 
Getting Started with Amazon Database Migration Service
Getting Started with Amazon Database Migration ServiceGetting Started with Amazon Database Migration Service
Getting Started with Amazon Database Migration ServiceAmazon Web Services
 
Mass migrations stephen orban - gartner toronto 2017
Mass migrations   stephen orban - gartner toronto 2017Mass migrations   stephen orban - gartner toronto 2017
Mass migrations stephen orban - gartner toronto 2017Amazon Web Services
 
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...Amazon Web Services
 
Migrate Enterprise Applications Framework and Guiding Principles.pdf
Migrate Enterprise Applications Framework and Guiding Principles.pdfMigrate Enterprise Applications Framework and Guiding Principles.pdf
Migrate Enterprise Applications Framework and Guiding Principles.pdfAmazon Web Services
 
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...Amazon Web Services
 

Tendances (20)

The Real AWS Migration Opportunity
The Real AWS Migration OpportunityThe Real AWS Migration Opportunity
The Real AWS Migration Opportunity
 
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...
Microservices? Dynamic Infrastructure? - Adventures in Keeping Your Applicati...
 
Migrating your Data Centre to AWS
Migrating your Data Centre to AWSMigrating your Data Centre to AWS
Migrating your Data Centre to AWS
 
From On-Premises to Cloud: Modernize Data Protection with Druva Phoenix and AWS
From On-Premises to Cloud:  Modernize Data Protection with Druva Phoenix and AWSFrom On-Premises to Cloud:  Modernize Data Protection with Druva Phoenix and AWS
From On-Premises to Cloud: Modernize Data Protection with Druva Phoenix and AWS
 
How to Plan a Migration to AWS: The Cox Automotive Story
 How to Plan a Migration to AWS: The Cox Automotive Story How to Plan a Migration to AWS: The Cox Automotive Story
How to Plan a Migration to AWS: The Cox Automotive Story
 
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)
AWS re:Invent 2016: Large-scale AWS Migrations (ENT204)
 
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
Best Practices for Data Center Migration Planning - August 2016 Monthly Webin...
 
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek  Mah...AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek  Mah...
AWS Innovate 2016- Planning a Phased Cloud Migration Strategy - Abhishek Mah...
 
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)
AWS re:Invent 2016: Saving at Scale with Reserved Instances (ENT307)
 
Compute Without Servers – Building Applications with AWS Lambda - Technical 301
Compute Without Servers – Building Applications with AWS Lambda - Technical 301Compute Without Servers – Building Applications with AWS Lambda - Technical 301
Compute Without Servers – Building Applications with AWS Lambda - Technical 301
 
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Chicago ...
 
Amazon.com Corporate IT apps Migration to AWS
Amazon.com Corporate IT apps Migration to AWSAmazon.com Corporate IT apps Migration to AWS
Amazon.com Corporate IT apps Migration to AWS
 
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...
AWS re:Invent 2016: Lift and Evolve – Saving Money in the Cloud is Easy, Maki...
 
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)AWS re:Invent 2016: Cost Optimization at Scale (ENT209)
AWS re:Invent 2016: Cost Optimization at Scale (ENT209)
 
Getting Started with Amazon Database Migration Service
Getting Started with Amazon Database Migration ServiceGetting Started with Amazon Database Migration Service
Getting Started with Amazon Database Migration Service
 
Mass migrations stephen orban - gartner toronto 2017
Mass migrations   stephen orban - gartner toronto 2017Mass migrations   stephen orban - gartner toronto 2017
Mass migrations stephen orban - gartner toronto 2017
 
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...
AWS April 2016 Webinar Series - Getting Started with Real-Time Data Analytics...
 
Migrate Enterprise Applications Framework and Guiding Principles.pdf
Migrate Enterprise Applications Framework and Guiding Principles.pdfMigrate Enterprise Applications Framework and Guiding Principles.pdf
Migrate Enterprise Applications Framework and Guiding Principles.pdf
 
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...
Migrating Databases to the Cloud: Introduction to AWS DMS - SRV215 - Atlanta ...
 
Application Migrations
Application MigrationsApplication Migrations
Application Migrations
 

En vedette

John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudyJohn Adams
 
Performance Appraisal By Core Competencies
Performance Appraisal By Core CompetenciesPerformance Appraisal By Core Competencies
Performance Appraisal By Core CompetenciesPham Ngoc
 
Personal branding
Personal brandingPersonal branding
Personal brandingPham Ngoc
 
Sentence Structure : Sentence Types
Sentence Structure : Sentence TypesSentence Structure : Sentence Types
Sentence Structure : Sentence TypesAre Fizz Qimmy
 

En vedette (6)

John adams talk cloudy
John adams   talk cloudyJohn adams   talk cloudy
John adams talk cloudy
 
Performance Appraisal By Core Competencies
Performance Appraisal By Core CompetenciesPerformance Appraisal By Core Competencies
Performance Appraisal By Core Competencies
 
Personal branding
Personal brandingPersonal branding
Personal branding
 
Twitter Tricks
Twitter TricksTwitter Tricks
Twitter Tricks
 
Jhon adams
Jhon adamsJhon adams
Jhon adams
 
Sentence Structure : Sentence Types
Sentence Structure : Sentence TypesSentence Structure : Sentence Types
Sentence Structure : Sentence Types
 

Similaire à Fixing Twitter Velocity2009

Fixing twitter
Fixing twitterFixing twitter
Fixing twitterRoger Xia
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...smallerror
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...xlight
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterJohn Adams
 
Scaling Systems: Architectures that Grow
Scaling Systems: Architectures that GrowScaling Systems: Architectures that Grow
Scaling Systems: Architectures that GrowGibraltar Software
 
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Vikas Sahni
 
Building azure applications ireland
Building azure applications irelandBuilding azure applications ireland
Building azure applications irelandMichael Meagher
 
Building FoundationDB
Building FoundationDBBuilding FoundationDB
Building FoundationDBFoundationDB
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Pythondidip
 
Donatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsDonatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsTanya Denisyuk
 
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and Scalabilty
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and ScalabiltyDocker/DevOps Meetup: Metrics-Driven Continuous Performance and Scalabilty
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and ScalabiltyAndreas Grabner
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...Javier García Magna
 
Getting Started with Real-time Analytics
Getting Started with Real-time AnalyticsGetting Started with Real-time Analytics
Getting Started with Real-time AnalyticsAmazon Web Services
 
Webinar issues we_find_slideshare
Webinar issues we_find_slideshareWebinar issues we_find_slideshare
Webinar issues we_find_slideshareSOASTA
 
Membase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase
 
AWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayAWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayEitan Sela
 
Iot meets Serverless
Iot meets ServerlessIot meets Serverless
Iot meets ServerlessNarendran R
 
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Gary Arora
 

Similaire à Fixing Twitter Velocity2009 (20)

Fixing twitter
Fixing twitterFixing twitter
Fixing twitter
 
Fixing_Twitter
Fixing_TwitterFixing_Twitter
Fixing_Twitter
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
 
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...Fixing Twitter  Improving The Performance And Scalability Of The Worlds Most ...
Fixing Twitter Improving The Performance And Scalability Of The Worlds Most ...
 
Chirp 2010: Scaling Twitter
Chirp 2010: Scaling TwitterChirp 2010: Scaling Twitter
Chirp 2010: Scaling Twitter
 
Scaling Systems: Architectures that Grow
Scaling Systems: Architectures that GrowScaling Systems: Architectures that Grow
Scaling Systems: Architectures that Grow
 
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
Building Real World Applications using Windows Azure - Scott Guthrie, 2nd Dec...
 
Building azure applications ireland
Building azure applications irelandBuilding azure applications ireland
Building azure applications ireland
 
Building FoundationDB
Building FoundationDBBuilding FoundationDB
Building FoundationDB
 
Os Solomon
Os SolomonOs Solomon
Os Solomon
 
Super Sizing Youtube with Python
Super Sizing Youtube with PythonSuper Sizing Youtube with Python
Super Sizing Youtube with Python
 
Donatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIsDonatas Mažionis, Building low latency web APIs
Donatas Mažionis, Building low latency web APIs
 
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and Scalabilty
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and ScalabiltyDocker/DevOps Meetup: Metrics-Driven Continuous Performance and Scalabilty
Docker/DevOps Meetup: Metrics-Driven Continuous Performance and Scalabilty
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
 
Getting Started with Real-time Analytics
Getting Started with Real-time AnalyticsGetting Started with Real-time Analytics
Getting Started with Real-time Analytics
 
Webinar issues we_find_slideshare
Webinar issues we_find_slideshareWebinar issues we_find_slideshare
Webinar issues we_find_slideshare
 
Membase Meetup - Silicon Valley
Membase Meetup - Silicon ValleyMembase Meetup - Silicon Valley
Membase Meetup - Silicon Valley
 
AWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-RayAWS Lambda support for AWS X-Ray
AWS Lambda support for AWS X-Ray
 
Iot meets Serverless
Iot meets ServerlessIot meets Serverless
Iot meets Serverless
 
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
Leapfrog into Serverless - a Deloitte-Amtrak Case Study | Serverless Confere...
 

Dernier

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.pptxRustici Software
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
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 FMESafe Software
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
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 WorkerThousandEyes
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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 SavingEdi Saputra
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
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?Igalia
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
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 FresherRemote DBA Services
 
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)wesley chun
 

Dernier (20)

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
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
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?
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
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
 
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)
 

Fixing Twitter Velocity2009

  • 1. Fixing Twitter ... and Finding your own Fail Whale John Adams Twitter Operations <jna@twitter.com>
  • 2. Operations • Small team, growing rapidly. • What do we do? • Software Performance (back-end) • Availability • Capacity Planning (metrics-driven) • Configuration Management • We don’t deal with the physical plant.
  • 3. Managed Services • Dedicated team (NTTA) • 24/7 Hands on remote support • No clouds. We tried that! • Need raw processing power, latency too high in existing cloud offerings • Frees us to deal with real, intellectual, computer science problems.
  • 4. 752% 2008 Growth Unique Visitors (in Millions)
  • 5. 752% 2008 Growth 5 3.75 2.5 1.25 0 Dec 07 Feb 08 Apr 08 Jun 08 Aug 08 Oct 08 Dec 08 Unique Visitors (in Millions)
  • 6. That was only the beginning... previous graph!
  • 7. Uniques Not slowing down, despite what outsiders say. Hard for outsiders to measure API usage!
  • 8. Growth = Pain + an appreciation for Institutionalized Fear
  • 9. Mantra! Find Weakest Point Metrics + Logs + Science = Analysis
  • 10. Mantra! Find Weakest Take Corrective Point Action Metrics + Process Logs + Science = Analysis
  • 11. Mantra! Find Weakest Take Corrective Move to Next Point Action Weakest Point Metrics + Process Repeatability Logs + Science = Analysis
  • 12. Find the Weakest Point • Metrics + Graphs • Individual metrics are irrelevant • Logs • SCIENCE! • Find out what the actionable items are.
  • 13. Instrument Everything (cc) seenoevil@flickr
  • 14. Monitoring • Graph and report critical metrics in as near real time as possible • You already have the tools. • RRD • Ganglia + custom gMetric scripts • MRTG
  • 15. Dashboards • “Criticals” view • Smokeping/MRTG • Google Analytics • Not just for HTTP 200s/SEO • XML Feeds from managed services • Data Porn!
  • 16. Analyze • Turn data into information • Where is the code base going? • Are things worse than they were? • Understand the impact of the last software deploy • Run check scripts during and after deploys • Capacity Planning, not Fire Fighting!
  • 17. Forecasting Curve-fitting for capacity planning (R, fityk, Mathematica, CurveFit) unsigned int (32 bit) Twitpocolypse status_id signed int (32 bit) Twitpocolypse r2=0.99
  • 18. Deploys • Graph time-of-deploy along side server CPU and Latency • Display time-of-last-deploy on dashboard last deploy times
  • 19. Whale-Watcher • Simple shell script, • MASSIVE WIN. • Whale = HTTP 503 (timeout) • Robot = HTTP 500 (error) • Examines last 100,000 lines of aggregated daemon / www logs • “Whales per Second” > Wthreshold • Thar be whales! Call in ops.
  • 21. Feature “Darkmode” • Specific site controls to enable and disable computationally or IO-Heavy site function • The “Emergency Stop” button • Changes logged and reported to all teams • Around 60 switches we can throw • Static / Read-only mode
  • 22. Configuration Management • Start automated configuration management EARLY in your company. • Don’t wait until it’s too late. • Twitter started within the first few months.
  • 23. Configuration Management • Complex Environment • Multiple Admins • Unknown Interactions • Solution: 2nd set of eyes.
  • 25. Reviewboard www.review-board.org • SVN pre-commit hook causes a failure if the log message doesn’t include ‘reviewed’ • SVN post-commit hook informs people what changed via email • Watches the entire SVN tree
  • 28. Many limiting factors in the request pipeline Apache Rails MPM Model (mongrel) MaxClients 2:1 oversubscribed TCP Listen queue depth to cores Memcached # connections MySQL Varnish (search) # db connections # threads
  • 29. Make an attack plan. Symptom Bottleneck Vector Solution HTTP Bandwidth Network Servers++ Latency Better Timeline Database Update Delay algorithm DBs++ Search Database Delays Code Updates Algorithm Latency Algorithms
  • 30. Make an attack plan. Symptom Bottleneck Vector Solution HTTP Bandwidth Network Servers++ Latency Better Timeline Database Update Delay algorithm DBs++ Search Database Delays Code Updates Algorithm Latency Algorithms
  • 31. Make an attack plan. Symptom Bottleneck Vector Solution HTTP Bandwidth Network Servers++ Latency Better Timeline Database Update Delay algorithm DBs++ Search Database Delays Code Updates Algorithm Latency Algorithms
  • 32. Make an attack plan. Symptom Bottleneck Vector Solution HTTP Bandwidth Network Servers++ Latency Better Timeline Database Update Delay algorithm DBs++ Search Database Delays Code Updates Algorithm Latency Algorithms
  • 33. Make an attack plan. Symptom Bottleneck Vector Solution HTTP Bandwidth Network Servers++ Latency Better Timeline Database Update Delay algorithm DBs++ Search Database Delays Code Updates Algorithm Latency Algorithms
  • 34. CPU: More with Less • Reduction in 40% of CPU by replacing dual and quad core machines with 8 core • Switching from AMD to Intel Xeon = 30% gain • Saved data center space, power, cost per month. • Not the best option if you own machines. Capital expenditure = hard to realize new technology gains.
  • 35. Rails • Stop blaming Rails. • Analysis found: • Caching + Cache invalidation problems • Bad queries generated by ActiveRecord, resulting in slow queries against the db • Queue Latency • Memcache / Page Cache Corruption • Replication Lag
  • 36. Disk is the new Tape. • Social Networking application profile has many O(ny) operations. • Page requests have to happen in < 500mS or users start to notice. Goal: 250-300mS • Web 2.0 isn’t possible without lots of RAM • What to do?
  • 37. Caching • We’re the real-time web, but lots of caching opportunity • Most caching strategies rely on long TTLs (>60 s) • Separate memcache pools for different data types to prevent eviction • Optimize Ruby Gem to libmemcached + FNV Hash instead of Ruby + MD5 • Twitter now largest contributor to libmemcached
  • 38. Caching 50% decrease in load with Native C gem + libmemcached
  • 39. Cache Money! • Active Record Plugin • Cache when reading from the DB • Cache when writing to the DB • Transparently provides caching • Removes need for set/get cache code • Open Source!
  • 40. Caching • “Cache Everything!” not the best policy • Invalidating caches at the right time is difficult. • Cold Cache problem • Network Memory Bus != Infinite
  • 41. Memcached • memcached isn’t perfect. • Memcached SEGVs hurt us early on. • Evictions make the cache unreliable for important configuration data (loss of darkmode flags, for example) • Data and Hash Corruption (even in 1.2.6) • Exposed corruption issue with specific inputs causing SEGV and unexpected behavior
  • 42. API + Caching (search) • Cache and control abusive clients • Varnish between two Apache Virtual Hosts (failover to another backend if Varnish dies) • Remove Cache busting query strings before applying hash algorithm • Using ESI to cache jQuery requests when specifying a callback= parameter - big win.
  • 43. Relational Databases not a Panacea • Good for: • Users, Relational Data, Transactions • Bad: • Queues. Polling operations. Caching. • You don’t need ACID for everything. • Enter the message queue...
  • 44. Queues • Many message queue solutions on the market • At high loads, most perform poorly when used in ‘durable’ mode. • Erlang based queues work well (RabbitMQ), but you need in house Erlang experience. • We wrote our own. • Kestrel to the rescue!
  • 45. Kestrel Falco tinnunculus • Works like memcache (same protocol) • SET = enqueue | GET = dequeue • No strict ordering of jobs • No shared state between servers • Written in Scala.
  • 46. Asynchronous Requests • Inbound traffic consumes a mongrel • Outbound traffic consumes a mongrel • The request pipeline should not be used to handle 3rd party communications or back-end work. • Daemons, Daemons, Daemons.
  • 47. Don’t make services dependent • Move operations out of the synchronous request cycle • Email • Complex object generation (timelines) • 3rd party services (bit.ly, sms, etc.)
  • 48. Daemons • Many different types at Twitter. • # of daemons have to match the workload • Early Kestrel would crash if queues filled • “Seppaku” patch • Kill daemons after n requests • Long-running daemons = low memory
  • 49. MySQL Challenges • Replication Delay • Single threaded. Slow. • Social Networking not good for RDBMS • N x N relationships and social graph / tree traversal • Sharding importance • Disk issues (FS Choice, noatime, scheduling algorithm)
  • 50. MySQL • Replication delay and cache eviction produce inconsistent results to the end user. • Locks create resource contention for popular data
  • 51. Database Replication • Major issues around users and statuses tables • Multiple functional masters (FRP, FWP) • Make sure your code reads and writes to the write DBs. Reading from master = slow death • Monitor the DB. Find slow / poorly designed queries • Kill long running queries before they kill you (mkill)
  • 52. status.twitter.com • Keep users in the loop, or suffer. • Hosted on different service (Tumblr) • No matter how little information you have available.
  • 53. Key Points • Databases not always the best store. • Instrument everything. • Use metrics to make decisions, not guesses. • Don’t make services dependent • Process asynchronously when possible
  • 54. Thanks! Twitter Open Source (Apache License): - CacheMoney Gem (Write through Caching) http://github.com/nkallen/cache-money/tree/master - Libmemcached http://tangent.org/552/libmemcached.html - Kestrel (Memcache-like message queue) http://github.com/robey/kestrel - mod_memcache_block (Apache 2.x Limiter/blocker) http://github.com/netik/mod_memcache_block

Notes de l'éditeur

  1. What are we going to talk about? We&amp;#x2019;re going to talk about fixing twitter, but we&amp;#x2019;re also going to talk about how you can apply what we&amp;#x2019;ve done to your site.
  2. talk about architecture but (amazon sqs vs kestrel.. microseconds in kestrel) 250mS obsession w/ instant retry No clouds, but we still use S3.
  3. Since then we&amp;#x2019;ve experienced phenomenal growth
  4. Of course, how do you find these points? You need instrumentation. Every metric you can get your hands on needs to be graphed and recorded at reasonable rates that do not cause harm to the running environemnt
  5. Unless detrimental to performance!
  6. We have one of these, do you?
  7. talk about the status ID problem Don&amp;#x2019;t be afraid to go to the scientific / statistical side of the company Can do this with disk space, network bandwidth, anything. stats = good
  8. Talk about why we whale. Whale vs. timeout vs
  9. talk about automated configuration management talk
  10. Alternatives are immature, or complex. Lots of people
  11. talk about cpu contention. apache cannot be allowed to overload rails, there are limits. Everyone has a listen queue. When they overload, you get waits. How much wait can you deal with?
  12. moore&amp;#x2019;s law = 12.5% year on year as we refresh hardware
  13. so now, where are you going to store all this data?
  14. Facebook&amp;#x2019;s memcache isn&amp;#x2019;t much better.
  15. I&amp;#x2019;m sure the thing everyone says is &amp;#x201C;more caching.&amp;#x201D; It&amp;#x2019;s a good start but it&amp;#x2019;s not always the answer to all problems. Memcached can be unreliable. It can crash. Memcache SEGV from code push
  16. ????? disclosure ? Abuse ?
  17. we&amp;#x2019;ll talk about the databases in a bit
  18. rabbit mq, openmq = well documented problem - if you create a durable(persistant) queue, perf drops off dramatically no resiliance from failure and cannot back to disk reliabliy. Durable option kills performance. they were all slower than kestrel
  19. everything consumes resources. talk about passenger and threaded model, and problems with mod_rewrite.
  20. Most people design for fast clients that can dequeue quickly. Deal with the bottleneck.
  21. and a couple of final notes...