Key-value engine
A key-value engine serves as the bottommost layer in a key-valuedatabase, unless you are going to build your own file system oroperating system. A key-value engine is crucial for a database becauseit manages all the persistent data directly.
Most key-value engines provide some common interfaces like Get
,Put
and Delete
. Some engines also allow you to iterate thekey-values in order efficiently, and most will provide specialfeatures for added efficiency.
Choosing a key value engine is the first step to build adatabase. Here are some important things we need to consider:
- The data structure. Different data structures are optimized fordifferent workloads. Some are good for reads and some are good forwrites, etc.
- Maturity. We don’t need a storage engine to be fancy but we want itto be reliable. Buggy engines ruin everything you build on top ofthem. We recommend using a battle-tested storage engine which hasbeen adopted by a lot of users.
- Performance. The performance of the storage engine limits theoverall performance of the whole database. So make sure the storageengine meets your expectation and has the potential to improve alongwith the database.
In this chapter, we will do a comparison between two well-known datastructures and guide you through the storage engine used in TiKV.