SlideShare a Scribd company logo
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 0-1 Million in 46 Days
                 Scaling a Facebook Application in Rails

                 Ikai Lan
                 Linkedin




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 1
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Hi! I’m Ikai Lan




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 2
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 What this talk is not
            One-size-fits all solution to scaling
            problems
            Example source code
            An in-depth discussion of Ruby on
            Rails




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 3
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 What this talk is
            A look into the challenges we faced
            with scaling a rapid growth web
            application




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 4
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 This is a detective story.




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 5
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Rather than telling you best
                 practices




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 6
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 We’ll talk about how we came to
                 define them.




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 7
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Bumper Sticker?
            Investigation of the Facebook
            platform
            Investigation of Ruby on Rails as a
            serious development platform




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 8
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Reid Hoffman’s wager




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                       Slide 9
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 1 million users in 45 days!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 10
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Personal Badging
            Create and display badges
            Share badges
            Find badges




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 11
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 = Bumper Sticker!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 12
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Success!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 13
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 … 1 million in 46 days




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 14
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Trouble in Paradise




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 15
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Throw hardware at it!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 16
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 More hardware!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 17
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 This is not working.




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 18
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Current state of affairs
            7 million adds
            20 million pageviews
            3 million timeouts a day




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 19
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Strategy
            Analyze MySQL slow queries log
            Application log




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 20
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 D’oh! No logging!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 21
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Logging -> Syslog
            Rails does not buffer writes to
            filesystem




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 22
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin



                 Clue 1: Slaves ran several hours
                 behind Master




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 23
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Clue 2: Updates to add count

            One by one updates




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 24
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Counter Cache
            SQL Updates not batched
            Very inefficient!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 25
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




        Result: less slow queries



Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 26
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




         Lesson 1: Buffer
         everything!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 27
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Still had lots of timeouts!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 28
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Clue 3: 80% of traffic to static
                 content




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 29
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Next attempt: edge caching!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 30
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Edge caching using fb:ref
            Facebook mechanism for storing
            data




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 31
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Fb:ref on the load balancer!

            F5 BigIP set to conditionally respond
            to static URIs with fb:ref
            Background process to constantly
            update fb:ref in Facebook cache




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 32
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




       Result: Static pages =
       perfect




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 33
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




       Lesson 2: Edge cache
       when possible




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 34
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin



                 But we were still serving
                 millions of timeouts!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 35
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Clue 4: Most CPU time accepting
                 stickers

            Request taking up to 10 seconds
            during peak




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 36
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Slow database writes




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 37
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 1st attempt: Background process
                 writes




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 38
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




           Result: Timeouts dropped
           significantly!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 39
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




        Success … ?




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 40
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 No.




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 41
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




               Application would not
               seem responsive to user
               actions and seem out of
               sync.



Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 42
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




           2nd attempt: Two step
           write




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 43
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




              Step 1: Synchronous
              write to MemCache

           Step 2: Asynchronous write to
                 database (queue)


Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 44
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Result: Success!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 45
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




        Lesson 3: Use
        asynchronous processing
        when possible




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 46
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




        Lesson 3.1: Keeping data
        in sync is not trivial!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 47
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




       Lesson 3.2: Lack of
       concurrency in Rails
       presents problem earlier




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 48
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




        Lesson 3.3: Very few
        problems can be reduced
        to a linear equation




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 49
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 QED: Rails can scale.




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 50
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Latest stats
            16 million installs
            30 million pageviews a day
            Average response time of <80ms




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 51
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Scaling has a price!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 52
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Complexity




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 53
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 No new functionality!




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 54
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Key takeaways
            Make long running tasks
            asynchronous
            Use edge caching
            Buffer long operations when possible




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 55
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 The bigger picture
            Language choice is less important
            than architecture
            Be creative – brute force doesn’t
            work
            Be ready to be wrong




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 56
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




              Questions?




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 57
Colorado Software Summit: October 19 – 24, 2008                                      © Copyright 2008, Linkedin




                 Thanks for coming!
            ilan@linkedin.com
            http://www.linkedin.com/in/ikailan




Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails                      Slide 58

More Related Content

Similar to From 0-1 billion in 46 days

Innovation and Strategy in Web 2.0: Application Marketing
Innovation and Strategy in Web 2.0:  Application MarketingInnovation and Strategy in Web 2.0:  Application Marketing
Innovation and Strategy in Web 2.0: Application Marketing
Robyn Tippins
 
Collaboration tools 2018
Collaboration tools 2018 Collaboration tools 2018
Collaboration tools 2018
Digital Disciple Network
 
Engineering challenges, product management solutions - product camp 2016
Engineering challenges, product management solutions - product camp 2016Engineering challenges, product management solutions - product camp 2016
Engineering challenges, product management solutions - product camp 2016
Ron Lichty
 
