SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
Storage Infrastructure Behind
                 Facebook Messages
                        HBase/HDFS/ZK/MapReduce

                        Kannan Muthukkaruppan
                          Software Engineer, Facebook




Big Data Experiences & Scars, HPTS 2011
Oct 24th, 2011
The New Facebook Messages

 Messages   Chats    Emails   SMS
Why we chose HBase
â–Ș   High write throughput
â–Ș   Good random read performance
â–Ș   Horizontal scalability
â–Ș   Automatic Failover
â–Ș   Strong consistency
â–Ș   Benefits of HDFS
    â–Ș   Fault tolerant, scalable, checksums, MapReduce
    â–Ș   internal dev & ops expertise
What do we store in HBase
â–Ș   HBase
    â–Ș   Small messages
    â–Ș   Message metadata (thread/message indices)
    â–Ș   Search index


â–Ș   Haystack (our photo store)
    â–Ș   Attachments
    â–Ș   Large messages
HBase-HDFS System Overview
                             Database Layer

   HBASE
       Master      Backup
                   Master
   Region           Region                    Region    ...
   Server           Server                    Server
                                                              Coordination Service
            Storage Layer

HDFS                                                   Zookeeper Quorum
   Namenode          Secondary Namenode                ZK      ZK           ...
                                                       Peer    Peer
Datanode Datanode           Datanode          ...
Facebook Messages Architecture
                                                           User Directory Service
           Clients
   (Front End, MTA, etc.)
                            What’s the cell for
                               this user?         Cell 2
        Cell 1                                                   Cell 3

                                  Cell 1   Application Server
 Application Server                                  Application Server

                                                  Attachments
                                             HBase/HDFS/Z
  HBase/HDFS/Z                                Message, Metadata,
                                             K Search HBase/HDFS/Z
                                                        Index
  K                                                    K


                            Haystack
Typical Cluster Layout
 â–Ș   Multiple clusters/cells for messaging
     â–Ș   20 servers/rack; 5 or more racks per cluster
 â–Ș   Controllers (master/Zookeeper) spread across racks
 ZooKeeper Peer       ZooKeeper Peer     ZooKeeper Peer    ZooKeeper Peer     ZooKeeper Peer
 HDFS Namenode        Backup Namenode    Job Tracker       HBase Master     Backup HBase Master


Region Server        Region Server      Region Server     Region Server      Region Server
Data Node            Data Node          Data Node         Data Node          Data Node
Task Tracker         Task Tracker       Task Tracker      Task Tracker       Task Tracker



19x...                19x...            19x...            19x...             19x...


Region Server        Region Server      Region Server     Region Server      Region Server
Data Node            Data Node          Data Node         Data Node          Data Node
Task Tracker         Task Tracker       Task Tracker      Task Tracker       Task Tracker

         Rack #1          Rack #2            Rack #3           Rack #4            Rack #5
Facebook Messages: Quick Stats
â–Ș   6B+ messages/day


â–Ș   Traffic to HBase
     â–Ș 75+ Billion R+W ops/day

     â–Ș At peak: 1.5M ops/sec

     â–Ș ~ 55% Read vs. 45% Write ops

     â–Ș Avg write op inserts ~16 records across multiple

       column families.
Facebook Messages: Quick Stats (contd.)
â–Ș   2PB+ of online data in HBase (6PB+ with replication;
    excludes backups)
    â–Ș message data, metadata, search index

â–Ș   All data LZO compressed
â–Ș   Growing at 250TB/month
Facebook Messages: Quick Stats (contd.)
Timeline:
â–Ș   Started in Dec 2009
â–Ș   Roll out started in Nov 2010
â–Ș   Fully rolled out by July 2011 (migrated 1B+ accounts from
    legacy messages!)


While in production:
â–Ș   Schema changes: not once, but twice!
â–Ș   Implemented & rolled out HFile V2 and numerous other
    optimizations in an upward compatible manner!
Shadow Testing: Before Rollout
â–Ș   Both product and infrastructure were changing.
â–Ș   Shadows the old messages product + chat while the new one was
    under development

            Messages                    Chat          Backfilled data from
           V1 Frontend                Frontend        MySQL for % of users and
                                                      mirrored their production
                                                      traffic


                                                       Application Servers



       Cassandra         MySQL           ChatLogger
                                                      HBase/HDFS Cluster


                         Production                        Shadow
