SlideShare a Scribd company logo
1 of 40
Apache BookKeeper
DISTRIBUTED STORE
a Salesforce Use Case
Venkateswararao Jujjuri (JV)
Cloud Storage Architect
vjujjuri@salesforce.com
jujjuri@gmail.com
@jvjujjuri | Twitter
https://www.linkedin.com/in/jvjujjuri
Agenda
Salesforce needs and requirements
Hunt and Selection
BookKeeper Introduction
Improvements and Enhancements
As Service at Scale @ Salesforce
Performance
Community
Q & A
Salesforce Application Storage Needs
Store for Persistent WAL, data, and objects
Low, constant write latencies
• Transaction Log, Smaller writes
Low, constant Random Read latencies
Highly available for immutable data
• Append Only entries
• Objects
Highly Consistent for immutable data
Long Term Storage
Distributed and linearly scalable.
On commodity hardware
Low Operating Cost
What Did we consider?
Build vs. Buy
• Time-To-Market, resources, cost etc.
Finalists
• Ceph
• A CP System
• w/Unreliable reads read path can behave like AP system.
• Lot of effort to make it AP behavior on write path
• Remember: Immutable data.
• BookKeeper
• CAP system, because of immutable/append only store.
• Came close to what we want
• Almost there but not everything.
Apache Bookkeeper
A highly consistent, available, replicated distributed log service.
Immutable , append only store.
Thick Client, Simple and Elegant placement policy
• No Central Master
• No complicated hashing/computing for placement
Low latency, both on writes and reads.
Runs on commodity hardware.
Built for WAL use case, but can be expanded to other storage needs
Uses ZooKeeper as consensuses resolver, and metadata store.
Awesome Community.
Enter Apache BookKeeper
Apache BookKeeper
A system to reliably log streams of records.
Is designed to store write ahead logs for database like applications.
Inspired by and designed to solve HDFS NameNode availability deficiencies.
Opensource Chronology
• 2008 Open Sourced contribution to ZooKeeper
• 2011 Sub-Project of ZooKeeper.
• 2012 Production
Terminology
Journal: Write ahead log
Ledger: Log Stream
Entry: Each entry of log record
Client: Library, with the application.
Bookie: Server
Ensemble: Set of Bookies across which a ledger is striped.
Cluster: All bookies belong to a given instance of Bookkeeper
Write Quorum Size: Number of replicas.
Ack Quorum Size: Number of responses needed before client’s write is satisfied.
LAC: Last Add Confirmed.
Guarantees
• If an entry has been acknowledged, it must be readable.
• If an entry is read once, it must always be readable.
• If write of entry ‘n’ is successful, all entries until ‘n’ are successfully committed.
Major Components
• Thick Client; Carries heavy weight in the protocol.
• Thin Server, Bookie. Bookies never initiate any interaction with ZooKeeper or fellow Bookies.
• Zookeeper monitors Bookies.
• Metadata is stored on Zookeeper.
• Auditor to monitor bookies and identify under replicated ledgers.
• Replication workers to replicate under replicated ledger copies.
Highlights
Create Ledger
• Gets Writer Ledger Handle
Add an entry to the Ledger
• Write To the Ledger
Open Ledger
• Gives ReadOnly Ledger Handle.
• May ask for non-recovery read handle.
Get an entry from the ledger
• Read from the ledger
Close the ledger.
Basic Operations
Out-of-order write and In-Order Ack.
• Application has liberty to pre-allocate entryIDs
• Multiple application threads can write in parallel.
User defined Ledger Names
• Not restricted by BK generated ledger Names
Explicit LAC updates
• Added ReadLac, WriteLac to the protocol.
• Maintain both piggy-back LAC and explicit LAC simultaneously.
Enhancements - In the internal branch working to push upstream
Conventional Name Space.
• User defined Names
• Treat LedgerId as an i-node.
Disk scrubbers and Repairs
• Actively hunt and repair bit-rots and corruptions
Scalable Metadata Store
• Separate and dedicated metadata store
• Not restricted by ZK limitations
Enhancements - Future
Salesforce Application with BookKeeper
Application
Store Interface
With
Bookkeeper client User
Library
Bookies ZooKeeper
Server Machine
Guarantees
• If an entry has been acknowledged, it must be readable.
• If an entry is read once, it must always be readable.
• If write of entry ‘n’ is successful, all entries until ‘n’ are successfully committed.
Consistencies
• Last Add Confirmed is consistency among readers
• Fence is consistency among writers.
Consistencies
Out of order write and in order Ack
0 1 2 3 4 5
App A ( Writer )
6
App B ( Writer )
8
App C ( Writer )
7
Last Add Confirmed
0 1 2 3 4 5
App A ( Writer )
6
App B ( Writer )
8
App C ( Writer )
7
LAC LAC
App D (Reader)
X
LAC
Things Do Break
What Can Happen?
Client side
• Client Restarts
• Client looses connection with zookeeper
• Client looses connection with bookies.
Bookie Side
• Bookie Goes down
• Disk(s) on bookie go bad, IO issues
• Bookie gets disconnected from network.
Zookeeper
• Gets disconnected from rest of the cluster
Writing Client Crash
bookie
bookie
bookie
zookeeper
What is the last entry?
• Nothing happens until a reader attempts to
read.
• Recovery process gets initiated when a
process opens the ledger for reading.
• Close the ledger on zoo keeper
• Identify Last entry of the ledger.
• Update metadata on zookeeper with Last
Add Confirmed. (LAC)
Client gets disconnected with Bookies.
Either bookie is down or network between client and bookie have issues.
Contact zoo keeper to get the list of available bookies.
Update ensemble set, register with bookkeeper.
Continue with new set.
Client gets disconnected with Zookeeper.
Tries to reestablish the connection.
Can continue to read and write to the ledger.
Until that time, no metadata operations can be performed.
• Can not create a ledger
• Can not seal a ledger.
• Can not open a ledger.
Reader Opens while writer is active.
Must be avoided by the application.
BK guarantees correctness.
Reader initiates recovery process.
• Fences bookie on the zookeeper.
• Informs all bookies in ensemble recovery started.
• After these steps writer will get write errors.(if actively writing)
• Reader contacts all bookies to learn last entry.
• Replicates last entry if it doesn’t have enough replicas.
• Updates zookeeper with LAC, and closes the ledger.
Recovery begins when the ledger is opened by the reader in recovery mode
• Check if the ledger needs recovery (not closed)
• Fence the ledger first and initiate recovery
• Step1: Flag that the ledger is in recovery by update ZooKeeper state.
• Step2 : Fence Bookies
• Step3 : Recover the Ledger
Fencing and Recovery
Ledger Fencing
BookKeeper
Distributed Store
Ledger
Write Non Recovery Read
Recovery ReadFence & Recover
Attempt to write
ZooKeeper
Cluster
B
Bookie Crashes - Auto Recovery
Bookie-1 Bookie-2 Bookie-N
BookKeeper
Cluster
Auditor (Lead)
Replicator
Worker
Auditor
(Follower)
Replicator
Worker
Auditor
(Follower)
Replicator
Worker
Machine-1 Machine-2 Machine-N
Auditor
• Starts on every Bookie machine, leader gets elected through ZooKeeper.
• One active auditor per cluster.
• Watch Bookie failures and manage under replicated ledgers list.
Replication Workers
• Responsible for performing replication to maintain quorum copies.
• Can run on any machine in the cluster, usually runs on each Bookie machine.
• Work on under replicated ledgers list published by the Auditor.
• Pick one ledger at a time, create a lock on ZooKeeper and replicate to local bookie.
• If local bookie is part of the ensemble, drop the lock and move to next one in the list.
Auto Recovery Components
Heterogeneous Stores and Tired Architecture
Log Store
Data Store
Archival Store
Clusters of storage serving App Instances
Log Store
Data Store
Archival Store
App Instance
App Instance App Instance
App Instance
App Instance
App Instance
App Instance
App Instance
Performance
Performance
Community Update
Projects built on BookKeeper
• Twitter Distributed Log : Manhattan, Pub/Sub, DeferredRPC
• Yahoo Cloud Messaging
• Salesforce Distributed Store.
• Huawei – HDFS NameNode
• HubSpot – WAL
• Majordodo – Distributed Resource Manager
Community
• 6 PMC members
• 8 Committers
• 20-25 active members
• 5 Enterprises actively using/contributing
More Info
https://cwiki.apache.org/confluence/display/BOOKKEEPER/BookKeeper+papers+and+presentations
thank y u
BACKUP
Inside the bookie
• Journal
• A journal file contains the BookKeeper transaction logs.
• One journal per bookie at a time.
• New journal file is created once the old one reaches max file size.
• Entry Log
• Entries from different ledgers are aggregated and written sequentially
• Offsets are kept as pointers in LedgerCache for fast lookup.
• One entry log per bookie at a time.
• New Entry Log file is created once old one reaches max size.
• Old entry log files are removed by the Garbage Collector Thread once they are not associated with any active ledger.
• Index Files
• One per ledger.
• Offsets of the entries in that ledger.
Data Management in Bookies
Ledger Recovery
WritePath - Add Entry
disk 2
fsync
ack
add
L2 - E3
L3 - E7
L1 - E4
L1 - E2
L2 - E1
L1 - E1
disk 1
L2 - E3
L3 - E7
L1 - E4
L1 - E2
L2 - E1
L1 - E1
async flush
cache Similar rates
Durability
Read-efficient
INDEX
Ledger device Journal device
The ledger abstraction
op op op op op op op op op op opop op op opop op
add
read
checkpoint
Ledger 1
Ledger 2
Ledger 3
Garbage collection / compaction
disk 2
L2 - E3
L3 - E7
L1 - E4
L1 - E2
L2 - E1
L1 - E1
disk 1
L2 - E3
L3 - E7
L2 - E1
L1 - E4
L1 - E2
L1 - E1
L1 - E4
L1 - E2
L2 - E1L1 - E1
L1 - E4
L1 - E2
L2 - E1
L1 - E1
Ledger 1 deleted
L2 - E1
Entry log Journal