Keynote at CloudExpo and DevOps Summit 2014, Silicon Valley
Keynote at CloudExpo and DevOps Summit 2014, Silicon ValleyKeynote at CloudExpo and DevOps Summit 2014, Silicon Valley
Keynote at CloudExpo and DevOps Summit 2014, Silicon Valley
Victoria Livschitz
 
Creating Value In Social Networking
Creating Value In Social NetworkingCreating Value In Social Networking
Creating Value In Social Networking
Lars Trieloff
 
Chinese Startup 01.AI Is Winning the Open Source AI Race
Chinese Startup 01.AI Is Winning the Open Source AI RaceChinese Startup 01.AI Is Winning the Open Source AI Race
Chinese Startup 01.AI Is Winning the Open Source AI Race
LUMINATIVE MEDIA/PROJECT COUNSEL MEDIA GROUP
 
API Management and Community Development layer 7 in london 2012
API Management and Community Development layer 7 in london 2012API Management and Community Development layer 7 in london 2012
API Management and Community Development layer 7 in london 2012
James Governor
 
Web Services for Fun and Profit
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and Profit
Simon Willison
 
Web2.0!
Web2.0!Web2.0!
Web2.0!
Marcus Lacher
 
Defining Web 2.0 and RIA
Defining Web 2.0 and RIADefining Web 2.0 and RIA
Defining Web 2.0 and RIA
Arielladog
 

Similar to From 0-1 billion in 46 days (12)

Innovation and Strategy in Web 2.0: Application Marketing
Innovation and Strategy in Web 2.0:  Application MarketingInnovation and Strategy in Web 2.0:  Application Marketing
Innovation and Strategy in Web 2.0: Application Marketing
 
Collaboration tools 2018
Collaboration tools 2018 Collaboration tools 2018
Collaboration tools 2018
 
Engineering challenges, product management solutions - product camp 2016
Engineering challenges, product management solutions - product camp 2016Engineering challenges, product management solutions - product camp 2016
Engineering challenges, product management solutions - product camp 2016
 
Keynote at CloudExpo and DevOps Summit 2014, Silicon Valley
Keynote at CloudExpo and DevOps Summit 2014, Silicon ValleyKeynote at CloudExpo and DevOps Summit 2014, Silicon Valley
Keynote at CloudExpo and DevOps Summit 2014, Silicon Valley
 
Creating Value In Social Networking
Creating Value In Social NetworkingCreating Value In Social Networking
Creating Value In Social Networking
 
Web 2.0 21st Century Learner
Web 2.0 21st Century LearnerWeb 2.0 21st Century Learner
Web 2.0 21st Century Learner
 
Chinese Startup 01.AI Is Winning the Open Source AI Race
Chinese Startup 01.AI Is Winning the Open Source AI RaceChinese Startup 01.AI Is Winning the Open Source AI Race
Chinese Startup 01.AI Is Winning the Open Source AI Race
 
API Management and Community Development layer 7 in london 2012
API Management and Community Development layer 7 in london 2012API Management and Community Development layer 7 in london 2012
API Management and Community Development layer 7 in london 2012
 
Web Services for Fun and Profit
Web Services for Fun and ProfitWeb Services for Fun and Profit
Web Services for Fun and Profit
 
Web2.0!
Web2.0!Web2.0!
Web2.0!
 
web 2.0
web 2.0web 2.0
web 2.0
 
Defining Web 2.0 and RIA
Defining Web 2.0 and RIADefining Web 2.0 and RIA
Defining Web 2.0 and RIA
 

More from ikailan

2011 aug-gdd-mexico-city-high-replication-datastore
2011 aug-gdd-mexico-city-high-replication-datastore2011 aug-gdd-mexico-city-high-replication-datastore
2011 aug-gdd-mexico-city-high-replication-datastore
ikailan
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-go
ikailan
 
2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore
ikailan
 
2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon
ikailan
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
ikailan
 
Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodb
ikailan
 
Introducing the App Engine datastore
Introducing the App Engine datastoreIntroducing the App Engine datastore
Introducing the App Engine datastore
ikailan
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? Oikailan
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
ikailan
 

More from ikailan (9)

2011 aug-gdd-mexico-city-high-replication-datastore
2011 aug-gdd-mexico-city-high-replication-datastore2011 aug-gdd-mexico-city-high-replication-datastore
2011 aug-gdd-mexico-city-high-replication-datastore
 
2011 july-nyc-gtug-go
2011 july-nyc-gtug-go2011 july-nyc-gtug-go
2011 july-nyc-gtug-go
 
2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore2011 july-gtug-high-replication-datastore
2011 july-gtug-high-replication-datastore
 
2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon2011 june-kuala-lumpur-gtug-hackathon
2011 june-kuala-lumpur-gtug-hackathon
 
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
2011 June - Singapore GTUG presentation. App Engine program update + intro to Go
 
Rapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodbRapid web development using tornado web and mongodb
Rapid web development using tornado web and mongodb
 
Introducing the App Engine datastore
Introducing the App Engine datastoreIntroducing the App Engine datastore
Introducing the App Engine datastore
 
What is App Engine? O
What is App Engine? OWhat is App Engine? O
What is App Engine? O
 
OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 

Recently uploaded

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 

Recently uploaded (20)

zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 
UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6UiPath Test Automation using UiPath Test Suite series, part 6
UiPath Test Automation using UiPath Test Suite series, part 6
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 

From 0-1 billion in 46 days

  • 1. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin 0-1 Million in 46 Days Scaling a Facebook Application in Rails Ikai Lan Linkedin Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 1
  • 2. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Hi! I’m Ikai Lan Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 2
  • 3. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin What this talk is not One-size-fits all solution to scaling problems Example source code An in-depth discussion of Ruby on Rails Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 3
  • 4. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin What this talk is A look into the challenges we faced with scaling a rapid growth web application Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 4
  • 5. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin This is a detective story. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 5
  • 6. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Rather than telling you best practices Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 6
  • 7. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin We’ll talk about how we came to define them. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 7
  • 8. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Bumper Sticker? Investigation of the Facebook platform Investigation of Ruby on Rails as a serious development platform Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 8
  • 9. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Reid Hoffman’s wager Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 9
  • 10. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin 1 million users in 45 days! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 10
  • 11. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Personal Badging Create and display badges Share badges Find badges Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 11
  • 12. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin = Bumper Sticker! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 12
  • 13. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Success! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 13
  • 14. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin … 1 million in 46 days Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 14
  • 15. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Trouble in Paradise Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 15
  • 16. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Throw hardware at it! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 16
  • 17. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin More hardware! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 17
  • 18. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin This is not working. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 18
  • 19. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Current state of affairs 7 million adds 20 million pageviews 3 million timeouts a day Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 19
  • 20. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Strategy Analyze MySQL slow queries log Application log Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 20
  • 21. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin D’oh! No logging! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 21
  • 22. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Logging -> Syslog Rails does not buffer writes to filesystem Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 22
  • 23. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Clue 1: Slaves ran several hours behind Master Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 23
  • 24. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Clue 2: Updates to add count One by one updates Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 24
  • 25. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Counter Cache SQL Updates not batched Very inefficient! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 25
  • 26. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Result: less slow queries Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 26
  • 27. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 1: Buffer everything! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 27
  • 28. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Still had lots of timeouts! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 28
  • 29. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Clue 3: 80% of traffic to static content Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 29
  • 30. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Next attempt: edge caching! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 30
  • 31. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Edge caching using fb:ref Facebook mechanism for storing data Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 31
  • 32. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Fb:ref on the load balancer! F5 BigIP set to conditionally respond to static URIs with fb:ref Background process to constantly update fb:ref in Facebook cache Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 32
  • 33. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Result: Static pages = perfect Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 33
  • 34. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 2: Edge cache when possible Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 34
  • 35. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin But we were still serving millions of timeouts! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 35
  • 36. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Clue 4: Most CPU time accepting stickers Request taking up to 10 seconds during peak Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 36
  • 37. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Slow database writes Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 37
  • 38. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin 1st attempt: Background process writes Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 38
  • 39. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Result: Timeouts dropped significantly! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 39
  • 40. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Success … ? Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 40
  • 41. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin No. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 41
  • 42. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Application would not seem responsive to user actions and seem out of sync. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 42
  • 43. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin 2nd attempt: Two step write Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 43
  • 44. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Step 1: Synchronous write to MemCache Step 2: Asynchronous write to database (queue) Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 44
  • 45. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Result: Success! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 45
  • 46. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 3: Use asynchronous processing when possible Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 46
  • 47. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 3.1: Keeping data in sync is not trivial! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 47
  • 48. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 3.2: Lack of concurrency in Rails presents problem earlier Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 48
  • 49. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Lesson 3.3: Very few problems can be reduced to a linear equation Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 49
  • 50. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin QED: Rails can scale. Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 50
  • 51. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Latest stats 16 million installs 30 million pageviews a day Average response time of <80ms Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 51
  • 52. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Scaling has a price! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 52
  • 53. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Complexity Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 53
  • 54. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin No new functionality! Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 54
  • 55. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Key takeaways Make long running tasks asynchronous Use edge caching Buffer long operations when possible Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 55
  • 56. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin The bigger picture Language choice is less important than architecture Be creative – brute force doesn’t work Be ready to be wrong Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 56
  • 57. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Questions? Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 57
  • 58. Colorado Software Summit: October 19 – 24, 2008 © Copyright 2008, Linkedin Thanks for coming! ilan@linkedin.com http://www.linkedin.com/in/ikailan Ikai Lan — From 0 to 1,000,000 in 46 Days: Scaling a Facebook Application in Rails Slide 58