Shadow Testing: After Rollout
â–Ș   Shadows new version of the Messages product.
â–Ș   All backend changes go through shadow cluster before prod push


                       New
                     Messages
                     Frontend



                 Application Servers               Application Servers




                                                 HBase/HDFS Cluster
                 HBase/HDFS Cluster


                                                       Shadow
                   Production
Backup/Recovery (V1)
‱   During early phase, concerned about potential bugs in HBase.
‱   Off-line backups: written to HDFS via Scribe
‱   Recovery tools; testing of recovery tools

          Message
          Frontend


     Application Servers          Scribe/HDFS                      Local
                                                                 Datacenter
                                                                   HDFS          Remote
                                                                                Datacenter
                                                         ‱ Merge & Dedup          HDFS
    HBase/HDFS Cluster                                   ‱ Store locally, and
                                                         ‱ Copy to Remote DC


                           Double log from AppServer & HBase
                           to reduce probability of data loss
Backups (V2)
â–Ș   Now, does periodic HFile level backups.
â–Ș   Working on:
    â–Ș   Moving to HFile + Commit Log based backups to be able to recover to
        finer grained points in time
        â–Ș   Avoid need to log data to Scribe.
    â–Ș   Zero copy (hard link based) fast backups
Messages Schema & Evolution
â–Ș   “Actions” (data) Column Family the source of truth
    â–Ș   Log of all user actions (addMessage, markAsRead, etc.)

â–Ș   Metadata (thread index, message index, search index) etc. in other
    column families
â–Ș   Metadata portion of schema underwent 3 changes:
        â–Ș   Coarse grained snapshots (early development; rollout up to 1M users)
        â–Ș   Hybrid (up to full rollout – 1B+ accounts; 800M+ active)
        â–Ș   Fine-grained metadata (after rollout)
â–Ș   MapReduce jobs against production clusters!
        â–Ș   Ran in throttled way
        â–Ș   Heavy use of HBase bulk import features
Write Path Overview
Region Server
                ....
            Region #2
       Region #1
                        ....
                  ColumnFamily #2

            ColumnFamily #1
                                    Memstore


                HFiles (in HDFS)



  Write Ahead Log ( in HDFS)
                                      Append/Sync
Flushes: Memstore -> HFile
Region Server
               ....
           Region #2
      Region #1
                        ....
                 ColumnFamily #2

           ColumnFamily #1
                                       Memstore


                       HFiles                               flush




           Data in HFile is sorted; has block index for efficient
           retrieval
Read Path Overview
Region Server
               ....
           Region #2
      Region #1
                         ....
                 ColumnFamily #2

           ColumnFamily #1
                                   Memstore


                       HFiles



                                         Get
Compactions
Region Server
               ....
           Region #2
      Region #1
                        ....
                 ColumnFamily #2

           ColumnFamily #1
                                   Memstore

               HFiles
Reliability: Early work
â–Ș   HDFS sync support for durability of transactions
â–Ș   Multi-CF transaction atomicity
â–Ș   Several bug fixes in log recovery
â–Ș   New block placement policy in HDFS
    â–Ș   To reduce probability of data loss
Availability: Early Work
â–Ș   Common reasons for unavailability:
    â–Ș   S/W upgrades
        â–Ș   Solution: rolling upgrades
    â–Ș   Schema Changes
        â–Ș   Applications needs new Column Families
        â–Ș   Need to change settings for a CF
        â–Ș   Solution: online “alter table”
    â–Ș   Load balancing or cluster restarts took forever
        â–Ș   Upon investigation: stuck waiting for compactions to finish
        â–Ș   Solution: Interruptible Compactions!
Performance: Early Work
â–Ș   Read optimizations:
    â–Ș   Seek optimizations for rows with large number of cells
    â–Ș   Bloom Filters
        â–Ș   minimize HFile lookups
    â–Ș   Timerange hints on HFiles (great for temporal data)
    â–Ș   Multigets
    â–Ș   Improved handling of compressed HFiles
Performance: Compactions                                          Was
â–Ș   Critical for read performance
â–Ș   Old Algorithm:
#1. Start from newest file (file 0); include next file if:
    â–Ș   size[i] < size[i-1] * C (good!)
#2. Always compact at least 4 files, even if rule #1 isn’t met.

Solution:
                                                                  Now
