Advanced Rails - Building Industrial-Strength Web Apps in Record Time

(Tuis.) #1
Load Balancing and High Availability | 123


  • Use a software high-availability solution such as Wackamole (http://www.
    backhand.org/wackamole/). This will expose a pool of virtual I Paddresses and
    ensure that exactly one live server has each I Paddress at all times. If a server
    fails, its VIPs are redistributed among those remaining. The pool of VIPs is dis-
    tributed via a DNS round-robin list, so the application will pick a VI Pmore or
    less at random.


PostgreSQL


There are several load-balancing and high-availability options for PostgreSQL.
Because there is no single company behind PostgreSQL, the options are provided by
different organizations and companies. Each product typically embodies a different
replication or clustering paradigm. Some of the options are described in this section.


High availability: Warm standby


Warm standby is a simple way to achieve high availability under PostgreSQL. It
takes some configuration, but the configuration is documented well. Warm standby
uses the write-ahead log (WAL) that PostgreSQL logs activity to. Changes are writ-
ten in the WAL prior to being committed, so the database state can be reconstructed
even if a transaction is interrupted catastrophically.Log shippingis the process of
sending the WAL as files from the master to a slave.


Under a warm standby setup, a server is on standby, in restore mode. It is continu-
ously restoring from the primary server, using a restore command that waits for
WALs to become available and applies them as soon as they do. If the primary server
dies, a monitoring system (which must be provided by the user) designates the
standby as the new primary server.


Master-slave replication: Slony-I


Slony-I is a master-slave replication system similar to the replication mechanisms
included with MySQL. It supports promoting slaves to masters, but, like MySQL,
does not provide any mechanism to detect that nodes have failed.


An upgrade to Slony, Slony-II, is in the very early stages of development now. It
plans to provide multimaster synchronous replication for PostgreSQL based on the
Spread group-communication framework.


Multimaster replication: PGCluster


PGCluster (http://pgcluster.projects.postgresql.org/) is a product that offers multimaster
replication and clustering for PostgreSQL. It provides both load balancing and high
availability for a database cluster. The software handles failover, and yields a readily
available solution if three or more physical servers are used.

Free download pdf