]> begriffs open source - ai-pg/blob - full-docs/txt/high-availability.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / high-availability.txt
1
2 Chapter 26. High Availability, Load Balancing, and Replication
3
4    Table of Contents
5
6    26.1. Comparison of Different Solutions
7    26.2. Log-Shipping Standby Servers
8
9         26.2.1. Planning
10         26.2.2. Standby Server Operation
11         26.2.3. Preparing the Primary for Standby Servers
12         26.2.4. Setting Up a Standby Server
13         26.2.5. Streaming Replication
14         26.2.6. Replication Slots
15         26.2.7. Cascading Replication
16         26.2.8. Synchronous Replication
17         26.2.9. Continuous Archiving in Standby
18
19    26.3. Failover
20    26.4. Hot Standby
21
22         26.4.1. User's Overview
23         26.4.2. Handling Query Conflicts
24         26.4.3. Administrator's Overview
25         26.4.4. Hot Standby Parameter Reference
26         26.4.5. Caveats
27
28    Database servers can work together to allow a second server to take
29    over quickly if the primary server fails (high availability), or to
30    allow several computers to serve the same data (load balancing).
31    Ideally, database servers could work together seamlessly. Web servers
32    serving static web pages can be combined quite easily by merely
33    load-balancing web requests to multiple machines. In fact, read-only
34    database servers can be combined relatively easily too. Unfortunately,
35    most database servers have a read/write mix of requests, and read/write
36    servers are much harder to combine. This is because though read-only
37    data needs to be placed on each server only once, a write to any server
38    has to be propagated to all servers so that future read requests to
39    those servers return consistent results.
40
41    This synchronization problem is the fundamental difficulty for servers
42    working together. Because there is no single solution that eliminates
43    the impact of the sync problem for all use cases, there are multiple
44    solutions. Each solution addresses this problem in a different way, and
45    minimizes its impact for a specific workload.
46
47    Some solutions deal with synchronization by allowing only one server to
48    modify the data. Servers that can modify data are called read/write,
49    master or primary servers. Servers that track changes in the primary
50    are called standby or secondary servers. A standby server that cannot
51    be connected to until it is promoted to a primary server is called a
52    warm standby server, and one that can accept connections and serves
53    read-only queries is called a hot standby server.
54
55    Some solutions are synchronous, meaning that a data-modifying
56    transaction is not considered committed until all servers have
57    committed the transaction. This guarantees that a failover will not
58    lose any data and that all load-balanced servers will return consistent
59    results no matter which server is queried. In contrast, asynchronous
60    solutions allow some delay between the time of a commit and its
61    propagation to the other servers, opening the possibility that some
62    transactions might be lost in the switch to a backup server, and that
63    load balanced servers might return slightly stale results. Asynchronous
64    communication is used when synchronous would be too slow.
65
66    Solutions can also be categorized by their granularity. Some solutions
67    can deal only with an entire database server, while others allow
68    control at the per-table or per-database level.
69
70    Performance must be considered in any choice. There is usually a
71    trade-off between functionality and performance. For example, a fully
72    synchronous solution over a slow network might cut performance by more
73    than half, while an asynchronous one might have a minimal performance
74    impact.
75
76    The remainder of this section outlines various failover, replication,
77    and load balancing solutions.