#1. Compact at least 4 files, but only if eligible files found.
#2. Also, new file selection based on summation of sizes.
           size[i] < (size[0] + size[1] + 
size[i-1]) * C
Performance: Compactions
â–Ș   More problems!
    â–Ș   Read performance dips during      Small Compaction Q   Big Compaction Q
        peak
    â–Ș   Major compaction storms               Compaction         Compaction

    â–Ș   Large compactions bottleneck          Compaction        Compaction

â–Ș   Enhancements/fixes:                       Compaction
    â–Ș   Staggered major compactions
                                              Compaction
    â–Ș   Multi-thread compactions;
        separate queues for small & big
        compactions
    â–Ș   Aggressive off-peak compactions
Metrics, metrics, metrics

â–Ș   Initially, only had coarse level overall metrics (get/put latency/ops;
    block cache counters).
â–Ș   Slow query logging
â–Ș   Added per Column Family stats for:
    â–Ș   ops counts, latency
    â–Ș   block cache usage & hit ratio
    â–Ș   memstore usage
    â–Ș   on-disk file sizes
    â–Ș   file counts
    â–Ș   bytes returned, bytes flushed, compaction statistics
    â–Ș   stats by block type (data block vs. index blocks vs. bloom blocks, etc.)
    â–Ș   bloom filter stats
Metrics (contd.)
â–Ș   HBase Master Statistics:
    â–Ș   Number of region servers alive
    â–Ș   Number of regions
    â–Ș   Load balancing statistics
    â–Ș   ..
â–Ș   All stats stored in Facebook’s Operational Data Store (ODS).
â–Ș   Lots of ODS dashboards for debugging issues
    â–Ș   Side note: ODS planning to use HBase for storage pretty soon!
Need to keep up as data grows on you!
â–Ș   Rapidly iterated on several new features while in production:
    â–Ș   Block indexes upto 6GB per server! Cluster starts taking longer and
        longer. Block cache hit ratio on the decline.
        â–Ș   Solution: HFile V2
                â–Ș   Multi-level block index, Sharded Bloom Filters
    â–Ș   Network pegged after restarts
        â–Ș   Solution: Locality on full & rolling restart
    â–Ș   High disk utilization during peak
        â–Ș   Solution: Several “seek” optimizations to reduce disk IOPS
            â–Ș   Lazy Seeks (use time hints to avoid seeking into older HFiles)
            â–Ș   Special bloom filter for deletes to avoid additional seek
            â–Ș   Utilize off-peak IOPS to do more aggressive compactions during
Scares & Scars!
â–Ș   Not without our share of scares and incidents:
    â–Ș   s/w bugs. (e.g., deadlocks, incompatible LZO used for bulk imported data, etc.)
        â–Ș   found a edge case bug in log recovery as recently as last week!
    â–Ș   performance spikes every 6 hours (even off-peak)!
            â–Ș   cleanup of HDFS’s Recycle bin was sub-optimal! Needed code and config fix.
    â–Ș   transient rack switch failures
    â–Ș   Zookeeper leader election took than 10 minutes when one member of the
        quorum died. Fixed in more recent version of ZK.
    â–Ș   HDFS Namenode – SPOF
    â–Ș   flapping servers (repeated failures)
Scares & Scars! (contd.)
â–Ș   Sometimes, tried things which hadn’t been tested in dark launch!
        â–Ș   Added a rack of servers to help with performance issue
            â–Ș   Pegged top of the rack network bandwidth!
                â–Ș   Had to add the servers at much slower pace. Very manual .
                â–Ș   Intelligent load balancing needed to make this more automated.
â–Ș   A high % of issues caught in shadow/stress testing
â–Ș   Lots of alerting mechanisms in place to detect failures cases
    â–Ș   Automate recovery for a lots of common ones
    â–Ș   Treat alerts on shadow cluster as hi-pri too!
â–Ș   Sharding service across multiple HBase cells also paid off
Future Work
â–Ș   Reliability, Availability, Scalability!
â–Ș   Lot of new use cases on top of HBase in the works.


      â–Ș   HDFS Namenode HA
      â–Ș   Recovering gracefully from transient issues
      â–Ș   Fast hot-backups
      â–Ș   Delta-encoding in block cache
      â–Ș   Replication
      â–Ș   Performance (HBase and HDFS)
      â–Ș   HBase as a service Multi-tenancy
      â–Ș   Features- coprocessors, secondary indices
