SlideShare a Scribd company logo
1
TELENAV CONFIDENTIAL
RocksDB vs. BoltDB
Xun Liu & Jay
2
TELENAV CONFIDENTIAL
Agenda
•RocksDB
• What & Why & How
• Internal
• Use cases
•BoltDB
• History & Keywords & Project Status
• RocksDB vs. BoltDB
• Practice in OSRM
3
TELENAV CONFIDENTIAL
RocksDB
4
TELENAV CONFIDENTIAL
History
5
TELENAV CONFIDENTIAL
What is RocksDB
1. Key-value persistent store
2. Embedded
4. Optimized for flash
3. Log Structure base tree
5. Fork of LevelDB
More info:
https://github.com/CodeBear801/tech_summary/blob/master/t
ech-summary/tools/rocksdb/rocksdb_index.md
6
TELENAV CONFIDENTIAL
Why RocksDB
Write amplification
Traditional DB use B+ tree
Optimize for heavy write
7
TELENAV CONFIDENTIAL
Why RocksDB
Embedded
8
TELENAV CONFIDENTIAL
Why RocksDB
9
TELENAV CONFIDENTIAL
RocksDB architecture
10
TELENAV CONFIDENTIAL
RocksDB architecture
11
TELENAV CONFIDENTIAL
RocksDB architecture
12
TELENAV CONFIDENTIAL
RocksDB architecture
13
TELENAV CONFIDENTIAL
RocksDB architecture
14
TELENAV CONFIDENTIAL
RocksDB architecture
Topics we will focus on
- Avoid random write
- Single write + multiple read
- Snapshot + multiple version
concurrency control
15
TELENAV CONFIDENTIAL
Internal(levelDB)
16
TELENAV CONFIDENTIAL
Internal(Based on LevelDB)
1. Put
2. Compaction
3. Get
4. Concurrent read/write
17
TELENAV CONFIDENTIAL
RocksDB Example
Write operation is extremely fast, just one disk update(WAL) + one
memory write(skiplist)
18
TELENAV CONFIDENTIAL
19
TELENAV CONFIDENTIAL
Write Ahead Log
key =bob value =3
20
TELENAV CONFIDENTIAL
Write Ahead Log
key =bob value =3
21
TELENAV CONFIDENTIAL
Write Ahead Log
key =bob value =3
22
TELENAV CONFIDENTIAL
23
TELENAV CONFIDENTIAL
Skiplist – a balance of space and performance, CAS, lock free
24
TELENAV CONFIDENTIAL
Internal(Based on LevelDB)
1. Put
2. Compaction
3. Get
4. Concurrent read/write
25
TELENAV CONFIDENTIAL
When to trigger
- Size
- Seek
- Manual compaction
26
TELENAV CONFIDENTIAL
RocksDB put() -> compaction
27
TELENAV CONFIDENTIAL
RocksDB put() -> compaction
28
TELENAV CONFIDENTIAL
RocksDB put() -> compaction
29
TELENAV CONFIDENTIAL
Internal(Based on LevelDB)
1. Put
2. Compaction
3. Get
4. Concurrent read/write
30
TELENAV CONFIDENTIAL
RocksDB Example
31
TELENAV CONFIDENTIAL
RocksDB get() example
32
TELENAV CONFIDENTIAL
bloom filter
If bloom filter detect key is not in the set, then it
must not: never false negative
If bloom filter detect the key inside the set, then
there is high possibility its in, but also possible
not exist, which is false positive
For rocksDB, 99.9% of get() finds value in single
sstable load
33
TELENAV CONFIDENTIAL
SSTable(sorted string table)
34
TELENAV CONFIDENTIAL
Internal(Based on LevelDB)
1. Put
2. Compaction
3. Get
4. Concurrent read/write
35
TELENAV CONFIDENTIAL
Concurrent Read/Write
Challenges
- Performance
- What if compaction happens
during query?
- What if a key is updated
during reading?
- Consistent result(no stale data,
timeout)
36
TELENAV CONFIDENTIAL
Put write tasks into queue
37
TELENAV CONFIDENTIAL
38
TELENAV CONFIDENTIAL
39
TELENAV CONFIDENTIAL
40
TELENAV CONFIDENTIAL
41
TELENAV CONFIDENTIAL
Challenges
- Performance
- What if compaction happens
during query?
- What if a key is updated
during reading?
- Consistent result(no stale data,
timeout)
Solutions:
- Isolate action of compaction and
query
- Sequence ID + Version
42
TELENAV CONFIDENTIAL
43
TELENAV CONFIDENTIAL
44
TELENAV CONFIDENTIAL
45
TELENAV CONFIDENTIAL
46
TELENAV CONFIDENTIAL
When to delete
old sstable?
reference count
by version
47
TELENAV CONFIDENTIAL
48
TELENAV CONFIDENTIAL
Usage
49
TELENAV CONFIDENTIAL
#1 Chrome – storage engine
50
TELENAV CONFIDENTIAL
#1 Chrome – storage engine
51
TELENAV CONFIDENTIAL
#2 Calculation Engine – record state
52
TELENAV CONFIDENTIAL
#3 Realtime newsfeed processing
More
Writes
More
Data
More
Query
53
TELENAV CONFIDENTIAL
#4. Map Making/Map data aggregator
54
TELENAV CONFIDENTIAL
RocksDB Resources
Main pages
• https://github.com/facebook/rocksdb
• https://github.com/facebook/rocksdb/wiki
• https://github.com/google/leveldb/tree/master/doc
Posts
• RocksDB: A High Performance Embedded Key-Value Store for Flash Storage
• Code reading notes about LevelDB
Practices
• RocksDB usage at LinkedIn
• Linked FollowFeed - (ALT - Aggregator Leaf Tailer)
55
TELENAV CONFIDENTIAL
BoltDB
56
TELENAV CONFIDENTIAL
BoltDB History
• 2011, Howard Chu introduced MDB, a memory-mapped database backend
for OpenLDAP, later renamed to LMDB (Lightning Memory-Mapped
Database).
• 2013, Bolt initially started by Ben Johnson as a port of LMDB to Go, but
then the two projects diverged.
• The author of Bolt decided to focus on simplicity and providing the easy-to-use Go
API.
• 2018, Blot stable and widely used. Etcd-io forked for further improvement.
57
TELENAV CONFIDENTIAL
BoltDB Keywords
• Key/value
• Embedded
• Simplicity and easy-to-use API
• Fast
• B+ tree
• Pure Go
• Memory-mapped
58
TELENAV CONFIDENTIAL
BoltDB vs RocksDB
• B+ tree vs. LSM tree
• Optimizes for
• read-heavy/range scans vs. random writes
• Go vs. C++
https://github.com/etcd-io/bbolt#comparison-with-other-databases
59
TELENAV CONFIDENTIAL
BoltDB – Stable & Widely used
Project Status
• Bolt is stable, the API is fixed, and the file format is fixed.
• Full unit test coverage and randomized black box testing are
used to ensure database consistency and thread safety.
• Bolt is currently used in high-load production environments
serving databases as large as 1TB.
• Many companies such as Shopify and Heroku use Bolt-
backed services every day.
ÞBackend store of etcd
Þhttps://github.com/boltdb/bolt#other-projects-using-bolt
60
TELENAV CONFIDENTIAL
BoltDB Practice in OSRM
Generate DB
• Stores fromNodeID,toNodeID->wayID mapping, each key costs 16bytes, each value costs 8 bytes.
• DB file is about 28 GB(about 9.2GB after snappy compressed), ~5 billions keys.
• Generating process is about 4 hours.
Query
• Query tens of nodes only takes 1ms!
• Query 226390 wayIDs from 226394 nodeIDs, takes 1.399967 seconds. (shm)
References
§ https://github.com/Telenav/osrm-backend/issues/257
§ https://github.com/Telenav/osrm-backend/issues/272
61
TELENAV CONFIDENTIAL
BoltDB Resources
Main pages
• https://github.com/boltdb/bolt
• https://github.com/etcd-io/bbolt
• https://github.com/bmatsuo/lmdb-go
• https://github.com/dgraph-io/badger
Posts
• Intro to BoltDB: Painless Performant Persistence by Nate Finch.
• Bolt -- an embedded key/value database for Go by Progville
• https://tech.townsourced.com/post/boltdb-vs-badger/
• https://dgraph.io/blog/post/badger-lmdb-boltdb/
Practices
• https://github.com/Telenav/osrm-backend/issues/257
• https://github.com/Telenav/osrm-backend/issues/272

