Faster Prometheus restarts with memory snapshot on shutdown

Memory snapshot on shutdown is a Prometheus feature flag that writes in-memory chunks and series to disk at shutdown so restarts replay less WAL. This page covers what it changes, its trade-offs, and how to roll it out.

On this page

Why a Prometheus restart on a large server takes so long, and how memory snapshot on shutdown helps

A large single Prometheus server can take a long time to come back after a restart or upgrade, and during that window queries, dashboards and alert evaluation may be missing or delayed. The memory-snapshot-on-shutdown feature flag, enabled with --enable-feature=memory-snapshot-on-shutdown, reduces startup time by restoring memory state from a snapshot instead of rebuilding everything from the write-ahead log. At shutdown, Prometheus writes in-memory chunks and series information to disk, so on startup it restores that state along with the memory-mapped chunks and replays the write-ahead log only for the parts not captured in the snapshot.

Teams usually need this when a server holds a large number of active series and has a long write-ahead log, and when restarts happen often enough for the gap to matter, such as during routine upgrades to a new minor release or config reloads that require a restart. The flag is most useful where the monitoring gap itself is the problem. Confirm with your own environment how long a restart takes today by measuring startup time and the amount of write-ahead log replayed before you change anything. Also check that your shutdown is clean, because the benefit depends on Prometheus reaching its shutdown path rather than being killed by the process manager.

The flag does not change how Prometheus stores data. Local storage stays a single-node database, with the same two-hour blocks, write-ahead log and retention settings, and the snapshot does not replicate anything to another machine. Losing the server still means losing the local data that has not been persisted, and high availability still requires running a second Prometheus or sending data to external long-term storage. Before enabling the flag in production, test the upgrade path in a non-production environment, and confirm the behavior for your Prometheus version against the Prometheus feature flags documentation.

Configuration options and when each fits

This table compares the memory-snapshot-on-shutdown feature flag with the default restart behavior and with other ways to limit downtime, such as maintenance windows, a second server, or agent mode. Read each row against your own restart frequency, query needs and tolerance for gaps in data. The main takeaway is that the flag shortens restarts on one server but does not remove the need for a plan when you cannot afford any gap.

OptionWhat it changesTrade-offWhen it fits
Default behavior (flag off)Prometheus replays the write-ahead log on startup to rebuild in-memory series and chunksStartup time grows with the amount of WAL to replay, so large servers stay unavailable longer after a restartSmall servers, or teams that restart rarely and can accept a longer startup
Memory snapshot flag onWrites in-memory chunks and series information to disk at shutdown, so startup restores most state from the snapshotAdds work at shutdown, and only the parts not in the snapshot are replayed from the WAL, so confirm behavior in your versionLarge single servers where restarts for upgrades or config reloads cause long gaps
Planned maintenance windowSchedules restarts for low-impact periods and announces the expected gap in dashboards and alertsGaps in data and alerting still occur, and the window must be coordinated with on-call teamsOrganizations with predictable change calendars and tolerance for a known outage
Second server for overlapRuns a twin Prometheus scraping the same targets, so one can restart while the other answers queriesDoubles scrape load, storage and memory, and queries must be routed or merged across both serversTeams that need continuous query and alerting coverage during upgrades
Agent mode for collectionScrapes and forwards samples through remote write, with no local query or rule evaluationLocal queries, rules and alerting move elsewhere, so this is a design change rather than a restart fixEdge sites or many clusters where a central store should hold the data
Remote write to long-term storageKeeps copies of samples in an external system that survives a local restartAdds a second system to run and secure, and the local server still restarts with its own startup costEstates that already need long-term retention beyond the local store

How to enable the feature flag and verify the restart

