1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Comparison of Different Solutions</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="High Availability, Load Balancing, and Replication"
16
HREF="high-availability.html"><LINK
18
TITLE="High Availability, Load Balancing, and Replication"
19
HREF="high-availability.html"><LINK
21
TITLE="Log-Shipping Standby Servers"
22
HREF="warm-standby.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="High Availability, Load Balancing, and Replication"
57
HREF="high-availability.html"
66
TITLE="High Availability, Load Balancing, and Replication"
67
HREF="high-availability.html"
74
>Chapter 25. High Availability, Load Balancing, and Replication</TD
80
TITLE="High Availability, Load Balancing, and Replication"
81
HREF="high-availability.html"
89
TITLE="Log-Shipping Standby Servers"
90
HREF="warm-standby.html"
104
NAME="DIFFERENT-REPLICATION-SOLUTIONS"
105
>25.1. Comparison of Different Solutions</A
113
>Shared Disk Failover</DT
116
> Shared disk failover avoids synchronization overhead by having only one
117
copy of the database. It uses a single disk array that is shared by
118
multiple servers. If the main database server fails, the standby server
119
is able to mount and start the database as though it were recovering from
120
a database crash. This allows rapid failover with no data loss.
123
> Shared hardware functionality is common in network storage devices.
124
Using a network file system is also possible, though care must be
125
taken that the file system has full <ACRONYM
129
HREF="creating-cluster.html#CREATING-CLUSTER-NFS"
131
>). One significant limitation of this
132
method is that if the shared disk array fails or becomes corrupt, the
133
primary and standby servers are both nonfunctional. Another issue is
134
that the standby server should never access the shared storage while
135
the primary server is running.
139
>File System (Block-Device) Replication</DT
142
> A modified version of shared hardware functionality is file system
143
replication, where all changes to a file system are mirrored to a file
144
system residing on another computer. The only restriction is that
145
the mirroring must be done in a way that ensures the standby server
146
has a consistent copy of the file system — specifically, writes
147
to the standby must be done in the same order as those on the master.
151
> is a popular file system replication solution
156
>Warm and Hot Standby Using Point-In-Time Recovery (<ACRONYM
162
> Warm and hot standby servers can be kept current by reading a
163
stream of write-ahead log (<ACRONYM
167
records. If the main server fails, the standby contains
168
almost all of the data of the main server, and can be quickly
169
made the new master database server. This is asynchronous and
170
can only be done for the entire database server.
173
> A PITR standby server can be implemented using file-based log shipping
175
HREF="warm-standby.html"
177
>) or streaming replication (see
179
HREF="warm-standby.html#STREAMING-REPLICATION"
181
>), or a combination of both. For
182
information on hot standby, see <A
183
HREF="hot-standby.html"
189
>Trigger-Based Master-Standby Replication</DT
192
> A master-standby replication setup sends all data modification
193
queries to the master server. The master server asynchronously
194
sends data changes to the standby server. The standby can answer
195
read-only queries while the master server is running. The
196
standby server is ideal for data warehouse queries.
202
> is an example of this type of replication, with per-table
203
granularity, and support for multiple standby servers. Because it
204
updates the standby server asynchronously (in batches), there is
205
possible data loss during fail over.
209
>Statement-Based Replication Middleware</DT
212
> With statement-based replication middleware, a program intercepts
213
every SQL query and sends it to one or all servers. Each server
214
operates independently. Read-write queries are sent to all servers,
215
while read-only queries can be sent to just one server, allowing
216
the read workload to be distributed.
219
> If queries are simply broadcast unmodified, functions like
225
>CURRENT_TIMESTAMP</CODE
227
sequences can have different values on different servers.
228
This is because each server operates independently, and because
229
SQL queries are broadcast (and not actual modified rows). If
230
this is unacceptable, either the middleware or the application
231
must query such values from a single server and then use those
232
values in write queries. Another option is to use this replication
233
option with a traditional master-standby setup, i.e. data modification
234
queries are sent only to the master and are propagated to the
235
standby servers via master-standby replication, not by the replication
236
middleware. Care must also be taken that all
237
transactions either commit or abort on all servers, perhaps
238
using two-phase commit (<A
239
HREF="sql-prepare-transaction.html"
240
>PREPARE TRANSACTION</A
243
HREF="sql-commit-prepared.html"
253
this type of replication.
257
>Asynchronous Multimaster Replication</DT
260
> For servers that are not regularly connected, like laptops or
261
remote servers, keeping data consistent among servers is a
262
challenge. Using asynchronous multimaster replication, each
263
server works independently, and periodically communicates with
264
the other servers to identify conflicting transactions. The
265
conflicts can be resolved by users or conflict resolution rules.
266
Bucardo is an example of this type of replication.
270
>Synchronous Multimaster Replication</DT
273
> In synchronous multimaster replication, each server can accept
274
write requests, and modified data is transmitted from the
275
original server to every other server before each transaction
276
commits. Heavy write activity can cause excessive locking,
277
leading to poor performance. In fact, write performance is
278
often worse than that of a single server. Read requests can
279
be sent to any server. Some implementations use shared disk
280
to reduce the communication overhead. Synchronous multimaster
281
replication is best for mostly read workloads, though its big
282
advantage is that any server can accept write requests —
283
there is no need to partition workloads between master and
284
standby servers, and because the data changes are sent from one
285
server to another, there is no problem with non-deterministic
295
> does not offer this type of replication,
299
> two-phase commit (<A
300
HREF="sql-prepare-transaction.html"
301
>PREPARE TRANSACTION</A
303
HREF="sql-commit-prepared.html"
306
can be used to implement this in application code or middleware.
310
>Commercial Solutions</DT
316
> is open source and easily
317
extended, a number of companies have taken <SPAN
321
and created commercial closed-source solutions with unique
322
failover, replication, and load balancing capabilities.
329
HREF="different-replication-solutions.html#HIGH-AVAILABILITY-MATRIX"
332
the capabilities of the various solutions listed above.
337
NAME="HIGH-AVAILABILITY-MATRIX"
341
>Table 25-1. High Availability, Load Balancing, and Replication Feature Matrix</B
346
><COL><COL><COL><COL><COL><COL><COL><COL><THEAD
351
>Shared Disk Failover</TH
353
>File System Replication</TH
355
>Hot/Warm Standby Using PITR</TH
357
>Trigger-Based Master-Standby Replication</TH
359
>Statement-Based Replication Middleware</TH
361
>Asynchronous Multimaster Replication</TH
363
>Synchronous Multimaster Replication</TH
369
>Most Common Implementation</TD
394
>Communication Method</TD
415
>table rows and row locks</TD
419
>No special hardware required</TD
444
>Allows multiple master servers</TD
469
>No master server overhead</TD
494
>No waiting for multiple servers</TD
519
>Master failure will never lose data</TD
544
>Standby accept read-only queries</TD
569
>Per-table granularity</TD
594
>No conflict resolution necessary</TD
621
> There are a few solutions that do not fit into the above categories:
629
>Data Partitioning</DT
632
> Data partitioning splits tables into data sets. Each set can
633
be modified by only one server. For example, data can be
634
partitioned by offices, e.g., London and Paris, with a server
635
in each office. If queries combining London and Paris data
636
are necessary, an application can query both servers, or
637
master/standby replication can be used to keep a read-only copy
638
of the other office's data on each server.
642
>Multiple-Server Parallel Query Execution</DT
645
> Many of the above solutions allow multiple servers to handle multiple
646
queries, but none allow a single query to use multiple servers to
647
complete faster. This solution allows multiple servers to work
648
concurrently on a single query. It is usually accomplished by
649
splitting the data among servers and having each server execute its
650
part of the query and return results to a central server where they
651
are combined and returned to the user. <SPAN
655
has this capability. Also, this can be implemented using the
670
SUMMARY="Footer navigation table"
681
HREF="high-availability.html"
699
HREF="warm-standby.html"
709
>High Availability, Load Balancing, and Replication</TD
715
HREF="high-availability.html"
723
>Log-Shipping Standby Servers</TD
b'\\ No newline at end of file'