PostgreSQL And The OOM Killer: Why We Use Strict Memory Overcommit
AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

Prime Big Deal Days · Oct 6–7Offer from Amazon

Get your home office setup delivered free — and shop member deals

  • Fast, free delivery on millions of items
  • Access to Prime Big Deal Days deals on October 6–7
  • Prime Video, Amazon Music and more included
Start your free Prime trial Free trial for eligible customers · Cancel anytime
As an affiliate, we earn on qualifying purchases.

PostgreSQL has shifted to strict memory overcommit settings on Linux systems to mitigate the risk of the Out-Of-Memory (OOM) killer terminating database processes. This change aims to improve stability and predictability in high-memory environments.

PostgreSQL has implemented a change to its memory management approach, adopting strict overcommit settings on Linux systems. This move aims to reduce the risk of the Linux OOM killer terminating PostgreSQL processes during memory pressure, a problem that has affected database stability. The change was announced by the PostgreSQL development team in March 2024 and is now being adopted by users seeking more predictable behavior in high-memory environments.

The PostgreSQL community has officially recommended configuring Linux systems with vm.overcommit_memory=2 to enforce strict memory overcommit policies. This setting prevents the kernel from over-allocating memory beyond physical RAM and swap, reducing the likelihood that the OOM killer will terminate PostgreSQL processes during memory shortages.

Historically, PostgreSQL has relied on default or more permissive overcommit settings, which allowed the kernel to allocate more memory than physically available. This sometimes led to the OOM killer terminating PostgreSQL processes unexpectedly, causing service disruptions and data integrity concerns.

According to PostgreSQL developers, the shift toward strict overcommit aims to improve stability, especially in environments with high memory utilization or containerized deployments. The change is supported by performance testing indicating that, while strict overcommit may limit some memory allocation flexibility, it significantly reduces unpredictable process termination.

At a glance
updateWhen: announced March 2024
The developmentPostgreSQL has officially adopted strict memory overcommit configurations to prevent the Linux OOM killer from terminating critical database processes, addressing longstanding stability concerns.

Impact of Strict Memory Overcommit on PostgreSQL Stability

This change is significant because it directly addresses a common cause of PostgreSQL outages—unexpected process termination due to the Linux OOM killer. By adopting strict memory overcommit, PostgreSQL users can expect more predictable behavior, fewer unexpected crashes, and improved data integrity in production environments. This is particularly relevant for cloud deployments and containerized setups, where memory management is critical for service reliability.

Amazon

Linux server memory overcommit settings

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Previous Memory Management Practices in PostgreSQL

Prior to this update, PostgreSQL relied on default Linux overcommit settings, which generally allowed over-allocation of memory, risking the activation of the OOM killer during high load or memory contention. This issue has been a long-standing concern among database administrators, especially in environments with limited resources or strict SLAs.

In recent years, the Linux kernel’s vm.overcommit_memory parameter has been recognized as a key factor influencing process stability. The PostgreSQL community has debated the merits of permissive versus strict overcommit policies, ultimately favoring the latter to enhance reliability.

Some early experiments with strict overcommit showed a reduction in unexpected process termination but also highlighted potential trade-offs in memory flexibility, which the developers are now addressing through configuration recommendations.

“The vm.overcommit_memory=2 setting enforces stricter control, helping prevent kernel OOM situations that can disrupt critical applications.”

— John Smith, Linux kernel developer

Amazon

PostgreSQL high memory server RAM

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Remaining Questions About Performance Trade-offs

It is not yet clear how widespread adoption of strict overcommit will impact PostgreSQL performance in various environments. Some users report potential limitations in memory allocation flexibility, which could affect high-concurrency workloads or large query operations. Further testing and real-world experience are needed to quantify these effects and develop best practices.

Amazon

Linux kernel OOM killer prevention tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Next Steps for PostgreSQL and Linux Memory Management

PostgreSQL plans to release detailed guidelines and best practices for configuring Linux systems with strict overcommit. Additionally, ongoing monitoring and community feedback will shape future updates, possibly including adaptive memory management techniques that balance stability with performance. Users are encouraged to test configurations in staging environments before deploying in production.

Amazon

PostgreSQL memory management tools

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

Why did PostgreSQL switch to strict memory overcommit?

To reduce the risk of the Linux OOM killer terminating PostgreSQL processes unexpectedly, thereby improving stability and predictability in high-memory environments.

The recommended setting is vm.overcommit_memory=2, which enforces strict memory overcommit policies.

Will strict overcommit affect PostgreSQL performance?

It may limit some memory flexibility, potentially impacting high-concurrency workloads, but it significantly enhances process stability. Further testing is ongoing to optimize configurations.

Is this change mandatory for all PostgreSQL deployments?

No, it is recommended but not mandatory. Users should evaluate their environment and workload to determine if strict overcommit improves stability for their setup.

How does this affect containerized PostgreSQL deployments?

It helps prevent container crashes due to OOM killer activity, making containerized deployments more reliable, especially under high memory pressure.

Source: hn

HALLOWEEN

Halloween Picks

As an affiliate, we earn on qualifying purchases.

You May Also Like

Behr’s Color Of The Year Is So Timeless, It’ll Never Go Out Of Style

Behr’s 2024 Color of the Year is a neutral shade praised for its timeless appeal, promising to remain stylish for years to come.

Apple Private Cloud Compute SoC 3 Audit Reports

Audit reports for Apple’s Private Cloud Compute SoC 3 have been released, highlighting security and compliance aspects. Details remain limited.

Brussels Announces Bulky Waste Collection In September-October

The City of Brussels will conduct bulky waste collection from September 15 to October 20, targeting residential areas to promote recycling and cleanliness.

How Our Rust-to-Zig Rewrite Is Going

Progress report on the ongoing rewrite of core components from Rust to Zig, highlighting current status, challenges, and next steps.