More Related Content

PPTX
How to Migrate from Oracle to EDB Postgres
PPTX
Basic introduction to power query
PDF
Arrow diagrams in Powerpoint
PDF
Business Case Development Framework
PPT
4 tools for quick market validation
PDF
[EPPG] Oracle to PostgreSQL, Challenges to Opportunity
PDF
EPIC CONTENT MARKETING
PPTX
Data Vault Overview
How to Migrate from Oracle to EDB Postgres
Basic introduction to power query
Arrow diagrams in Powerpoint
Business Case Development Framework
4 tools for quick market validation
[EPPG] Oracle to PostgreSQL, Challenges to Opportunity
EPIC CONTENT MARKETING
Data Vault Overview

What's hot (15)

PPTX
APMP Foundation Introduction
PDF
Data Migration PowerPoint Presentation Slides
PDF
Project Manager Toolkit in Powerpoint & Excel
PPT
Informatica session
PDF
Data Platform Architecture Principles and Evaluation Criteria
PDF
Call center solutions
PDF
Update on DSpace 7
PDF
#190 - Fyra-hinkar-principen 2021 | Ett sätt att strukturera din ekonomi som ...
PDF
Achieving Sales Target Powerpoint Presentation Slides
PDF
Commercial Strategy Plan
DOCX
Abdul ETL Resume
PPTX
PDF
Alfresco 4 manajemen konten dalam alfresco - by softbless - part 2
PDF
Considerations for Data Access in the Lakehouse
APMP Foundation Introduction
Data Migration PowerPoint Presentation Slides
Project Manager Toolkit in Powerpoint & Excel
Informatica session
Data Platform Architecture Principles and Evaluation Criteria
Call center solutions
Update on DSpace 7
#190 - Fyra-hinkar-principen 2021 | Ett sätt att strukturera din ekonomi som ...
Achieving Sales Target Powerpoint Presentation Slides
Commercial Strategy Plan
Abdul ETL Resume
Alfresco 4 manajemen konten dalam alfresco - by softbless - part 2
Considerations for Data Access in the Lakehouse
Ad