Acknowledgements
Work of lot of people spanning HBase, HDFS, Migrations,
Backup/Recovery pipeline, and Ops!

   Karthik Ranganathan            Mikhail Bautin
   Nicolas Spiegelberg            Pritam Damania
   Aravind Menon                  Prakash Khemani
   Dhruba Borthakur               Doug Porter
   Hairong Kuang                  Alex Laslavic
   Jonathan Gray                  Kannan Muthukkaruppan
   Rodrigo Schmidt                + Apache HBase
   Amitanand Aiyer                + Interns
   Guoqiang (Jerry) Chen          + Messages FrontEnd Team
   Liyin Tang                     + Messages AppServer Team
   Madhu Vaidya                   + many more folks

Thanks! Questions?
facebook.com/engineering

Mais conteĂșdo relacionado

Mais procurados

Introduction to hadoop and hdfs
Introduction to hadoop and hdfsIntroduction to hadoop and hdfs
Introduction to hadoop and hdfs
TrendProgContest13
 
MongoDB at eBay
MongoDB at eBayMongoDB at eBay
MongoDB at eBay
MongoDB
 
HBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBaseHBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBase
enissoz
 
Alfresco scalability and performnce
Alfresco   scalability and performnceAlfresco   scalability and performnce
Alfresco scalability and performnce
Paul Hampton
 

Mais procurados (20)

Meet HBase 1.0
Meet HBase 1.0Meet HBase 1.0
Meet HBase 1.0
 
Apache HBase for Architects
Apache HBase for ArchitectsApache HBase for Architects
Apache HBase for Architects
 
HBaseCon 2013: Compaction Improvements in Apache HBase
HBaseCon 2013: Compaction Improvements in Apache HBaseHBaseCon 2013: Compaction Improvements in Apache HBase
HBaseCon 2013: Compaction Improvements in Apache HBase
 
Introduction to hadoop and hdfs
Introduction to hadoop and hdfsIntroduction to hadoop and hdfs
Introduction to hadoop and hdfs
 
MongoDB at eBay
MongoDB at eBayMongoDB at eBay
MongoDB at eBay
 
Operating and supporting HBase Clusters
Operating and supporting HBase ClustersOperating and supporting HBase Clusters
Operating and supporting HBase Clusters
 
Hadoop 101
Hadoop 101Hadoop 101
Hadoop 101
 
HBase Advanced - Lars George
HBase Advanced - Lars GeorgeHBase Advanced - Lars George
HBase Advanced - Lars George
 
