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

TL;DR

FOR BUSINESS

Open a free Amazon Business account

Business pricing, bulk buying and tax-exempt orders.

Create a free account

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

FALL

Fall Picks

As an affiliate, we earn on qualifying purchases.

You May Also Like

‘VPNs Are Lawful Technical Tools,’ Says EU Court In Landmark Copyright Ruling

The EU Court affirms that VPNs are legal tools, impacting copyright enforcement and user rights across Europe.

The Latest iPhone 18 News, Leaks, And Rumors: Release Date, Price Increases, And Color Options

Latest leaks suggest iPhone 18 will launch in September 2024 with a higher price and new color options. Here’s what is confirmed and what remains uncertain.

Warm-Up Rituals Before Deep Work: Priming Your Brain to Focus

Discover practical warm-up rituals that prime your brain for deep work. Learn how small routines can boost focus and productivity every day.

United Point (Residensi Berpadu) Condo For Rent In Segambut, Kuala Lumpur By JACKSON PANG – Edgeprop.my

JAC offers units at United Point Residensi Berpadu in Segambut for rent, attracting increased search interest amid rising demand for Kuala Lumpur condos.