Similar to Rocksdb vs boltdb (20)

PDF
RocksDB storage engine for MySQL and MongoDB
PDF
RocksDB Performance and Reliability Practices
PPTX
YugaByte DB Internals - Storage Engine and Transactions
PDF
Database Solutions Used within Blockchain Platforms
PDF
MyRocks introduction and production deployment
PDF
TokuDB vs RocksDB
PPTX
MongoDB: Comparing WiredTiger In-Memory Engine to Redis
PPTX
The Hive Think Tank: Rocking the Database World with RocksDB
KEY
Hybrid MongoDB and RDBMS Applications
PPTX
Python Ireland Conference 2016 - Python and MongoDB Workshop
PDF
Boltdb - an embedded key value database
PDF
Learn Learn how to build your mobile back-end with MongoDB
PDF
Netflix Open Source Meetup Season 4 Episode 2
PDF
MongoDB vs Firebase
PDF
From Mobile to MongoDB: Store your app's data using Realm
PDF
MyRocks Deep Dive
PDF
kranonit S06E01 Игорь Цинько: High load
PDF
MongoDB Versatility: Scaling the MapMyFitness Platform
PPTX
Migrating from InnoDB and HBase to MyRocks at Facebook
PPTX
How does Apache Pegasus (incubating) community develop at SensorsData
RocksDB storage engine for MySQL and MongoDB
RocksDB Performance and Reliability Practices
YugaByte DB Internals - Storage Engine and Transactions
Database Solutions Used within Blockchain Platforms
MyRocks introduction and production deployment
TokuDB vs RocksDB
MongoDB: Comparing WiredTiger In-Memory Engine to Redis
The Hive Think Tank: Rocking the Database World with RocksDB
Hybrid MongoDB and RDBMS Applications
Python Ireland Conference 2016 - Python and MongoDB Workshop
Boltdb - an embedded key value database
Learn Learn how to build your mobile back-end with MongoDB
Netflix Open Source Meetup Season 4 Episode 2
MongoDB vs Firebase
From Mobile to MongoDB: Store your app's data using Realm
MyRocks Deep Dive
kranonit S06E01 Игорь Цинько: High load
MongoDB Versatility: Scaling the MapMyFitness Platform
Migrating from InnoDB and HBase to MyRocks at Facebook
How does Apache Pegasus (incubating) community develop at SensorsData
Ad

Recently uploaded (20)

PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
top salesforce developer skills in 2025.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
assetexplorer- product-overview - presentation
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
history of c programming in notes for students .pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Why Generative AI is the Future of Content, Code & Creativity?
top salesforce developer skills in 2025.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Navsoft: AI-Powered Business Solutions & Custom Software Development
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Understanding Forklifts - TECH EHS Solution
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Operating system designcfffgfgggggggvggggggggg
Odoo POS Development Services by CandidRoot Solutions
assetexplorer- product-overview - presentation
CHAPTER 2 - PM Management and IT Context
Designing Intelligence for the Shop Floor.pdf
Cost to Outsource Software Development in 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
history of c programming in notes for students .pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool

Rocksdb vs boltdb