All Topics
All Topics
Technology
Technology
AI
AI
Business
Business
Entertainment
Entertainment
News
News
Programming
Programming
Science
Science
Design
Design
Environment
Environment
Finance
Finance
Crypto
Crypto
Politics
Politics
Sports
Sports
Education
Education
Gaming
Gaming
Art
Art
Music
Music
Health
Health
Security
Security
Books
Books
Food
Food
Travel
Travel
Personal
Personal
Bluesky
Twitter

Protecting PostgreSQL from the OOM Killer: A Guide to Strict Memory Overcommit

This article explains why PostgreSQL databases are particularly vulnerable to the Linux OOM (Out-Of-Memory) Killer due to their shared memory architecture, where killing a single backend process can crash the entire database. It advocates for strict memory overcommit settings (vm.overcommit_memory=2) to prevent the OOM killer from ever activating, and shares real-world operational experience including a one-character kernel bug that forced a temporary rollback of this setting. The post also provides a heuristic for determining the right overcommit limit based on workload characteristics.

furkansahin5d ago6 min readenInsight
Read on ubicloud.com

Key quotes

PostgreSQL's postmaster (its main supervisor process) forks a backend process for each connection. These backends share memory segments that hold shared buffers, WAL buffers, lock tables, and other shared state.
The OOM killer doesn't understand this architecture. It simply picks a process based on a heuristic (usually the process that uses the most memory) and terminates it.
For most processes, handling an OOM kill is simple: the process restarts, reconnects, and picks up where it left off. PostgreSQL is different.

From the article

In this blog post, we will explain how strict memory overcommit protects your database from catastrophic OOM (out of memory) kills. We will also share how a one character kernel bug forced us to temporarily disable this setting. Finally, we will explain o
Continue reading on ubicloud.com

You might also wanna read

Comments

Sign in to join the conversation.

No comments yet. Be the first.