Writing a Time Series Database from Scratch∞
A fascinating walkthrough for the new storage format that is going to be used in Prometheus 2.0. Starting with the requirements, it describes the current solutions, the problems with it, and the solution they implemented.
After all, it is synthetic and thus not worth much beyond a good first impression. Starting out about 20x above the initial design target, it was time to embed this into an actual Prometheus server, adding all the practical overhead and flakes only experienced in more realistic environments.
Some things are “standard” database techniques, like batching writes as much as possible, moving away from the one-file-per-series scheme, not touching old data at all, a write ahead log, using a data layout so
mmap can be used, … But there is also an inverted index for the queries, which is usually used in text indexing, and a scheme for intersecting sorted ids that reminds me of the leapfrog triejoin algorithm.