Re: The right SHMMAX and FILE_MAX - Mailing list pgsql-performance

From Greg Smith
Subject Re: The right SHMMAX and FILE_MAX
Date
Msg-id 4DBDB6CB.70002@2ndQuadrant.com
Whole thread Raw
In response to The right SHMMAX and FILE_MAX  (Phoenix Kiula <phoenix.kiula@gmail.com>)
List pgsql-performance
On 05/01/2011 02:48 AM, Phoenix Kiula wrote:
> Hi. I'm on a 64 Bit CentOS 5 system, quadcore processor, 8GB RAM and
> tons of data storage (1 TB SATAII disks).
>
> The current SHMMAX and SHMMIN are (commas added for legibility) --
>
> kernel.shmmax = 68,719,476,736
> kernel.shmall = 4,294,967,296
>

That's set higher than the amount of RAM in the server.  Run the
attached script; it will produce reasonable values for your server,
presuming you'll never want to allocate >50% of the RAM in the server
for shared memory.  Given standard tuning for shared_buffers is <40%,
I've never run into a situation where this was a terrible choice if you
want to just set and forget about it.  Only reason to fine-tine is if
another major user of shared memory is running on the server

> Now, according to my reading in the PG manual and this list, a good
> recommended value for SHMMAX is
>
>     (shared_buffers * 8192)
>

The value for shared_buffers stored internally is in 8192 byte pages:

select setting,unit,current_setting(name) from pg_settings where
name='shared_buffers';
  setting | unit | current_setting
---------+------+-----------------
  4096    | 8kB  | 32MB

So any formula you found that does this sort of thing is just converting
it back to bytes again, and is probably from an earlier PostgreSQL
version where you couldn't set this parameter in memory units.  SHMMAX
needs to be a bit bigger than shared_buffers in bytes.

> Similarly with "fs.file_max". There are articles like this one:
> http://tldp.org/LDP/solrhe/Securing-Optimizing-Linux-RH-Edition-v1.3/chap6sec72.html
> Is this relevant for PostgreSQL performance at all, or should I skip that?
>

That's ancient history.  This is how big the default is on the two Linux
distributions I have handy:

[RHEL5]
$ cat /proc/sys/fs/file-max
745312

[Debian Squeeze]
$ cat /proc/sys/fs/file-max
1645719

It was a tiny number circa the RedHat 6 that manual was written for, now
it's very unlikely you'll exceed the kernel setting here.

--
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books


Attachment

pgsql-performance by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: The right SHMMAX and FILE_MAX
Next
From: Greg Smith
Date:
Subject: Re: stored proc and inserting hundreds of thousands of rows