PostgreSQL resource consumption limitations

PostgreSQL offers a great deal of flexibility when it comes to resource
allocation and efficient usage of hardware capacities. This allows fancy
monitoring of what PostgreSQL does in production. Sometimes, however, better
operating system integration is needed and helps to use hardware even more
efficiently.

On Linux one way to limit or allocate resources is to use the Linux kernel's
cgroup interface. cgroups and PostgreSQL are a perfect team for …

more efficient monitoring

restriciting use of resources

resource accounting.

How do cgroups work?

On a Linux system cgroups (= control groups) are basically a way to group
various operating system processes into groups. A group like that can then be
assigned to a certain amount of RAM, a fraction of a CPU or to a certain number
of I/O operations.

Processes can be moved to a group manually or with the help of a daemon which
moves processes to the right group automatically given some user-defined rules.
It is easily possible to move all processes belonging to a user to some special
cgroup and apply constraints to it. Following this approach you can move an
entire PostgreSQL instance and all its processes to a certain cgroup.

We got two users which form separate groups. Each group will get certain
fractions of the system's CPU as well as a certain amount of memory. In other
words: You can box a database instance nicely inside a group.

In the next step you can nicely put processes into a group. This is best done
using /etc/cgrules.conf:

user_0004 * /user_0004
user_0005 * /user_0005

In our case every user's process is automatically moved to the right process on
startup.

More on cgroups will be available in further blog posts.

VN:F [1.9.22_1171]

please wait...

Rating: 5.0/5 (3 votes cast)

PostgreSQL resource consumption limitations, 5.0 out of 5 based on 3 ratings

Hans-Juergen Schoenig

Hans-Jürgen Schönig has 15 years of experience with PostgreSQL. He is consultant and CEO of the company "Cybertec Schönig & Schönig GmbH" (www.postgresq-support.de), which has served countless customers around the globe.