Re: 2 postgresql processes on the same machine ? - Mailing list pgsql-novice

From Oliver Fromme
Subject Re: 2 postgresql processes on the same machine ?
Date
Msg-id 200407291645.i6TGjw3i090879@lurza.secnetix.de
Whole thread Raw
In response to 2 postgresql processes on the same machine ?  ("Jean-Guillaume LALANNE" <jeanguillaume.lalanne@capgemini.com>)
List pgsql-novice
Jean-Guillaume LALANNE wrote:
 > My question may seem a little bit strange but
 > I'd like to know if it is possible to run 2
 > postgresql processes with 2 separate databases on the
 > same machine (change of the ports, different paths to
 > logs, ...)?

It's possible (I've done it in the past), but I would not
recommend it.

If you don't need network connectivity (i.e. access the
database only locally), then there is no problem at all.
If you need network connectivity, you can run the two
(or more) instances of PostgreSQL on different ports,
or you can bind them to different IP addresses if your
host has multiple ones.  (Note, PostgreSQL also uses a
UDP port on localhost to exchange statistics information,
but the port number is selected randomly, so there is no
problem.)

However, in general it is not advisable to run multiple
database services (no matter if it's PostgreSQL or any
other) on the same physical machine.  That's because the
processes will fight against each other for hardware
resources such as processor cache, disk cache, I/O band-
width etc.  In the worst case, both processes constantly
trow each other out of the cache, effectively disabling
it (this effect is called "trashing").

If you run just one PostgreSQL master, it uses shared
memory to communicate with its child processes and use
efficient caching between them.  If you run two (or more)
separate PostgreSQL masters, they cannot share any data
between each other.

In general, it is better to buy two cheaper machines than
to try to run two separate database services on one big
machine, expecially if you expect significant load on the
databases.  At least that has been my experience.  YMMV.

Best regards
   Oliver

--
Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 München
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

cat man du : where Unix geeks go when they die

pgsql-novice by date:

Previous
From: "Jean-Guillaume LALANNE"
Date:
Subject: 2 postgresql processes on the same machine ?
Next
From: Betsy Barker
Date:
Subject: Re: Calling a function that returns a composite type using