PostgreSQL And The OOM Killer: Why We Use Strict Memory Overcommit

TL;DR

PostgreSQL developers have implemented stricter memory overcommit policies to mitigate the risk of Linux’s Out-Of-Memory killer terminating database processes. This change aims to improve stability at the cost of potential resource limitations.

PostgreSQL has adopted a policy of strict memory overcommit settings to prevent the Linux Out-Of-Memory (OOM) killer from terminating database processes during periods of high memory demand. This change, confirmed by PostgreSQL developers, aims to improve system stability for users running large or resource-intensive databases.

PostgreSQL’s recent updates include configuring Linux kernel parameters to enforce stricter memory overcommit policies. Specifically, the database now recommends setting vm.overcommit_memory=2, which instructs the kernel to avoid over-allocating memory beyond the physical RAM and swap available. This approach reduces the likelihood of the OOM killer intervening and terminating PostgreSQL processes during memory pressure.

According to PostgreSQL project documentation and discussions on developer mailing lists, this change was motivated by incidents where the OOM killer terminated database processes unexpectedly, leading to data loss or service disruption. The new configuration aims to prioritize process stability, especially in environments with limited resources or unpredictable workloads.

While this strategy enhances stability, it also means that PostgreSQL may refuse to allocate additional memory when the system is near its limits, potentially impacting performance or scalability in some scenarios. Users are advised to carefully tune their system’s memory settings and monitor resource usage accordingly.

At a glance
reportWhen: announced March 2024
The developmentPostgreSQL has shifted to a stricter memory overcommit strategy to prevent the Linux OOM killer from terminating database processes during high memory usage.

Implications of Memory Overcommit Settings for PostgreSQL Stability

This development is significant because it directly affects how PostgreSQL manages system resources, especially on Linux servers. By adopting strict memory overcommit policies, PostgreSQL aims to reduce unexpected process termination caused by the OOM killer, which can lead to data corruption or service outages. For organizations running large-scale or critical databases, this change improves reliability and predictability, although it requires careful system tuning to avoid performance bottlenecks.

Experts note that this shift reflects a broader trend in database and system administration towards more conservative memory management to prioritize stability over maximum resource utilization. It underscores the importance of understanding Linux kernel parameters and their impact on application performance.

Amazon

Linux server memory overcommit settings

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background on Linux Memory Management and PostgreSQL

Linux’s memory management includes the overcommit feature, which controls how the kernel allocates memory to processes. Historically, many Linux distributions default to a permissive setting (vm.overcommit_memory=0), allowing processes to allocate more memory than physically available, trusting the kernel to handle overcommitment safely. However, this can lead to situations where the OOM killer terminates processes unexpectedly.

PostgreSQL, as a resource-intensive database, is particularly vulnerable to such terminations. In recent years, the PostgreSQL community has increasingly recognized the need for more predictable memory management, especially in cloud and virtualized environments where resource limits are strict. The recent shift to stricter overcommit policies aligns with this trend, aiming to prevent abrupt process kills and data loss.

Prior to this change, some users experienced database crashes or performance degradation due to the OOM killer intervening during peak workloads. The new recommendations and configuration adjustments are part of ongoing efforts to improve database stability under various system conditions.

“Implementing strict memory overcommit policies helps prevent unexpected process termination, ensuring more reliable database operation.”

— PostgreSQL core developer

Tricks for Python performance optimization and memory management - Tips for efficient resource usage and speedup using profiling tools - (Japanese Edition)

Tricks for Python performance optimization and memory management – Tips for efficient resource usage and speedup using profiling tools – (Japanese Edition)

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Remaining Questions About Long-Term Impact and Performance

It is not yet clear how widespread adoption of strict overcommit settings will impact PostgreSQL performance in diverse environments, especially under heavy workloads. Some users report potential limitations in resource scalability, but comprehensive data on long-term effects is still emerging. Additionally, the optimal configuration may vary depending on hardware and workload specifics, leaving some uncertainty about best practices.

Amazon

Linux kernel parameter tuning for databases

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Next Steps for PostgreSQL Users and Developers

PostgreSQL community members are expected to release detailed guidelines and best practices for tuning system memory settings in conjunction with the new overcommit policy. Monitoring tools and performance benchmarks will likely be updated to help administrators evaluate the impact of these changes. Further discussions are anticipated as users share real-world experiences and refine configurations to balance stability and performance.

Nice DDR4 Desktop PC Server Memory RAM Module and Computer Motherboard RAM Slot Easy Test Quick Diagnostic Analyzer LED Tester Card Complete Set Solution Kit 288 Pin All Speed Voltage ECC and nonECC

Nice DDR4 Desktop PC Server Memory RAM Module and Computer Motherboard RAM Slot Easy Test Quick Diagnostic Analyzer LED Tester Card Complete Set Solution Kit 288 Pin All Speed Voltage ECC and nonECC

  • Comprehensive User Guide: Includes PDF manuals and tech tips
  • Three PC Boot Stages: Tests power, POST, and OS boot
  • Easy Troubleshooting Tool: Quick, professional-grade RAM diagnostic kit

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What is memory overcommit in Linux?

Memory overcommit is a Linux kernel feature that allows processes to allocate more memory than physically available, trusting the kernel to manage over-allocation safely. Setting vm.overcommit_memory=2 enforces strict limits to prevent over-commitment, reducing the risk of the OOM killer terminating processes.

Why is PostgreSQL changing its memory management approach?

PostgreSQL is adopting stricter memory overcommit policies to prevent the Linux OOM killer from terminating database processes unexpectedly, which can cause data loss or outages. This change aims to improve system stability during high memory demand.

Does this change affect performance?

Potentially, yes. Stricter overcommit policies may limit memory allocation during peak loads, possibly impacting scalability or throughput. Users should tune their systems carefully and monitor resource usage.

It depends on the environment. For critical or large-scale systems, adopting strict overcommit policies can improve stability. However, users must evaluate their workload and hardware to determine the best configuration.

What should I do if I experience issues after applying these settings?

Review your system’s memory configuration, monitor resource usage, and consider adjusting PostgreSQL’s memory settings or kernel parameters. Consulting PostgreSQL and Linux documentation can help optimize performance and stability.

Source: hn

You May Also Like

Google Search Lets Creators Know More About Their Reach

Google Search now provides creators with detailed insights into their content reach, enhancing transparency and performance tracking.

Hyatt Surges In Global Coverage

Hyatt’s media mentions surged 48-fold recently, indicating a major increase in its international visibility and activity.

Oracle Surges In Global Coverage

Oracle has experienced a notable increase in global media mentions, with GDELT reporting 46 mentions in a recent window, indicating heightened international attention.

This Hand-Woven Hawaiian Slipper Is Peak Flip-Flop

A new handcrafted Hawaiian slipper is gaining attention for its traditional craftsmanship and unique design, promising a premium alternative to standard flip-flops.