More Related Content

What's hot

Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
confluent
 

What's hot (20)

TiDBのトランザクション
TiDBのトランザクションTiDBのトランザクション
TiDBのトランザクション
 
類義語検索と類義語ハイライト
類義語検索と類義語ハイライト類義語検索と類義語ハイライト
類義語検索と類義語ハイライト
 
Apache Kafka at LinkedIn
Apache Kafka at LinkedInApache Kafka at LinkedIn
Apache Kafka at LinkedIn
 
ビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分けビッグデータ処理データベースの全体像と使い分け
ビッグデータ処理データベースの全体像と使い分け
 
Fault, Error, Failure の違い
Fault, Error, Failure の違いFault, Error, Failure の違い
Fault, Error, Failure の違い
 
Verrazzanoご紹介
Verrazzanoご紹介Verrazzanoご紹介
Verrazzanoご紹介
 
ストリームデータ分散処理基盤Storm
ストリームデータ分散処理基盤Stormストリームデータ分散処理基盤Storm
ストリームデータ分散処理基盤Storm
 
Securing Kafka
Securing Kafka Securing Kafka
Securing Kafka
 
AWSで始めるサーバレスな RESTful API システム
AWSで始めるサーバレスな RESTful API システムAWSで始めるサーバレスな RESTful API システム
AWSで始めるサーバレスな RESTful API システム
 