This sequence turns on memory snapshot on shutdown in a non-production Prometheus server, confirms the restart reads the snapshot, and gives you measured startup evidence and a tested way back before the change reaches production.

  1. Confirm the Prometheus version and release line

    The platform engineer running the server records the exact Prometheus version from the server's version output and the running container or package. Compare it against the current release line on the release cycle page, including whether the build is a current minor release or a long-term support line, because minor releases stop receiving bug fixes after their six-week cycle. Upgrade the non-production copy first if it is behind a supported line. Done when the version and its support status are written into the change record.

  2. Check disk space and snapshot file permissions

    The storage owner checks free space on the volume holding the data directory and confirms that the Prometheus service account can write to it, since the snapshot is written at shutdown alongside the existing blocks and write-ahead log. Review the current size of the data directory and leave headroom for the snapshot, which the feature flags documentation describes as in-memory chunks and series information. Also confirm the process can create and replace files there and that your backup job does not lock them. Done when a test write as the service account succeeds and the free-space figure is recorded.

  3. Take a backup of the data directory

    The operator copies the data directory to a separate location while Prometheus is stopped, or uses a volume snapshot taken with the server stopped, so a restore point exists before the flag changes how shutdown behaves. Record the copy's location, size and checksum or file count. This copy is also the rollback source if the new startup path misbehaves. Done when the copy can be listed and its contents match the source.

  4. Enable the feature flag at startup

    The operator adds the memory-snapshot-on-shutdown flag to the startup arguments of the non-production server, using the syntax shown in the feature flags documentation for enabling features at launch, and does not change any other flags in the same change. Keep the flag in the service unit, container definition or configuration file that your team manages, so it survives restarts and is visible in review. Done when the running process's command line shows the flag and the configuration is committed to the team's change record.

  5. Perform a controlled shutdown and restart

    The operator stops the non-production server through its normal service manager so Prometheus runs its shutdown path, then starts it again and notes the exact times of both actions. Avoid killing the process with a forced signal, because that skips the shutdown path where the snapshot is written. Check that the shutdown completed without errors and that the data directory now contains a snapshot file alongside the blocks. Done when the snapshot is present and the shutdown log shows a clean exit.

  6. Check startup logs and the restore path

    The operator reads the startup log from the restart and looks for messages showing whether memory was restored from the snapshot and how much write-ahead log replay ran for the parts not covered by it. Compare that with a restart of the same server without the flag, using the backup copy if needed, so the difference is visible rather than assumed. Investigate any warnings about a missing or unreadable snapshot before continuing. Done when the log confirms snapshot restore and the replay scope is recorded.

  7. Measure time to readiness and test queries

    The operator measures the time from process start until the readiness endpoint reports ready and until a known PromQL query returns the expected recent samples, then repeats the test at least once to see whether the result holds. Run the same measurement against a restart without the flag and compare the two results in the change record. Confirm that active targets and alert rules load as expected. Done when both measurements are recorded and the query results match the pre-change baseline.

  8. Document the rollback and decide on rollout

    The operator writes the rollback as a tested procedure: stop the server, remove the flag from the startup configuration, restore the data directory from the backup if the snapshot caused problems, and start the server again. Run that procedure once in the non-production environment so the steps are known to work. Only after both the timing and the rollback are verified does the team schedule the change for production. Done when the rollback steps are signed off and the production change request references the non-production results.

Security and operational considerations for snapshot files on disk

The memory snapshot is a copy of server state written to the same disk as the TSDB, so it inherits the same security and operational obligations. The cards below cover what sits on disk, who can trigger shutdown and reload, how to watch restarts, and where to confirm the details for your environment.

Treat the snapshot as data at rest

The snapshot holds in-memory series and chunk information written to the data directory at shutdown, so it contains the same metric content as the TSDB blocks. Apply the same disk encryption, filesystem permissions and access rules you use for the data directory. Confirm with your storage team which volume the snapshot lands on and whether that volume is encrypted.

Feature flags docs

Scope backups to include the snapshot

A backup that copies only completed TSDB blocks will miss state the snapshot carries, and a restore from an older copy may pair stale files with a newer write-ahead log. Decide whether your backup job runs while Prometheus is stopped or captures a consistent view of the data directory. Test a restore on a non-production host before you rely on it.

Restrict who can stop and reload

