Thread: pg/linux How much swap relative to physical memory is needed?
We have an openSUSE 11.2 machine running PostgreSQL 8.4.2 that we recently upgraded from 24 to 74G RAM. We have a single swap partition of 2G that free tells us is completely used. I don't see any swap IO when I run vmstat at reasonably busy points in the day (although it must happen some time... perhaps during nightly dumps) . Other than all swap used this looks good: total used free shared buffers cached Mem: 74372840 74154700 218140 0 198732 68919724 -/+ buffers/cache: 5036244 69336596 Swap: 2104444 2104444 0 Is there some minimum proportion of swap to physical memory that linux or postgresql likes to have? Is it OK for all Usage: this machine hosts a cluster of three databases, one which dominates the activity. We have during the day 900-1000 connections, approximately 100 of which are pumping data in via libpq copy, most other connections send infrequent small queries. There will frequently be one or two big queries going on (peg a core, use lots of IO for up to several minutes). Pgdump at night, several in parallel handling different portions of our database. Responsiveness of the database and it's ability to absorb the significant data we throw at it is quite good, I have no reason to suspect anything is wrong other than that I've never seen all swap used on a linux machine before. I believe my mem settings are modest for a machine like this: shared_buffers=5GB, work_mem=32MB, maintenance_work_mem=1GB. Should I be concerned? Thanks, -K
On Thu, Jun 10, 2010 at 1:50 PM, Kelly Burkhart <kelly.burkhart@gmail.com> wrote: > Is there some minimum proportion of swap to physical memory that linux > or postgresql likes to have? Is it OK for all > Dunno about linux, but the BSD types like to have swap = physical mem + delta. If a machine crashes and you want crashdumps, it writes the content of memory to the swap partition. The crashdump is recreated from the data in swap at the next boot. For this to work you need as much swap as RAM plus a bit more. If you don't care for crashdumps, then what you have is plenty. If you run out of memory then you're probably overloading that machine given that much RAM. Having swap will not save you much.
On Thursday, June 10, 2010, Kelly Burkhart <kelly.burkhart@gmail.com> wrote: > Should I be concerned? > > Thanks, The default Linux kernel settings will tend to swap stuff out to make more memory available for filesystem cache. You can lower the value set in /proc/sys/vm/swappiness to decrease this tendency. I don't think it's hurting anything, though; it just has pages it thinks can be usefully swapped out. -- "No animals were harmed in the recording of this episode. We tried but that damn monkey was just too fast."
2010/6/10 Alan Hodgson <ahodgson@simkin.ca>: > On Thursday, June 10, 2010, Kelly Burkhart <kelly.burkhart@gmail.com> wrote: >> Should I be concerned? >> >> Thanks, > > The default Linux kernel settings will tend to swap stuff out to make more > memory available for filesystem cache. You can lower the value set in > /proc/sys/vm/swappiness to decrease this tendency. I don't think it's > hurting anything, though; it just has pages it thinks can be usefully > swapped out. you can read * /usr/src/linux/Documentation/vm/overcommit-account to get more info. But depending of your OOMKiller mode, the size of the swap is used to determine the total commit memory. So if your swap is too small with huge RAM, and mode 2 for OOM you might not used all of your available memory. > > -- > "No animals were harmed in the recording of this episode. We tried but that > damn monkey was just too fast." > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > -- Cédric Villemain 2ndQuadrant http://2ndQuadrant.fr/ PostgreSQL : Expertise, Formation et Support