Akkaで分散システム入門
Akkaで分散システム入門Akkaで分散システム入門
Akkaで分散システム入門
 
スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...
スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...
スキーマレスカラムナフォーマット「Yosegi」で実現する スキーマの柔軟性と処理性能を両立したログ収集システム / Hadoop / Spark Con...
 
並行実行制御の最適化手法
並行実行制御の最適化手法並行実行制御の最適化手法
並行実行制御の最適化手法
 
Cassandraのしくみ データの読み書き編
Cassandraのしくみ データの読み書き編Cassandraのしくみ データの読み書き編
Cassandraのしくみ データの読み書き編
 
コンテナにおけるパフォーマンス調査でハマった話
コンテナにおけるパフォーマンス調査でハマった話コンテナにおけるパフォーマンス調査でハマった話
コンテナにおけるパフォーマンス調査でハマった話
 
DSIRNLP #3 LZ4 の速さの秘密に迫ってみる
DSIRNLP #3 LZ4 の速さの秘密に迫ってみるDSIRNLP #3 LZ4 の速さの秘密に迫ってみる
DSIRNLP #3 LZ4 の速さの秘密に迫ってみる
 
Java EE から Quarkus による開発への移行について
Java EE から Quarkus による開発への移行についてJava EE から Quarkus による開発への移行について
Java EE から Quarkus による開発への移行について
 
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
Ingesting and Processing IoT Data Using MQTT, Kafka Connect and Kafka Streams...
 