Admin HTTP APIs are disabled by default, and the lifecycle endpoints that trigger reload and shutdown only exist when --web.enable-lifecycle is set. Leave both off unless a defined runbook needs them. When enabled, limit access to the operations team and route requests through your authenticated network path, since a shutdown that writes a snapshot is a change to production state.

Security model

Plan shutdown as a change

Use the same change process for shutdowns that you use for upgrades. Record the Prometheus version, the flag set, the time of shutdown and the expected restart window. Add a check that the new process logs successful startup from the snapshot before you close the change, so a silent fallback to full WAL replay does not go unnoticed.

Watch restart duration and logs

Measure how long each restart takes before and after enabling the flag, and alert when startup exceeds your baseline. Review startup log lines for snapshot load errors. If a restart is slow without an obvious cause, compare it with the WAL size, since replay still runs for data not covered by the snapshot.

Check for corruption after unclean shutdowns

A crash, power loss or forced kill can stop Prometheus before the snapshot is complete. Treat any unclean shutdown as a reason to inspect the data directory and the startup log before assuming the restart was clean. Keep the storage and operations documentation on hand so the on-call team knows the recovery steps for the TSDB.

Storage docs

Questions buyers ask about the memory snapshot effort and cost

Is the memory snapshot on shutdown feature free to use?

Yes, the feature itself carries no license fee, because Prometheus is licensed under Apache-2.0 and has no paid enterprise edition. The cost of enabling it comes from the infrastructure the server already runs on, the people who test and operate the change, and any time spent on the rollout. Ask your team to account for the planning and verification hours, the test environment, and the ongoing effort to keep the flag under review across Prometheus upgrades.

What drives the cost of a memory snapshot rollout?

The main driver is how large and how critical the Prometheus server is. A server with many series, long restart windows and heavy alerting dependencies needs more testing before a change, and each restart window has to be measured. Other cost drivers include:

  • The number of Prometheus servers that need the change and whether they share a standard configuration.
  • How many environments (test, staging, production) must reproduce the restart behavior before rollout.
  • Whether the team already has a documented upgrade and restart procedure.
  • The cost of any downtime gaps, such as alerts that stop firing during a restart.

Ask any quote to split these components so you can see what is one-time work and what recurs.

How long does a memory snapshot rollout take?

The honest answer depends on the server, the change window and how many environments need validation, so no fixed duration applies to every deployment. Plan for time in four phases: measuring current restart and WAL replay behavior, enabling the flag in a non-production copy, observing a full restart cycle, and then rolling out to production in agreed windows. Confirm the expected timeline in writing with any partner before work starts, and ask which phases are included in the quote.

What does the internal team need to provide for this work?

The internal team needs to supply access to the Prometheus configuration, a representative non-production environment, and people who can approve restart windows and interpret the results. Engineers should be ready to check the storage path, the disk capacity used for the snapshot, and the monitoring that watches the server during restart. Someone must also own the decision to roll the change out, because the change affects how the server recovers after every restart or upgrade.

Can our own engineers enable the feature without outside help?

Yes, a team that already runs Prometheus can enable the feature by setting the --enable-feature=memory-snapshot-on-shutdown flag. The difficulty lies in proving the change is safe for your specific server: measuring startup time before and after, confirming that the snapshot is written cleanly at shutdown, and checking that restarts behave correctly during upgrades. Teams without a tested restart procedure or without a non-production copy of the server usually find the verification work takes longer than the flag change itself.

What happens if the snapshot does not work as expected?

If the snapshot is not written or restored as expected, the server falls back to replaying the write-ahead log for the parts that are not covered by the snapshot, which means startup takes longer than planned. Make sure your rollback path is documented: know how to remove the flag, how to restart the server cleanly, and who makes that decision during a maintenance window. Confirm the failure behavior against the official feature flag documentation for the version you run before production use.

When should we hire a partner for this work?

Hire a partner when the Prometheus estate is large, critical or shared across several teams, or when your internal team lacks the time to design a test plan and run the verification. A partner is also useful when the change must fit into a compliance-driven change process. DeployOpen plans, implements, documents and supports self-hosted open-source platforms inside your own infrastructure, and most engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts. Ask for a written scope that lists the environments, the restart measurements and the handover documents.

