1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Chapter 26. High Availability, Load Balancing, and Replication</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="continuous-archiving.html" title="25.3. Continuous Archiving and Point-in-Time Recovery (PITR)" /><link rel="next" href="different-replication-solutions.html" title="26.1. Comparison of Different Solutions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">Chapter 26. High Availability, Load Balancing, and Replication</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="continuous-archiving.html" title="25.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="admin.html" title="Part III. Server Administration">Up</a></td><th width="60%" align="center">Part III. Server Administration</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="different-replication-solutions.html" title="26.1. Comparison of Different Solutions">Next</a></td></tr></table><hr /></div><div class="chapter" id="HIGH-AVAILABILITY"><div class="titlepage"><div><div><h2 class="title">Chapter 26. High Availability, Load Balancing, and Replication</h2></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="sect1"><a href="different-replication-solutions.html">26.1. Comparison of Different Solutions</a></span></dt><dt><span class="sect1"><a href="warm-standby.html">26.2. Log-Shipping Standby Servers</a></span></dt><dd><dl><dt><span class="sect2"><a href="warm-standby.html#STANDBY-PLANNING">26.2.1. Planning</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#STANDBY-SERVER-OPERATION">26.2.2. Standby Server Operation</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#PREPARING-PRIMARY-FOR-STANDBY">26.2.3. Preparing the Primary for Standby Servers</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#STANDBY-SERVER-SETUP">26.2.4. Setting Up a Standby Server</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#STREAMING-REPLICATION">26.2.5. Streaming Replication</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#STREAMING-REPLICATION-SLOTS">26.2.6. Replication Slots</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#CASCADING-REPLICATION">26.2.7. Cascading Replication</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#SYNCHRONOUS-REPLICATION">26.2.8. Synchronous Replication</a></span></dt><dt><span class="sect2"><a href="warm-standby.html#CONTINUOUS-ARCHIVING-IN-STANDBY">26.2.9. Continuous Archiving in Standby</a></span></dt></dl></dd><dt><span class="sect1"><a href="warm-standby-failover.html">26.3. Failover</a></span></dt><dt><span class="sect1"><a href="hot-standby.html">26.4. Hot Standby</a></span></dt><dd><dl><dt><span class="sect2"><a href="hot-standby.html#HOT-STANDBY-USERS">26.4.1. User's Overview</a></span></dt><dt><span class="sect2"><a href="hot-standby.html#HOT-STANDBY-CONFLICT">26.4.2. Handling Query Conflicts</a></span></dt><dt><span class="sect2"><a href="hot-standby.html#HOT-STANDBY-ADMIN">26.4.3. Administrator's Overview</a></span></dt><dt><span class="sect2"><a href="hot-standby.html#HOT-STANDBY-PARAMETERS">26.4.4. Hot Standby Parameter Reference</a></span></dt><dt><span class="sect2"><a href="hot-standby.html#HOT-STANDBY-CAVEATS">26.4.5. Caveats</a></span></dt></dl></dd></dl></div><a id="id-1.6.13.2" class="indexterm"></a><a id="id-1.6.13.3" class="indexterm"></a><a id="id-1.6.13.4" class="indexterm"></a><a id="id-1.6.13.5" class="indexterm"></a><a id="id-1.6.13.6" class="indexterm"></a><a id="id-1.6.13.7" class="indexterm"></a><p>
3 Database servers can work together to allow a second server to
4 take over quickly if the primary server fails (high
5 availability), or to allow several computers to serve the same
6 data (load balancing). Ideally, database servers could work
7 together seamlessly. Web servers serving static web pages can
8 be combined quite easily by merely load-balancing web requests
9 to multiple machines. In fact, read-only database servers can
10 be combined relatively easily too. Unfortunately, most database
11 servers have a read/write mix of requests, and read/write servers
12 are much harder to combine. This is because though read-only
13 data needs to be placed on each server only once, a write to any
14 server has to be propagated to all servers so that future read
15 requests to those servers return consistent results.
17 This synchronization problem is the fundamental difficulty for
18 servers working together. Because there is no single solution
19 that eliminates the impact of the sync problem for all use cases,
20 there are multiple solutions. Each solution addresses this
21 problem in a different way, and minimizes its impact for a specific
24 Some solutions deal with synchronization by allowing only one
25 server to modify the data. Servers that can modify data are
26 called read/write, <em class="firstterm">master</em> or <em class="firstterm">primary</em> servers.
27 Servers that track changes in the primary are called <em class="firstterm">standby</em>
28 or <em class="firstterm">secondary</em> servers. A standby server that cannot be connected
29 to until it is promoted to a primary server is called a <em class="firstterm">warm
30 standby</em> server, and one that can accept connections and serves read-only
31 queries is called a <em class="firstterm">hot standby</em> server.
33 Some solutions are synchronous,
34 meaning that a data-modifying transaction is not considered
35 committed until all servers have committed the transaction. This
36 guarantees that a failover will not lose any data and that all
37 load-balanced servers will return consistent results no matter
38 which server is queried. In contrast, asynchronous solutions allow some
39 delay between the time of a commit and its propagation to the other servers,
40 opening the possibility that some transactions might be lost in
41 the switch to a backup server, and that load balanced servers
42 might return slightly stale results. Asynchronous communication
43 is used when synchronous would be too slow.
45 Solutions can also be categorized by their granularity. Some solutions
46 can deal only with an entire database server, while others allow control
47 at the per-table or per-database level.
49 Performance must be considered in any choice. There is usually a
50 trade-off between functionality and
51 performance. For example, a fully synchronous solution over a slow
52 network might cut performance by more than half, while an asynchronous
53 one might have a minimal performance impact.
55 The remainder of this section outlines various failover, replication,
56 and load balancing solutions.
57 </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="continuous-archiving.html" title="25.3. Continuous Archiving and Point-in-Time Recovery (PITR)">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="admin.html" title="Part III. Server Administration">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="different-replication-solutions.html" title="26.1. Comparison of Different Solutions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">25.3. Continuous Archiving and Point-in-Time Recovery (PITR) </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 26.1. Comparison of Different Solutions</td></tr></table></div></body></html>