We’re making Prometheus use less memory and restart faster

Published: 15 Oct 2020

A few months ago, I blogged about memory-mapping of full chunks of the head block from disk. The feature, which was introduced in Prometheus v2.19.0, brings down memory usage and restart time.

Additionally, there’s another Prometheus feature in progress that snapshots in-memory data during shutdown for faster restarts; it’s expected to cut down the restart times by a big factor.

These two features formed the core of my KubeCon + CloudNativeCon EU talk, entitled Make Prometheus Use Less Memory and Restart Faster. Have a look at the talk to learn more!

Here’s a brief recap of the features:

Memory-mapping full chunks of head block offloads the chunks to disk regularly and only loads them in the memory when required — hence effectively reducing the memory usage. And with having chunks on disk, we can skip a lot of samples from the WAL during replay and reduce the restart time. If you are interested in knowing more low-level details of this feature, you can have a look at this blog post.

After memory mapping, we still have some data in the memory. With snapshotting, we dump this remaining in-memory data to the disk during shutdown. During startup, we can restore the in-memory state with this snapshot and the memory-mapped chunks, while skipping the WAL entirely. This brings down the restart time by a big factor, as WAL replay is the slowest part of the restart.

This work is still in progress and some details might change. We will be blogging about this as soon as the feature is in, so don’t forget to check back for updates!

Related Posts

Grafana Labs Director of Community Richard Hartmann and Robust Perception's Brian Brazil lead an introduction to the OpenMetrics format for standardizing metrics exposition.
At KubeCon + CloudNative Con Europe 2020, I finally delivered the last part of a trilogy of talks about histograms in Prometheus, this time focusing on the future: a proposal for better histograms that will now be discussed by the Prometheus developer community.
KubeCon + CloudNativeCon EU is going virtual next week. Here’s where you will find Grafana Labs team members during the conference.