Hadoop Demystified + MapReduce (Java and C#), Pig, and Hive Demos
Hadoop Demystified + MapReduce (Java and C#), Pig, and Hive DemosHadoop Demystified + MapReduce (Java and C#), Pig, and Hive Demos
Hadoop Demystified + MapReduce (Java and C#), Pig, and Hive Demos
 
HBase Accelerated: In-Memory Flush and Compaction
HBase Accelerated: In-Memory Flush and CompactionHBase Accelerated: In-Memory Flush and Compaction
HBase Accelerated: In-Memory Flush and Compaction
 
Accumulo Summit 2014: Benchmarking Accumulo: How Fast Is Fast?
Accumulo Summit 2014: Benchmarking Accumulo: How Fast Is Fast?Accumulo Summit 2014: Benchmarking Accumulo: How Fast Is Fast?
Accumulo Summit 2014: Benchmarking Accumulo: How Fast Is Fast?
 
Realtime Apache Hadoop at Facebook
Realtime Apache Hadoop at FacebookRealtime Apache Hadoop at Facebook
Realtime Apache Hadoop at Facebook
 
Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...
Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...
Hadoop World 2011: The Hadoop Stack - Then, Now and in the Future - Eli Colli...
 
HBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBaseHBase and HDFS: Understanding FileSystem Usage in HBase
HBase and HDFS: Understanding FileSystem Usage in HBase
 
Zero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter MigrationZero-downtime Hadoop/HBase Cross-datacenter Migration
Zero-downtime Hadoop/HBase Cross-datacenter Migration
 
Cross-DC Fault-Tolerant ViewFileSystem @ Twitter
Cross-DC Fault-Tolerant ViewFileSystem @ TwitterCross-DC Fault-Tolerant ViewFileSystem @ Twitter
Cross-DC Fault-Tolerant ViewFileSystem @ Twitter
 
Apache HBaseăźçŸćœš - ç«ć±±ăšć‘Œă°ă‚ŒăŸHBaseは今どうăȘっどいるぼか
Apache HBaseăźçŸćœš - ç«ć±±ăšć‘Œă°ă‚ŒăŸHBaseは今どうăȘっどいるぼかApache HBaseăźçŸćœš - ç«ć±±ăšć‘Œă°ă‚ŒăŸHBaseは今どうăȘっどいるぼか
Apache HBaseăźçŸćœš - ç«ć±±ăšć‘Œă°ă‚ŒăŸHBaseは今どうăȘっどいるぼか
 
Apache Hadoop YARN, NameNode HA, HDFS Federation
Apache Hadoop YARN, NameNode HA, HDFS FederationApache Hadoop YARN, NameNode HA, HDFS Federation
Apache Hadoop YARN, NameNode HA, HDFS Federation
 
Alfresco scalability and performnce
Alfresco   scalability and performnceAlfresco   scalability and performnce
Alfresco scalability and performnce
 
Meet hbase 2.0
Meet hbase 2.0Meet hbase 2.0
Meet hbase 2.0
 

Semelhante a Storage Infrastructure Behind Facebook Messages

æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿæ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
yongboy
 
Hw09 Practical HBase Getting The Most From Your H Base Install
Hw09   Practical HBase  Getting The Most From Your H Base InstallHw09   Practical HBase  Getting The Most From Your H Base Install
Hw09 Practical HBase Getting The Most From Your H Base Install
Cloudera, Inc.
 
Hbase status quo apache-con europe - nov 2012
Hbase status quo   apache-con europe - nov 2012Hbase status quo   apache-con europe - nov 2012
Hbase status quo apache-con europe - nov 2012
Chris Huang
 
[B4]deview 2012-hdfs
[B4]deview 2012-hdfs[B4]deview 2012-hdfs
[B4]deview 2012-hdfs
NAVER D2
 

Semelhante a Storage Infrastructure Behind Facebook Messages (20)

Facebook Messages & HBase
Facebook Messages & HBaseFacebook Messages & HBase
Facebook Messages & HBase
 
æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿæ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
æ”Żæ’‘Facebookæ¶ˆæŻć€„ç†çš„h baseć­˜ć‚šçł»ç»Ÿ
 
Facebook's HBase Backups - StampedeCon 2012
Facebook's HBase Backups - StampedeCon 2012Facebook's HBase Backups - StampedeCon 2012
Facebook's HBase Backups - StampedeCon 2012
 
HBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, Cloudera
HBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, ClouderaHBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, Cloudera
HBaseCon 2012 | HBase and HDFS: Past, Present, Future - Todd Lipcon, Cloudera
 
Hbase jdd
Hbase jddHbase jdd
Hbase jdd
 
Hbase
HbaseHbase
Hbase
 
Hadoop Backup and Disaster Recovery
Hadoop Backup and Disaster RecoveryHadoop Backup and Disaster Recovery
Hadoop Backup and Disaster Recovery
 
Hw09 Practical HBase Getting The Most From Your H Base Install
Hw09   Practical HBase  Getting The Most From Your H Base InstallHw09   Practical HBase  Getting The Most From Your H Base Install
Hw09 Practical HBase Getting The Most From Your H Base Install
 
Cloudera Sessions - Clinic 1 - Getting Started With Hadoop
Cloudera Sessions - Clinic 1 - Getting Started With HadoopCloudera Sessions - Clinic 1 - Getting Started With Hadoop
Cloudera Sessions - Clinic 1 - Getting Started With Hadoop
 
Design for a Distributed Name Node
Design for a Distributed Name NodeDesign for a Distributed Name Node
Design for a Distributed Name Node
 
Hbase mhug 2015
Hbase mhug 2015Hbase mhug 2015
Hbase mhug 2015
 
HBaseCon 2013: Apache Drill - A Community-driven Initiative to Deliver ANSI S...
HBaseCon 2013: Apache Drill - A Community-driven Initiative to Deliver ANSI S...HBaseCon 2013: Apache Drill - A Community-driven Initiative to Deliver ANSI S...
HBaseCon 2013: Apache Drill - A Community-driven Initiative to Deliver ANSI S...
 
Hbase status quo apache-con europe - nov 2012
Hbase status quo   apache-con europe - nov 2012Hbase status quo   apache-con europe - nov 2012
Hbase status quo apache-con europe - nov 2012
 
[B4]deview 2012-hdfs
[B4]deview 2012-hdfs[B4]deview 2012-hdfs
[B4]deview 2012-hdfs
 
Introduction to HDFS and MapReduce
Introduction to HDFS and MapReduceIntroduction to HDFS and MapReduce
Introduction to HDFS and MapReduce
 
Cloudera Operational DB (Apache HBase & Apache Phoenix)
Cloudera Operational DB (Apache HBase & Apache Phoenix)Cloudera Operational DB (Apache HBase & Apache Phoenix)
Cloudera Operational DB (Apache HBase & Apache Phoenix)
 
Architectural Evolution Starting from Hadoop
Architectural Evolution Starting from HadoopArchitectural Evolution Starting from Hadoop
Architectural Evolution Starting from Hadoop
 
Geo-based content processing using hbase
Geo-based content processing using hbaseGeo-based content processing using hbase
Geo-based content processing using hbase
 
HugeTableApplication-Oriented Structure Data Storage System
HugeTableApplication-Oriented Structure Data Storage SystemHugeTableApplication-Oriented Structure Data Storage System
HugeTableApplication-Oriented Structure Data Storage System
 
Mar 2012 HUG: Hive with HBase
Mar 2012 HUG: Hive with HBaseMar 2012 HUG: Hive with HBase
Mar 2012 HUG: Hive with HBase
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
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
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
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
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
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
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

Storage Infrastructure Behind Facebook Messages

  • 1. Storage Infrastructure Behind Facebook Messages HBase/HDFS/ZK/MapReduce Kannan Muthukkaruppan Software Engineer, Facebook Big Data Experiences & Scars, HPTS 2011 Oct 24th, 2011
  • 2. The New Facebook Messages Messages Chats Emails SMS
  • 3. Why we chose HBase â–Ș High write throughput â–Ș Good random read performance â–Ș Horizontal scalability â–Ș Automatic Failover â–Ș Strong consistency â–Ș Benefits of HDFS â–Ș Fault tolerant, scalable, checksums, MapReduce â–Ș internal dev & ops expertise
  • 4. What do we store in HBase â–Ș HBase â–Ș Small messages â–Ș Message metadata (thread/message indices) â–Ș Search index â–Ș Haystack (our photo store) â–Ș Attachments â–Ș Large messages
  • 5. HBase-HDFS System Overview Database Layer HBASE Master Backup Master Region Region Region ... Server Server Server Coordination Service Storage Layer HDFS Zookeeper Quorum Namenode Secondary Namenode ZK ZK ... Peer Peer Datanode Datanode Datanode ...
  • 6. Facebook Messages Architecture User Directory Service Clients (Front End, MTA, etc.) What’s the cell for this user? Cell 2 Cell 1 Cell 3 Cell 1 Application Server Application Server Application Server Attachments HBase/HDFS/Z HBase/HDFS/Z Message, Metadata, K Search HBase/HDFS/Z Index K K Haystack
  • 7. Typical Cluster Layout â–Ș Multiple clusters/cells for messaging â–Ș 20 servers/rack; 5 or more racks per cluster â–Ș Controllers (master/Zookeeper) spread across racks ZooKeeper Peer ZooKeeper Peer ZooKeeper Peer ZooKeeper Peer ZooKeeper Peer HDFS Namenode Backup Namenode Job Tracker HBase Master Backup HBase Master Region Server Region Server Region Server Region Server Region Server Data Node Data Node Data Node Data Node Data Node Task Tracker Task Tracker Task Tracker Task Tracker Task Tracker 19x... 19x... 19x... 19x... 19x... Region Server Region Server Region Server Region Server Region Server Data Node Data Node Data Node Data Node Data Node Task Tracker Task Tracker Task Tracker Task Tracker Task Tracker Rack #1 Rack #2 Rack #3 Rack #4 Rack #5
  • 8. Facebook Messages: Quick Stats â–Ș 6B+ messages/day â–Ș Traffic to HBase â–Ș 75+ Billion R+W ops/day â–Ș At peak: 1.5M ops/sec â–Ș ~ 55% Read vs. 45% Write ops â–Ș Avg write op inserts ~16 records across multiple column families.
  • 9. Facebook Messages: Quick Stats (contd.) â–Ș 2PB+ of online data in HBase (6PB+ with replication; excludes backups) â–Ș message data, metadata, search index â–Ș All data LZO compressed â–Ș Growing at 250TB/month
  • 10. Facebook Messages: Quick Stats (contd.) Timeline: â–Ș Started in Dec 2009 â–Ș Roll out started in Nov 2010 â–Ș Fully rolled out by July 2011 (migrated 1B+ accounts from legacy messages!) While in production: â–Ș Schema changes: not once, but twice! â–Ș Implemented & rolled out HFile V2 and numerous other optimizations in an upward compatible manner!
  • 11. Shadow Testing: Before Rollout â–Ș Both product and infrastructure were changing. â–Ș Shadows the old messages product + chat while the new one was under development Messages Chat Backfilled data from V1 Frontend Frontend MySQL for % of users and mirrored their production traffic Application Servers Cassandra MySQL ChatLogger HBase/HDFS Cluster Production Shadow
  • 12. Shadow Testing: After Rollout â–Ș Shadows new version of the Messages product. â–Ș All backend changes go through shadow cluster before prod push New Messages Frontend Application Servers Application Servers HBase/HDFS Cluster HBase/HDFS Cluster Shadow Production
  • 13. Backup/Recovery (V1) ‱ During early phase, concerned about potential bugs in HBase. ‱ Off-line backups: written to HDFS via Scribe ‱ Recovery tools; testing of recovery tools Message Frontend Application Servers Scribe/HDFS Local Datacenter HDFS Remote Datacenter ‱ Merge & Dedup HDFS HBase/HDFS Cluster ‱ Store locally, and ‱ Copy to Remote DC Double log from AppServer & HBase to reduce probability of data loss
  • 14. Backups (V2) â–Ș Now, does periodic HFile level backups. â–Ș Working on: â–Ș Moving to HFile + Commit Log based backups to be able to recover to finer grained points in time â–Ș Avoid need to log data to Scribe. â–Ș Zero copy (hard link based) fast backups
  • 15. Messages Schema & Evolution â–Ș “Actions” (data) Column Family the source of truth â–Ș Log of all user actions (addMessage, markAsRead, etc.) â–Ș Metadata (thread index, message index, search index) etc. in other column families â–Ș Metadata portion of schema underwent 3 changes: â–Ș Coarse grained snapshots (early development; rollout up to 1M users) â–Ș Hybrid (up to full rollout – 1B+ accounts; 800M+ active) â–Ș Fine-grained metadata (after rollout) â–Ș MapReduce jobs against production clusters! â–Ș Ran in throttled way â–Ș Heavy use of HBase bulk import features
  • 16. Write Path Overview Region Server .... Region #2 Region #1 .... ColumnFamily #2 ColumnFamily #1 Memstore HFiles (in HDFS) Write Ahead Log ( in HDFS) Append/Sync
  • 17. Flushes: Memstore -> HFile Region Server .... Region #2 Region #1 .... ColumnFamily #2 ColumnFamily #1 Memstore HFiles flush Data in HFile is sorted; has block index for efficient retrieval
  • 18. Read Path Overview Region Server .... Region #2 Region #1 .... ColumnFamily #2 ColumnFamily #1 Memstore HFiles Get
  • 19. Compactions Region Server .... Region #2 Region #1 .... ColumnFamily #2 ColumnFamily #1 Memstore HFiles
  • 20. Reliability: Early work â–Ș HDFS sync support for durability of transactions â–Ș Multi-CF transaction atomicity â–Ș Several bug fixes in log recovery â–Ș New block placement policy in HDFS â–Ș To reduce probability of data loss
  • 21. Availability: Early Work â–Ș Common reasons for unavailability: â–Ș S/W upgrades â–Ș Solution: rolling upgrades â–Ș Schema Changes â–Ș Applications needs new Column Families â–Ș Need to change settings for a CF â–Ș Solution: online “alter table” â–Ș Load balancing or cluster restarts took forever â–Ș Upon investigation: stuck waiting for compactions to finish â–Ș Solution: Interruptible Compactions!
  • 22. Performance: Early Work â–Ș Read optimizations: â–Ș Seek optimizations for rows with large number of cells â–Ș Bloom Filters â–Ș minimize HFile lookups â–Ș Timerange hints on HFiles (great for temporal data) â–Ș Multigets â–Ș Improved handling of compressed HFiles
  • 23. Performance: Compactions Was â–Ș Critical for read performance â–Ș Old Algorithm: #1. Start from newest file (file 0); include next file if: â–Ș size[i] < size[i-1] * C (good!) #2. Always compact at least 4 files, even if rule #1 isn’t met. Solution: Now #1. Compact at least 4 files, but only if eligible files found. #2. Also, new file selection based on summation of sizes. size[i] < (size[0] + size[1] + 
size[i-1]) * C
  • 24. Performance: Compactions â–Ș More problems! â–Ș Read performance dips during Small Compaction Q Big Compaction Q peak â–Ș Major compaction storms Compaction Compaction â–Ș Large compactions bottleneck Compaction Compaction â–Ș Enhancements/fixes: Compaction â–Ș Staggered major compactions Compaction â–Ș Multi-thread compactions; separate queues for small & big compactions â–Ș Aggressive off-peak compactions
  • 25. Metrics, metrics, metrics
 â–Ș Initially, only had coarse level overall metrics (get/put latency/ops; block cache counters). â–Ș Slow query logging â–Ș Added per Column Family stats for: â–Ș ops counts, latency â–Ș block cache usage & hit ratio â–Ș memstore usage â–Ș on-disk file sizes â–Ș file counts â–Ș bytes returned, bytes flushed, compaction statistics â–Ș stats by block type (data block vs. index blocks vs. bloom blocks, etc.) â–Ș bloom filter stats
  • 26. Metrics (contd.) â–Ș HBase Master Statistics: â–Ș Number of region servers alive â–Ș Number of regions â–Ș Load balancing statistics â–Ș .. â–Ș All stats stored in Facebook’s Operational Data Store (ODS). â–Ș Lots of ODS dashboards for debugging issues â–Ș Side note: ODS planning to use HBase for storage pretty soon!
  • 27. Need to keep up as data grows on you! â–Ș Rapidly iterated on several new features while in production: â–Ș Block indexes upto 6GB per server! Cluster starts taking longer and longer. Block cache hit ratio on the decline. â–Ș Solution: HFile V2 â–Ș Multi-level block index, Sharded Bloom Filters â–Ș Network pegged after restarts â–Ș Solution: Locality on full & rolling restart â–Ș High disk utilization during peak â–Ș Solution: Several “seek” optimizations to reduce disk IOPS â–Ș Lazy Seeks (use time hints to avoid seeking into older HFiles) â–Ș Special bloom filter for deletes to avoid additional seek â–Ș Utilize off-peak IOPS to do more aggressive compactions during
  • 28. Scares & Scars! â–Ș Not without our share of scares and incidents: â–Ș s/w bugs. (e.g., deadlocks, incompatible LZO used for bulk imported data, etc.) â–Ș found a edge case bug in log recovery as recently as last week! â–Ș performance spikes every 6 hours (even off-peak)! â–Ș cleanup of HDFS’s Recycle bin was sub-optimal! Needed code and config fix. â–Ș transient rack switch failures â–Ș Zookeeper leader election took than 10 minutes when one member of the quorum died. Fixed in more recent version of ZK. â–Ș HDFS Namenode – SPOF â–Ș flapping servers (repeated failures)
  • 29. Scares & Scars! (contd.) â–Ș Sometimes, tried things which hadn’t been tested in dark launch! â–Ș Added a rack of servers to help with performance issue â–Ș Pegged top of the rack network bandwidth! â–Ș Had to add the servers at much slower pace. Very manual . â–Ș Intelligent load balancing needed to make this more automated. â–Ș A high % of issues caught in shadow/stress testing â–Ș Lots of alerting mechanisms in place to detect failures cases â–Ș Automate recovery for a lots of common ones â–Ș Treat alerts on shadow cluster as hi-pri too! â–Ș Sharding service across multiple HBase cells also paid off
  • 30. Future Work â–Ș Reliability, Availability, Scalability! â–Ș Lot of new use cases on top of HBase in the works. â–Ș HDFS Namenode HA â–Ș Recovering gracefully from transient issues â–Ș Fast hot-backups â–Ș Delta-encoding in block cache â–Ș Replication â–Ș Performance (HBase and HDFS) â–Ș HBase as a service Multi-tenancy â–Ș Features- coprocessors, secondary indices
  • 31. Acknowledgements Work of lot of people spanning HBase, HDFS, Migrations, Backup/Recovery pipeline, and Ops! Karthik Ranganathan Mikhail Bautin Nicolas Spiegelberg Pritam Damania Aravind Menon Prakash Khemani Dhruba Borthakur Doug Porter Hairong Kuang Alex Laslavic Jonathan Gray Kannan Muthukkaruppan Rodrigo Schmidt + Apache HBase Amitanand Aiyer + Interns Guoqiang (Jerry) Chen + Messages FrontEnd Team Liyin Tang + Messages AppServer Team Madhu Vaidya + many more folks