Will the feature reduce our ongoing operating costs?

It can reduce the time your monitoring is unavailable during restarts and upgrades, but it does not remove the cost of running Prometheus. Ongoing costs continue to come from storage, compute, staff time for upgrades and monitoring, and any support retainer you choose. Measure restart duration before and after the change so you can judge whether the saving in downtime justifies the time spent on testing and upkeep.

How shutdown snapshot and startup replay fit together

The diagram starts at a graceful shutdown, where Prometheus with --enable-feature=memory-snapshot-on-shutdown writes in-memory chunks and series information to disk. On startup, the snapshot restores memory state and the m-mapped chunks, and the write-ahead log is replayed only for the parts not already captured in the snapshot. The branch on the right covers an unclean shutdown, where no snapshot is written and the full WAL replay path applies. Check the snapshot age and startup logs after each restart to confirm which path ran.

Startup path after a graceful shutdown versus an unclean one.

What changes for operators during upgrades and maintenance

The main change for operators is that a planned restart of a large Prometheus server gets shorter and more predictable, but only if the feature is enabled on purpose and verified on the release you run. Start by setting --enable-feature=memory-snapshot-on-shutdown in the same change set that schedules the maintenance window, then measure the restart time of a staging server with a realistic series count before you rely on it in production. Any restart still leaves a gap in rule evaluation and alert coverage while the server is down, so the window you schedule should reflect the measured startup time, not the time you hoped for.

The feature also changes the runbook itself. The shutdown step now writes in-memory chunks and series information to disk, so a graceful stop has to complete cleanly before the process is killed. Your runbook should therefore give the stop a generous timeout, confirm the snapshot files are present, and check that startup has replayed only the remaining write-ahead log. Treat an unclean stop as a different case with a longer recovery, and write that case into the runbook explicitly. Alertmanager is not restarted by this feature, so confirm its state and silences separately before and after the Prometheus restart.

Choose the release line first, because the feature flag is only useful on a version you can keep patched. The release cycle guidance says a minor release generally stops receiving bug fixes six weeks after its cycle begins, while long-term support lines receive fixes for one year. If you run a standard minor, plan to upgrade within that window, and rerun the restart measurement on every upgrade. If you run an LTS line, confirm the flag behaves the same on that line and check its end-of-support date before you commit the runbook to it. Use the Prometheus release cycle page to set the upgrade calendar that the restart procedure depends on.

How DeployOpen works on this

DeployOpen scopes memory-snapshot-on-shutdown as a planned change to your existing Prometheus servers, not a switch flipped during a maintenance window. We first measure how restarts behave today, then enable the feature flag in a controlled way, test startup behavior against your own data and hand over a runbook your team can repeat on each upgrade.

How we scope

  • Inventory every Prometheus server, its version, storage path and current restart duration before any change is proposed.
  • Confirm which servers run the feature flag on a supported release and which need an upgrade first.
  • Agree in writing which servers, environments and restart procedures are in scope, with fixed deliverables and timelines.

How we build

  • Enable --enable-feature=memory-snapshot-on-shutdown in a staging copy and confirm the snapshot is written at clean shutdown.
  • Measure startup time with and without the snapshot, including how much WAL replay still occurs on the test server.
  • Update service units, configuration management and disk sizing so the snapshot location has room and survives host restarts.

How we hand over

  • Deliver a runbook covering the shutdown sequence, expected startup logs and the steps to recover if a snapshot is not used.
  • Document the test results, measured restart times and the settings chosen for each server in your environment.
  • Walk your platform and on-call engineers through the procedure and the signals that show a restart went wrong.

How we support

  • Retest the restart procedure when you move to a new Prometheus release line, since flags and behavior can change between versions.
  • Ongoing support, upgrades and continuous testing are available as a retainer after the initial handover.
  • Confirm with your team and the Prometheus feature flag documentation which behaviors apply to your exact release before rollout.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.