Logicadの秒間16万リクエストをさばく広告入札システムにおける、gRPCの活用事例
Logicadの秒間16万リクエストをさばく広告入札システムにおける、gRPCの活用事例Logicadの秒間16万リクエストをさばく広告入札システムにおける、gRPCの活用事例
Logicadの秒間16万リクエストをさばく広告入札システムにおける、gRPCの活用事例
 
FizzBuzzで学ぶJavaの進化
FizzBuzzで学ぶJavaの進化FizzBuzzで学ぶJavaの進化
FizzBuzzで学ぶJavaの進化
 
Edomae 2015 - マルウェアを解析してみよう
Edomae 2015 - マルウェアを解析してみようEdomae 2015 - マルウェアを解析してみよう
Edomae 2015 - マルウェアを解析してみよう
 

Similar to Apache BookKeeper Distributed Store- a Salesforce use case

Building High-Throughput, Low-Latency Pipelines in Kafka
Building High-Throughput, Low-Latency Pipelines in KafkaBuilding High-Throughput, Low-Latency Pipelines in Kafka
Building High-Throughput, Low-Latency Pipelines in Kafka
confluent
 

Similar to Apache BookKeeper Distributed Store- a Salesforce use case (20)

Apache con2016final
Apache con2016final Apache con2016final
Apache con2016final
 
Putting Kafka Into Overdrive
Putting Kafka Into OverdrivePutting Kafka Into Overdrive
Putting Kafka Into Overdrive
 
How pulsar stores data at Pulsar-na-summit-2021.pptx (1)
How pulsar stores data at Pulsar-na-summit-2021.pptx (1)How pulsar stores data at Pulsar-na-summit-2021.pptx (1)
How pulsar stores data at Pulsar-na-summit-2021.pptx (1)
 
Metrics are Not Enough: Monitoring Apache Kafka / Gwen Shapira (Confluent)
Metrics are Not Enough: Monitoring Apache Kafka / Gwen Shapira (Confluent)Metrics are Not Enough: Monitoring Apache Kafka / Gwen Shapira (Confluent)
Metrics are Not Enough: Monitoring Apache Kafka / Gwen Shapira (Confluent)
 
How Pulsar Stores Your Data - Pulsar Summit NA 2021
How Pulsar Stores Your Data - Pulsar Summit NA 2021How Pulsar Stores Your Data - Pulsar Summit NA 2021
How Pulsar Stores Your Data - Pulsar Summit NA 2021
 
Spring Batch Introduction (and Bitbucket Project)
Spring Batch Introduction (and Bitbucket Project)Spring Batch Introduction (and Bitbucket Project)
Spring Batch Introduction (and Bitbucket Project)
 
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Apache ZooKeeper | Big Data Hadoop Spark Tutorial | CloudxLab
 
Monitoring Apache Kafka
Monitoring Apache KafkaMonitoring Apache Kafka
Monitoring Apache Kafka
 
NASIG 2021 Don't wait automate! Industry perspectives on KBART automation
NASIG 2021   Don't wait automate! Industry perspectives on KBART automationNASIG 2021   Don't wait automate! Industry perspectives on KBART automation
NASIG 2021 Don't wait automate! Industry perspectives on KBART automation
 
