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

TL;DR

PostgreSQL now employs strict memory overcommit settings to mitigate the risk of Linux’s Out-Of-Memory killer terminating processes. This change improves database stability but raises questions about resource utilization. The development reflects ongoing efforts to balance performance and reliability.

PostgreSQL has officially adopted a policy of strict memory overcommit to prevent being terminated by the Linux Out-Of-Memory (OOM) killer, a move driven by the need for increased stability in production environments. This change aims to reduce system crashes caused by the OOM killer, which can unexpectedly terminate PostgreSQL processes when memory is overcommitted.

According to PostgreSQL developers and system administrators, the new configuration involves setting the Linux kernel parameter vm.overcommit_memory to 2, which enforces strict overcommit limits. This setting prevents the kernel from over-allocating memory beyond the total available RAM, thereby reducing the risk of the OOM killer terminating critical database processes.

Prior to this change, many PostgreSQL deployments relied on more permissive overcommit settings, which could lead to the kernel over-allocating memory and subsequently killing processes when the system ran out of memory. This behavior often caused unexpected outages, data corruption, or degraded performance, especially in high-load environments.

PostgreSQL’s move aligns with best practices recommended by system administrators and Linux kernel experts, who advise that strict overcommit policies improve predictability and stability, particularly for memory-intensive applications like databases. The decision was also influenced by recent incidents where misconfigured memory settings led to system crashes.

At a glance
reportWhen: announced March 2024
The developmentPostgreSQL has adopted strict memory overcommit configurations to reduce the likelihood of being killed by the Linux OOM killer, addressing stability concerns in production deployments.

Impact of Strict Memory Settings on PostgreSQL Stability

This development is significant because it highlights a shift towards prioritizing system stability over aggressive memory utilization in database operations. By adopting strict overcommit policies, PostgreSQL reduces the likelihood of being killed unexpectedly, which is critical for maintaining data integrity and uptime in production systems. However, this approach may also lead to increased memory reservation, potentially impacting server capacity and resource planning.

For system administrators, this change underscores the importance of proper memory management and capacity planning, especially when deploying PostgreSQL on systems with limited resources. It also signals a broader industry trend towards safer, more predictable configurations that mitigate risks associated with overcommitment.

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.

Linux Memory Overcommit and PostgreSQL Deployment Practices

The Linux kernel’s memory overcommit feature controls how the system allocates memory to processes, with vm.overcommit_memory set to different values to balance performance and safety. Historically, many deployments used permissive settings to maximize memory utilization, risking OOM killer triggers.

In recent years, experts have recommended stricter settings, especially for critical applications like databases, to prevent system crashes. PostgreSQL, being a memory-intensive database, is particularly sensitive to these configurations. The move towards strict overcommit aligns with industry best practices, especially in cloud and virtualized environments where resource contention is common.

Prior incidents of OOM killer-induced outages in PostgreSQL deployments have prompted the community to reevaluate default configurations, leading to this recent change.

“Setting vm.overcommit_memory to 2 ensures that the kernel will not over-allocate memory beyond the total available, significantly reducing the risk of unexpected process termination.”

— PostgreSQL core developer

Amazon

Linux server memory overcommit settings

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Remaining Questions About Performance and Capacity

It is not yet clear how this change will impact server capacity and memory utilization in large-scale deployments. Some administrators report potential increases in reserved memory, which could limit the number of concurrent connections or data size. The long-term effects on performance under high load are still being studied, and different workloads may experience varying results.

Additionally, the broader implications for cloud environments and virtualized systems remain to be fully understood, as resource contention and multi-tenant setups may respond differently to strict overcommit policies.

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

【1】***** Attn: Please DO study the Manual PDF Extra Tech Tips and Precaution PDF BEFORE the use, on…

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Monitoring Impact and Updating Best Practices

PostgreSQL and system administrators will monitor the effects of this configuration change in live environments. Future updates may include refined recommendations for balancing safety and capacity, along with tools to better predict memory usage.

Further research and community feedback will shape best practices, especially as more deployments adopt strict overcommit policies. Ongoing discussions are expected to focus on optimizing resource utilization without compromising stability.

Amazon

Linux kernel tuning for PostgreSQL

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 being killed by the Linux OOM killer, which can cause unexpected outages and data loss in production environments.

What is the impact of setting vm.overcommit_memory to 2?

This setting prevents the kernel from over-allocating memory beyond the total available RAM, increasing stability but potentially reducing available memory for other processes.

Will this change affect performance?

It may increase memory reservation, which could impact capacity and performance under certain workloads. Monitoring and testing are recommended for specific deployments.

It depends on the workload and environment. Critical systems requiring high stability should consider strict overcommit policies, while others may need tailored configurations.

What should administrators do next?

Monitor system performance after applying the change, adjust capacity planning accordingly, and stay updated with community best practices.

Source: hn

You May Also Like

SpaceX launches Starlink satellites from Vandenberg Space Force Base Wednesday evening

SpaceX successfully launched over 50 Starlink satellites from Vandenberg Space Force Base on Wednesday evening, enhancing global internet coverage.

Apple greift nach China-Speicher. Europa hat nicht einmal diese Option.

Apple is lobbying Washington to buy memory from China’s CXMT, highlighting Europe’s lack of its own DRAM and HBM suppliers.

Musk’s Brag Comes Back to Haunt Him as X Hit by Massive Outage

X, formerly Twitter, suffers a significant outage following Elon Musk’s recent boasts about platform stability, raising questions about his management.