Your SlideShare is downloading. ×

Facebook Architecture - Breaking it Open

21,187

Published on

Facebook Architecture - Breaking it Open

Facebook Architecture - Breaking it Open

Published in: Technology, News & Politics
2 Comments
23 Likes
Statistics
Notes
No Downloads
Views
Total Views
21,187
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
506
Comments
2
Likes
23
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Learning and Development Be part of the learning experience at Aditi. presents Join the talks. Its free. Free as in freedom at work, not free-beer. Its not training. Its mind-opener. Speak at these events. Or bring an expert/friend to talk. Open Talk Series Mail OpenTalk@aditi.com with topic and A series of illuminating talks and interactions that open our minds to new availability.ideas and concepts; that makes us look for newer or better ways of doing what we did; or point us to exciting things we have never done before. A range of topics on Technology, Business, Fun and Life.
  • 2. HOW TO ENJOY AN TALKBring coffee & friends Switch OFF mobile Switch ON mindSign attendance sheet SHARE your wisdom QUESTION notions THANK the Talker SPREAD the good word
  • 3. architecture Sundararajan SubramanianImage Copyright : facebook
  • 4. facebook in 20 Minutes • 2.7 M Photos • 10.2M Comments • 4.6 MessagesStatisticsWhat is Facebook • Shared links: 1,000,000Technical challenges • Tagged photos: 1,323,000Front End • Event invites sent out: 1,484,000Data archServices architecture • Wall Posts: 1,587,000 • Status updates: 1,851,000 • Friend requests accepted: 1,972,000 • Photos uploaded: 2,716,000 • Comments: 10,208,000 • Message: 4,632,000
  • 5. facebook in 20 Minutes Direct FriendshipStatisticsWhat is FacebookTechnical challengesFront EndData archServices architecture Friends of Friends
  • 6. What is facebook • A social graph • Friends , Friends of friends, somewhere in the network. • Friends can comment, like, read your posts • Friends of friends can just readStatisticsWhat is FacebookTechnical challenges • Facebook messages – chat/ email/ SMSFront End • Near real-time updatesData archServices architecture
  • 7. Technical Challenges Challenges Ok to Live withStatisticsWhat is Facebook • High • Not MissionTechnical challengesFront End Concurrency CriticalData arch • High Data • Cached data isServices architecture Volumes fine • Multilevel • Write Failures Hierarchical are tolerable data
  • 8. The Data – (Illustrational) Everything is a hash lookup User Friend User Age Bio Intere ID s with Name stsStatistics 1 2,3,4 XYZ .. .. ..What is Facebook 2 1 .. .. .. ..Technical challenges Challenges SolutionsFront EndData archServices architecture The Relational Nature of the data No Constraints, No Joins in MySQL Data Volumes Write Through cache implementation Concurrency Hash Ring based architecture
  • 9. facebook – Data Partition initial thoughts • Horizontal partitioning based on Networks. – HarvardStatistics – StanfordWhat is FacebookTechnical challenges – CarnegieFront EndData archServices architecture
  • 10. facebook –Photos - HayStack • Each File read required a minimum of 3 i/o in a typical file system • CDNs- Not a Solution • Haystack is a customized storageStatistics system, which minimizes theWhat is FacebookTechnical challengesFront End amount of File metadata and involves only 1 i/o for each fileData archServices architecture read. • Haystack caches extensive data in in its main memory
  • 11. facebook – HayStackStatistics HayStack Interface HayStack HayStackWhat is Facebook Cache DirectoryTechnical challengesFront EndData arch Logical Drives Logical DrivesServices architecture PD PD PD PD PD PD http://CDN/Cache/Machine id/(Logical volume, Photo)
  • 12. Facebook – Serving the Photo - HaystackStatisticsWhat is FacebookTechnical challengesFront EndData archServices architecture
  • 13. Facebook – Scribe - Logging Nodes Nodes Nodes Scribe Scribe ScribeStatisticsWhat is FacebookTechnical challengesFront End $messages = array(); $entry = new LogEntry;Data arch Central Scribe Server $entry->category = "buckettest";Services architecture $entry->message = "something very”; $messages []= $entry; $result = $conn->Log($messages); Dashboards HBase
  • 14. facebook – Services– Thrift • Lightweight Software framework for cross- language development • Dev need not worry about serialization , connection handling and threading • Supported bindings:StatisticsWhat is FacebookTechnical challenges – C++, PHP, Python, java, ruby, erlang, perl,Front End haskell • Transports : Simple interface to i/oData archServices architecture • Protocols : Serialization format – TBinaryProtocol, TJsonProtocol • Severs – Non Blocking, Async, Single threaded, multi- threaded
  • 15. facebook – Memcache • In-memory distributed hash table • “hot” data from MySQL stored in cacheStatisticsWhat is FacebookTechnical challengesFront EndData archServices architecture
  • 16. facebook – front end - PHP • Op – Code Optimization • APC improvements(alternate PHP cache) – Lazy Loading – Cache primingStatistics • Custom ExtensionsWhat is FacebookTechnical challenges – Memcache Client ExtensionFront End – Serialization formatData arch – Logging, Stats Collection, MonitoringServices architecture – Asynchronous event-handling mechanism
  • 17. facebook – front end – Hip Hop • Source Code Transformer • Static Analysis, type inference, Code GenerationStatistics • Easier to write extensionsWhat is FacebookTechnical challenges • Significantly cuts down on CPU and Memory usageFront EndData archServices architecture
  • 18. facebook – front end – Hip HopStatisticsWhat is FacebookTechnical challengesFront EndData archServices architecture
  • 19. facebook – front end – BigPipe BigPipe first breaks web pages into multiple chunks called pageletsStatisticsWhat is FacebookTechnical challengesFront EndData archServices architecture
  • 20. facebook – front end – BigPipe BigPipe first breaks web pages into multiple chunks called pagelets Request Parsing Web Server parses and sanity checks the request Data Fetching Web Server fetches data from storage tierStatisticsWhat is Facebook Markup Generation Web server generates HTML MarkupTechnical challengesFront End Network Transport Response is transferredData archServices architecture CSS downloading Dom Tree Construction JavaScript downloading JS Execution
  • 21. facebook – Technology Stack Front End Big Pipe Hip Hop PHP - Custom compiler / Cache implementations Linux – Custom Kernel Extensions Service Aggregators Scribe Thrift Service 1 Service 2 Service 3 Service 4 Data Store MemCache – Write Through Cache implementation Cassandra MySQL HBase HayStack
  • 22. facebook – Messages InfrastructureStatisticsWhat is FacebookTechnical challengesFront EndData archServices architectureMessages
  • 23. facebook - MessagesStatisticsWhat is FacebookTechnical challengesFront EndData archServices architectureMessages
  • 24. facebook - MessagesStatisticsWhat is FacebookTechnical challengesFront EndData archServices architectureMessages
  • 25. facebook – Cells Cell Node 1StatisticsWhat is Facebook NodeTechnical challenges Node2 n ZookeperFront End ControllerData arch MachinesServices architectureMessages Node Node 4 3 Application Server Cluster Metadata Store
  • 26. facebook – Cells • They help scale incrementally while limiting failure scenarios • Easy upgradesStatisticsWhat is Facebook • Metadata store failures affect only a fewTechnical challenges usersFront EndData archServices architecture • Easy rolloutMessages • Flexibility to host cells in different data centers with multi-homing for disaster recovery
  • 27. Take away – for our applications • Really parallel Asynchronous AJAX Pages – ASP.Net Update panels is a HOAX • Appropriate usage of client side technology • Cache – Cache – Cache – Write Through Caches are way better – App Fabric cache/ Memcache • High – Normalization is not needed – Store denormalized views – materialized views • Parallel Services and Service aggregators • Fault tolerant applications • Asynchronous Processing • 1 Sec response time is too SLOW
  • 28. References • http://facebook.com/engineering • www.infoq.com • www.highscalability.com • www.stackoverflow.com • www.thrift.org
  • 29. Keep LearningFor suggestions on topics/ feedbacks etc., Contact OpenTalk@aditi.com

×