Building High-Throughput, Low-Latency Pipelines in Kafka
Building High-Throughput, Low-Latency Pipelines in KafkaBuilding High-Throughput, Low-Latency Pipelines in Kafka
Building High-Throughput, Low-Latency Pipelines in Kafka
 
kafka simplicity and complexity
kafka simplicity and complexitykafka simplicity and complexity
kafka simplicity and complexity
 
Best practices for highly available and large scale SolrCloud
Best practices for highly available and large scale SolrCloudBest practices for highly available and large scale SolrCloud
Best practices for highly available and large scale SolrCloud
 
Kafka at scale facebook israel
Kafka at scale   facebook israelKafka at scale   facebook israel
Kafka at scale facebook israel
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
Making Session Stores More Intelligent
Making Session Stores More IntelligentMaking Session Stores More Intelligent
Making Session Stores More Intelligent
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (PASSDC User Gr...
 
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
Locks, Blocks, and Snapshots: Maximizing Database Concurrency (New England SQ...
 
Apache Kafka as Message Queue for your microservices and other occasions
Apache Kafka as Message Queue for your microservices and other occasionsApache Kafka as Message Queue for your microservices and other occasions
Apache Kafka as Message Queue for your microservices and other occasions
 
Cashing in on logging and exception data
Cashing in on logging and exception dataCashing in on logging and exception data
Cashing in on logging and exception data
 
10135 b 11
10135 b 1110135 b 11
10135 b 11
 

More from Salesforce Engineering

More from Salesforce Engineering (20)

Locker Service Ready Lightning Components With Webpack
Locker Service Ready Lightning Components With WebpackLocker Service Ready Lightning Components With Webpack
Locker Service Ready Lightning Components With Webpack
 
Scaling HBase for Big Data
Scaling HBase for Big DataScaling HBase for Big Data
Scaling HBase for Big Data
 
Techniques to Effectively Monitor the Performance of Customers in the Cloud
Techniques to Effectively Monitor the Performance of Customers in the CloudTechniques to Effectively Monitor the Performance of Customers in the Cloud
Techniques to Effectively Monitor the Performance of Customers in the Cloud
 
Predictive System Performance Data Analysis
Predictive System Performance Data AnalysisPredictive System Performance Data Analysis
Predictive System Performance Data Analysis
 
Apache HBase State of the Project
Apache HBase State of the ProjectApache HBase State of the Project
Apache HBase State of the Project
 
Hit the Trail with Trailhead
Hit the Trail with TrailheadHit the Trail with Trailhead
Hit the Trail with Trailhead
 
HBase/PHOENIX @ Scale
HBase/PHOENIX @ ScaleHBase/PHOENIX @ Scale
HBase/PHOENIX @ Scale
 
Scaling up data science applications
Scaling up data science applicationsScaling up data science applications
Scaling up data science applications
 
Containers and Security for DevOps
Containers and Security for DevOpsContainers and Security for DevOps
Containers and Security for DevOps
 
Aspect Oriented Programming: Hidden Toolkit That You Already Have
Aspect Oriented Programming: Hidden Toolkit That You Already HaveAspect Oriented Programming: Hidden Toolkit That You Already Have
Aspect Oriented Programming: Hidden Toolkit That You Already Have
 
Monitoring @ Scale in Salesforce
Monitoring @ Scale in SalesforceMonitoring @ Scale in Salesforce
Monitoring @ Scale in Salesforce
 
Performance Tuning with XHProf
Performance Tuning with XHProfPerformance Tuning with XHProf
Performance Tuning with XHProf
 
A Smarter Pig: Building a SQL interface to Pig using Apache Calcite
A Smarter Pig: Building a SQL interface to Pig using Apache CalciteA Smarter Pig: Building a SQL interface to Pig using Apache Calcite
A Smarter Pig: Building a SQL interface to Pig using Apache Calcite
 
Implementing a Content Strategy Is Like Running 100 Miles
Implementing a Content Strategy Is Like Running 100 MilesImplementing a Content Strategy Is Like Running 100 Miles
Implementing a Content Strategy Is Like Running 100 Miles
 
Salesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief OverviewSalesforce Cloud Infrastructure and Challenges - A Brief Overview
Salesforce Cloud Infrastructure and Challenges - A Brief Overview
 
Koober Preduction IO Presentation
Koober Preduction IO PresentationKoober Preduction IO Presentation
Koober Preduction IO Presentation
 
Finding Security Issues Fast!
Finding Security Issues Fast!Finding Security Issues Fast!
Finding Security Issues Fast!
 
Microservices
MicroservicesMicroservices
Microservices
 
Global State Management of Micro Services
Global State Management of Micro ServicesGlobal State Management of Micro Services
Global State Management of Micro Services
 
The Future of Hbase
The Future of HbaseThe Future of Hbase
The Future of Hbase
 

Recently uploaded

AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
ankushspencer015
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Dr.Costas Sachpazis
 

Recently uploaded (20)

Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
AKTU Computer Networks notes --- Unit 3.pdf
AKTU Computer Networks notes ---  Unit 3.pdfAKTU Computer Networks notes ---  Unit 3.pdf
AKTU Computer Networks notes --- Unit 3.pdf
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 
Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...Call for Papers - International Journal of Intelligent Systems and Applicatio...
Call for Papers - International Journal of Intelligent Systems and Applicatio...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Unit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdfUnit 1 - Soil Classification and Compaction.pdf
Unit 1 - Soil Classification and Compaction.pdf
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 

Apache BookKeeper Distributed Store- a Salesforce use case

  • 1. Apache BookKeeper DISTRIBUTED STORE a Salesforce Use Case Venkateswararao Jujjuri (JV) Cloud Storage Architect vjujjuri@salesforce.com jujjuri@gmail.com @jvjujjuri | Twitter https://www.linkedin.com/in/jvjujjuri
  • 2. Agenda Salesforce needs and requirements Hunt and Selection BookKeeper Introduction Improvements and Enhancements As Service at Scale @ Salesforce Performance Community Q & A
  • 3. Salesforce Application Storage Needs Store for Persistent WAL, data, and objects Low, constant write latencies • Transaction Log, Smaller writes Low, constant Random Read latencies Highly available for immutable data • Append Only entries • Objects Highly Consistent for immutable data Long Term Storage Distributed and linearly scalable. On commodity hardware Low Operating Cost
  • 4. What Did we consider? Build vs. Buy • Time-To-Market, resources, cost etc. Finalists • Ceph • A CP System • w/Unreliable reads read path can behave like AP system. • Lot of effort to make it AP behavior on write path • Remember: Immutable data. • BookKeeper • CAP system, because of immutable/append only store. • Came close to what we want • Almost there but not everything.
  • 5. Apache Bookkeeper A highly consistent, available, replicated distributed log service. Immutable , append only store. Thick Client, Simple and Elegant placement policy • No Central Master • No complicated hashing/computing for placement Low latency, both on writes and reads. Runs on commodity hardware. Built for WAL use case, but can be expanded to other storage needs Uses ZooKeeper as consensuses resolver, and metadata store. Awesome Community.
  • 7. Apache BookKeeper A system to reliably log streams of records. Is designed to store write ahead logs for database like applications. Inspired by and designed to solve HDFS NameNode availability deficiencies. Opensource Chronology • 2008 Open Sourced contribution to ZooKeeper • 2011 Sub-Project of ZooKeeper. • 2012 Production
  • 8. Terminology Journal: Write ahead log Ledger: Log Stream Entry: Each entry of log record Client: Library, with the application. Bookie: Server Ensemble: Set of Bookies across which a ledger is striped. Cluster: All bookies belong to a given instance of Bookkeeper Write Quorum Size: Number of replicas. Ack Quorum Size: Number of responses needed before client’s write is satisfied. LAC: Last Add Confirmed.
  • 9. Guarantees • If an entry has been acknowledged, it must be readable. • If an entry is read once, it must always be readable. • If write of entry ‘n’ is successful, all entries until ‘n’ are successfully committed. Major Components • Thick Client; Carries heavy weight in the protocol. • Thin Server, Bookie. Bookies never initiate any interaction with ZooKeeper or fellow Bookies. • Zookeeper monitors Bookies. • Metadata is stored on Zookeeper. • Auditor to monitor bookies and identify under replicated ledgers. • Replication workers to replicate under replicated ledger copies. Highlights
  • 10. Create Ledger • Gets Writer Ledger Handle Add an entry to the Ledger • Write To the Ledger Open Ledger • Gives ReadOnly Ledger Handle. • May ask for non-recovery read handle. Get an entry from the ledger • Read from the ledger Close the ledger. Basic Operations
  • 11. Out-of-order write and In-Order Ack. • Application has liberty to pre-allocate entryIDs • Multiple application threads can write in parallel. User defined Ledger Names • Not restricted by BK generated ledger Names Explicit LAC updates • Added ReadLac, WriteLac to the protocol. • Maintain both piggy-back LAC and explicit LAC simultaneously. Enhancements - In the internal branch working to push upstream
  • 12. Conventional Name Space. • User defined Names • Treat LedgerId as an i-node. Disk scrubbers and Repairs • Actively hunt and repair bit-rots and corruptions Scalable Metadata Store • Separate and dedicated metadata store • Not restricted by ZK limitations Enhancements - Future
  • 13. Salesforce Application with BookKeeper Application Store Interface With Bookkeeper client User Library Bookies ZooKeeper Server Machine
  • 14. Guarantees • If an entry has been acknowledged, it must be readable. • If an entry is read once, it must always be readable. • If write of entry ‘n’ is successful, all entries until ‘n’ are successfully committed. Consistencies • Last Add Confirmed is consistency among readers • Fence is consistency among writers. Consistencies
  • 15. Out of order write and in order Ack 0 1 2 3 4 5 App A ( Writer ) 6 App B ( Writer ) 8 App C ( Writer ) 7
  • 16. Last Add Confirmed 0 1 2 3 4 5 App A ( Writer ) 6 App B ( Writer ) 8 App C ( Writer ) 7 LAC LAC App D (Reader) X LAC
  • 18. What Can Happen? Client side • Client Restarts • Client looses connection with zookeeper • Client looses connection with bookies. Bookie Side • Bookie Goes down • Disk(s) on bookie go bad, IO issues • Bookie gets disconnected from network. Zookeeper • Gets disconnected from rest of the cluster
  • 19. Writing Client Crash bookie bookie bookie zookeeper What is the last entry? • Nothing happens until a reader attempts to read. • Recovery process gets initiated when a process opens the ledger for reading. • Close the ledger on zoo keeper • Identify Last entry of the ledger. • Update metadata on zookeeper with Last Add Confirmed. (LAC)
  • 20. Client gets disconnected with Bookies. Either bookie is down or network between client and bookie have issues. Contact zoo keeper to get the list of available bookies. Update ensemble set, register with bookkeeper. Continue with new set.
  • 21. Client gets disconnected with Zookeeper. Tries to reestablish the connection. Can continue to read and write to the ledger. Until that time, no metadata operations can be performed. • Can not create a ledger • Can not seal a ledger. • Can not open a ledger.
  • 22. Reader Opens while writer is active. Must be avoided by the application. BK guarantees correctness. Reader initiates recovery process. • Fences bookie on the zookeeper. • Informs all bookies in ensemble recovery started. • After these steps writer will get write errors.(if actively writing) • Reader contacts all bookies to learn last entry. • Replicates last entry if it doesn’t have enough replicas. • Updates zookeeper with LAC, and closes the ledger.
  • 23. Recovery begins when the ledger is opened by the reader in recovery mode • Check if the ledger needs recovery (not closed) • Fence the ledger first and initiate recovery • Step1: Flag that the ledger is in recovery by update ZooKeeper state. • Step2 : Fence Bookies • Step3 : Recover the Ledger Fencing and Recovery
  • 24. Ledger Fencing BookKeeper Distributed Store Ledger Write Non Recovery Read Recovery ReadFence & Recover Attempt to write
  • 25. ZooKeeper Cluster B Bookie Crashes - Auto Recovery Bookie-1 Bookie-2 Bookie-N BookKeeper Cluster Auditor (Lead) Replicator Worker Auditor (Follower) Replicator Worker Auditor (Follower) Replicator Worker Machine-1 Machine-2 Machine-N
  • 26. Auditor • Starts on every Bookie machine, leader gets elected through ZooKeeper. • One active auditor per cluster. • Watch Bookie failures and manage under replicated ledgers list. Replication Workers • Responsible for performing replication to maintain quorum copies. • Can run on any machine in the cluster, usually runs on each Bookie machine. • Work on under replicated ledgers list published by the Auditor. • Pick one ledger at a time, create a lock on ZooKeeper and replicate to local bookie. • If local bookie is part of the ensemble, drop the lock and move to next one in the list. Auto Recovery Components
  • 27. Heterogeneous Stores and Tired Architecture Log Store Data Store Archival Store
  • 28. Clusters of storage serving App Instances Log Store Data Store Archival Store App Instance App Instance App Instance App Instance App Instance App Instance App Instance App Instance
  • 31. Community Update Projects built on BookKeeper • Twitter Distributed Log : Manhattan, Pub/Sub, DeferredRPC • Yahoo Cloud Messaging • Salesforce Distributed Store. • Huawei – HDFS NameNode • HubSpot – WAL • Majordodo – Distributed Resource Manager Community • 6 PMC members • 8 Committers • 20-25 active members • 5 Enterprises actively using/contributing More Info https://cwiki.apache.org/confluence/display/BOOKKEEPER/BookKeeper+papers+and+presentations
  • 33.
  • 36. • Journal • A journal file contains the BookKeeper transaction logs. • One journal per bookie at a time. • New journal file is created once the old one reaches max file size. • Entry Log • Entries from different ledgers are aggregated and written sequentially • Offsets are kept as pointers in LedgerCache for fast lookup. • One entry log per bookie at a time. • New Entry Log file is created once old one reaches max size. • Old entry log files are removed by the Garbage Collector Thread once they are not associated with any active ledger. • Index Files • One per ledger. • Offsets of the entries in that ledger. Data Management in Bookies
  • 38. WritePath - Add Entry disk 2 fsync ack add L2 - E3 L3 - E7 L1 - E4 L1 - E2 L2 - E1 L1 - E1 disk 1 L2 - E3 L3 - E7 L1 - E4 L1 - E2 L2 - E1 L1 - E1 async flush cache Similar rates Durability Read-efficient INDEX Ledger device Journal device
  • 39. The ledger abstraction op op op op op op op op op op opop op op opop op add read checkpoint Ledger 1 Ledger 2 Ledger 3
  • 40. Garbage collection / compaction disk 2 L2 - E3 L3 - E7 L1 - E4 L1 - E2 L2 - E1 L1 - E1 disk 1 L2 - E3 L3 - E7 L2 - E1 L1 - E4 L1 - E2 L1 - E1 L1 - E4 L1 - E2 L2 - E1L1 - E1 L1 - E4 L1 - E2 L2 - E1 L1 - E1 Ledger 1 deleted L2 - E1 Entry log Journal

Editor's Notes

  1. https://images.unsplash.com/photo-1444703686981-a3abbc4d4fe3?ixlib=rb-0.3.5&q=80&fm=jpg&crop=entropy&s=510562df272fc272c2e7b9a9189a6261
  2. CRC 32 and MAC Digests are used.
  3. CRC 32 and MAC Digests are used.
  4. CRC 32 and MAC Digests are used.
  5. CRC 32 and MAC Digests are used.
  6. https://static.pexels.com/photos/27911/pexels-photo-27911.jpg https://static.pexels.com/photos/14303/pexels-photo-14303.jpeg
  7. https://cwiki.apache.org/confluence/display/BOOKKEEPER/Fencing
  8. https://issues.apache.org/jira/secure/attachment/12543127/BookKeeper-Auto-Recovery-Updated-To-Latest.pdf
  9. https://cwiki.apache.org/confluence/display/BOOKKEEPER/Fencing
  10. CRC 32 and MAC Digests are used.
  11. CRC 32 and MAC Digests are used.
  12. https://unsplash.com/photos/i--IN3cvEjg
  13. CRC 32 and MAC Digests are used.