Relation between RAM / shmmax / shmall / shared_buffers

--_d7e1a313-3681-4457-a1d5-94acec9694d2_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Hi=2C
I am having a transactional database heavy on parallel reads and updates. A=
part from hardware optimization=2C I want to ensure that my system paramete=
rs are optimized as well. Following is what I am doing on my test system ha=
ving 4GB RAM. Please let me know if the logic sounds ok (at least at high-l=
evel) and if there are other related parameters I should tweak as well:
RAM =3D 4GB1. Keeping the kernel parameter kernel.shmmax at 75% of RAM (i.e=
.. at 3GB )kernel.shmmax =3D 32212254722. Keeping the kernel parameter shmal=
l at the same value. Because shmall is measured in number of pages and each=
page on my linux is 4096 bytes=2C having kernel.shmall =3D 786432 (786=
432 * 4096 =3D 3221225472=2C same as shmmax)3. Keeping the shared_buffer pa=
rameter in the postgresql.conf file to be 25% of the kernel.shmmax. i.e. sh=
ared_buffers =3D 768MB (25% of 3072 MB)

Thanks=2C-Bala

____________________________________________________________ _____
The New Busy is not the old busy. Search=2C chat and e-mail from your inbox=
..
http://www.windowslive.com/campaign/thenewbusy?ocid=3DPID283 26::T:WLMTAGL:O=
N:WL:en-US:WM_HMP:042010_3=

--_d7e1a313-3681-4457-a1d5-94acec9694d2_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
..hmmessage P
{
margin:0px=3B
padding:0px
}
body.hmmessage
{
font-size: 10pt=3B
font-family:Verdana
}
--></style>
</head>
<body class=3D'hmmessage'>
<div>Hi=2C</div><div><br></div><div>I am having a transactional database he=
avy on parallel reads and updates. Apart from hardware optimization=2C I wa=
nt to ensure that my system parameters are optimized as well. Following is =
what I am doing on my test system having 4GB RAM. Please let me know if the=
logic sounds ok (at least at high-level) and if there are other related pa=
rameters I should tweak as well:</div><div><br></div><div>RAM =3D 4GB</div>=
<div>1. Keeping the kernel parameter kernel.shmmax at 75% of RAM (i.e. at 3=
GB )kernel.shmmax =3D 3221225472</div><div>2. Keeping the kernel parameter =
shmall at the same value. Because shmall is measured in number of pages and=
each page on my linux is 4096 bytes=2C having kernel.shmall =3D 786432 &nb=
sp=3B  =3B (786432 * 4096 =3D 3221225472=2C same as shmmax)</div><div>3=
.. Keeping the shared_buffer parameter in the postgresql.conf file to be 25%=
of the kernel.shmmax. i.e. shared_buffers =3D 768MB (25% of 3072 MB)</div>=
<div><br></div><div><br></div><div>Thanks=2C</div><div>-Bala</div><div><br>=
</div>
<hr />The New Busy is not the old busy. Search=2C c=
hat and e-mail from your inbox. <a href=3D'http://www.windowslive.com/campa=
ign/thenewbusy?ocid=3DPID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP :042010_3' targ=
et=3D'_new'>Get started.</a></body>
</html>=

--_d7e1a313-3681-4457-a1d5-94acec9694d2_--
Balkrishna Sharma [ Di, 25 Mai 2010 20:05 ] [ ID #2042005 ]

Re: Relation between RAM / shmmax / shmall /

Balkrishna Sharma <b_ki [at] hotmail.com> wrote:

> [Are there] other related parameters I should tweak as well[?]

There are several which should probably be adjusted. See:

http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Serve r

-Kevin

--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
Kevin Grittner [ Di, 25 Mai 2010 20:10 ] [ ID #2042006 ]

Re: Relation between RAM / shmmax / shmall / shared_buffers

This is a multi-part message in MIME format.
--------------050204070503070109050300
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Balkrishna Sharma wrote:
> 1. Keeping the kernel parameter kernel.shmmax at 75% of RAM (i.e. at
> 3GB )kernel.shmmax = 3221225472
> 2. Keeping the kernel parameter shmall at the same value. Because
> shmall is measured in number of pages and each page on my linux is
> 4096 bytes, having kernel.shmall = 786432 (786432 * 4096 =
> 3221225472, same as shmmax)

There's little reason to put shmmax at over 50% of RAM, because
shared_buffers is going to be significantly lower than that even. I use
the attached script for this job now; I got sick of doing the math
manually all the time. If you're on a system that supports returning
memory info using getconf, it outputs the lines you need to put into the
kernel configuration.

--
Greg Smith 2ndQuadrant US Baltimore, MD
PostgreSQL Training, Services and Support
greg [at] 2ndQuadrant.com www.2ndQuadrant.us


--------------050204070503070109050300
Content-Type: text/plain;
name="shmsetup"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="shmsetup"

#!/bin/bash

# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system. The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.

# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
# sysctl -p

# Early FreeBSD versions do not support the sysconf interface
# used here. The exact version where this works hasn't
# been confirmed yet.

page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`

if [ -z "$page_size" ]; then
echo Error: cannot determine page size
exit 1
fi

if [ -z "$phys_pages" ]; then
echo Error: cannot determine number of memory pages
exit 2
fi

shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`

echo \# Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo \# Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall

--------------050204070503070109050300
Content-Type: text/plain
Content-Disposition: inline
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable


--
Sent via pgsql-admin mailing list (pgsql-admin [at] postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

--------------050204070503070109050300--
Greg Smith [ Fr, 28 Mai 2010 21:08 ] [ ID #2042203 ]
Datenbanken » gmane.comp.db.postgresql.admin » Relation between RAM / shmmax / shmall / shared_buffers

Vorheriges Thema: FW: Restore pg_dumpall
Nächstes Thema: Restore pg_dumpall