Near/far architecture
=====================

In the near/far architecture, there are two data nodes in the primary
location and one data node in a secondary location. The primary location
is where the majority of the data is stored and where most of the client
connections are made. The secondary location is used for disaster
recovery and isn’t used for client connections by default.

The data nodes are all configured in a multi-master replication
configuration, just like the standard architecture. The difference is
that the node at the secondary location is fenced off from the other
nodes in the cluster and doesn’t receive client connections by default.
In this configuration, the secondary location node has a complete
replica of the data in the primary location.

Using a PGD commit scope, the data nodes in the primary location are
configured to synchronously replicate data to the other node in the
primary location and to the node in the secondary location. This ensures
that the data is replicated to all nodes before it’s committed to on the
primary location. In the case of a node going down, the commit scope
rule detects the situation and degrades the replication to asynchronous
replication. This behavior allows the system to continue to operate.

In the event of a partial failure at the primary location, the system
switches to the other data node, also with a complete replica of the
data, and continues to operate. It also continues replication to the
secondary location. When the failed node at the primary location comes
back, it rejoins and begins replicating data from the node that’s
currently primary.

In the event of a complete failure in the primary location, the
secondary location’s database has a complete replica of the data.
Depending on the failure, options for recovery include restoring the
primary location from the secondary location or restoring the primary
location from a backup of the secondary location. The secondary location
can be configured to accept client connections, but this isn’t the
default configuration and requires some additional reconfiguration.

Synchronous replication in near/far architecture
------------------------------------------------

For best results, configure the near/far architecture with synchronous
replication. This ensures that the data is replicated to the secondary
location before it’s committed to the primary location.

See :ref:`Manually Deploying PGD Essential near-far architecture <Manually Deploying PGD Essential near-far architecture>`  for more information on how to configure the near/far
architecture with synchronous replication.

.. toctree::
  :maxdepth: 5

  how_to--essential-how-to--architectures--near-far--manually-deploying-near-far
