+2
日增长
15,803
stars
1,344
forks
220
watchers
1,481
prs
862
issues
60
releases
README
BadgerDB
!Badger mascot
BadgerDB is an embeddable, persistent and fast key-value (KV) database written in pure Go. It is the
underlying database for Dgraph, a fast, distributed graph
database. It's meant to be a performant alternative to non-Go-based key-value stores like RocksDB.
Project Status
Badger is stable and is being used to serve data sets worth hundreds of terabytes. Badger supports
concurrent ACID transactions with serializable snapshot isolation (SSI) guarantees. A Jepsen-style
bank test runs nightly for 8h, with --race flag and ensures the maintenance of transactional
guarantees. Badger has also been tested to work with filesystem level anomalies, to ensure
persistence and consistency. Badger is being used by a number of projects which includes Dgraph,
Jaeger Tracing, UsenetExpress, and many more.
The list of projects using Badger can be found here.
Please consult the [Changelog] for more detailed information on releases.
Note: Badger is built with go 1.23 and we refrain from bumping this version to minimize downstream
effects of those using Badger in applications built with older versions of Go.
[Changelog]: https://github.com/dgraph-io/badger/blob/main/CHANGELOG.md
Table of Contents
- BadgerDB
- Project Status
- Table of Contents
- Getting Started
- Installing
- Installing Badger Command Line Tool
- Choosing a version
- Badger Documentation
- Resources
- Blog Posts
- Design
- Comparisons
- Benchmarks
- Projects Using Badger
- Contributing
- Contact
Getting Started
Installing
To start using Badger, install Go 1.23 or above. Badger v3 and above needs go modules. From your
project, run the following command
sh
go get github.com/dgraph-io/badger/v4
This will retrieve the library.
Installing Badger Command Line Tool
Badger provides a CLI tool which can perform certain operations like offline backup/restore. To
install the Badger CLI, retrieve the repository and checkout the desired version. Then run
sh
cd badger
go install .
This will install the badger command line utility into your $GOBIN path.
Badger Documentation
Badger Documentation is available at https://badger.dgraph.io
Resources
Blog Posts
1. Introducing Badger: A fast key-value store written natively in Go
2. Make Badger crash resilient with ALICE
3. Badger vs LMDB vs BoltDB: Benchmarking key-value databases in Go
4. Concurrent ACID Transactions in Badger
Design
Badger was written with these design goals in mind:
- Write a key-value database in pure Go.
- Use latest research to build the fastest KV database for data sets spanning terabytes.
- Optimize for SSDs.
Badger’s design is based on a paper titled _[WiscKey: Separating Keys from Values in SSD-conscious
Storage][wisckey]_.
[wisckey]: https://www.usenix.org/system/files/conference/fast16/fast16-papers-lu.pdf
Comparisons
| Feature | Badger | RocksDB |Top issues
#2003GC doesn't seem to run10 comments · 2023-09-06#2287Unexpected memory limits on 386 runtime8 comments · 2026-05-25#2213Poor performance with streams (high CPU and memory usage)5 comments · 2025-07-17#2049[BUG]: db.Backup maybe see the `partial write` in one transaction5 comments · 2024-02-23#2226Ristretto Jemalloc linking error when running ./tesh.sh4 comments · 2025-09-28#2231Deadlock occurred during update3 comments · 2025-10-28#2224Add a builder API for iterator options3 comments · 2025-09-09#2190Memory Fluctuation Issue When using Jaeger with Badger3 comments · 2025-04-10
Latest release
v4.9.6 v4.9.6 2026-08-05What's Changed fix(compaction): restore size-ratio base level selection, clamped to the first non-empty level by @shiva-istari in https://github.com/dgraph-io/badger/pull/2330 Full Changelog: https://github.com/dgraph-io/badger/compare/v4.9.5...v4.9.6