0Pricing
Advanced PostgreSQL: Indexing, Partitioning, Replication · Lektion

Synchrone und asynchrone Replikation

Verstehen Sie die Zielkonflikte zwischen Haltbarkeit und Latenz bei synchroner und asynchroner physischer Replikation in PostgreSQL.

Synchrone und asynchrone Replikation ist eine kostenlose Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des Advanced PostgreSQL: Indexing, Partitioning, Replication-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Two Modes of Streaming

Physical streaming replication can run in two modes: asynchronous (the default) and synchronous. They differ in when the primary considers a commit complete.

Asynchronous Replication

In async mode the primary commits as soon as the WAL is flushed locally. It does not wait for the standby. This is fast but a crash can lose the most recent commits not yet shipped.

Synchronous Replication

In sync mode the primary waits until at least one standby confirms it received (or applied) the WAL before reporting commit success. This guarantees zero data loss for confirmed commits at the cost of extra latency.

Configuring Sync Standbys

Name your standbys with application_name and list them in synchronous_standby_names on the primary.

-- on the primary, in postgresql.conf
synchronous_standby_names = 'standby1, standby2';

Quorum-based Sync

You can require any N of several standbys to confirm, balancing durability and availability.

synchronous_standby_names = 'ANY 1 (standby1, standby2)';

synchronous_commit Levels

The synchronous_commit setting controls how far a commit must travel:

  • off / local — local only
  • remote_write — standby received WAL
  • on — standby flushed WAL to disk
  • remote_apply — standby applied WAL (visible on replica)

Per-transaction Control

This setting can be changed per transaction, letting unimportant writes go fast while critical writes wait for confirmation.

SET synchronous_commit = 'remote_apply';
INSERT INTO payments (amount) VALUES (100);

Availability Risk of Sync

If the only synchronous standby goes down, commits on the primary will block until a standby returns. Always pair sync replication with multiple candidates or quorum settings.

Checking Replication State

Inspect the live state from the primary using pg_stat_replication.

SELECT application_name, state, sync_state
FROM pg_stat_replication;

Choosing a Mode

Use async for throughput and geographically distant replicas. Use sync when losing even one committed transaction is unacceptable, such as financial ledgers.

Latency Reality

Synchronous commit latency is roughly the network round-trip to the standby plus its fsync time. Keeping sync standbys on a low-latency link is essential.

Quick Check

What is the key trade-off of synchronous replication?

Recap

You compared asynchronous and synchronous replication, configured synchronous_standby_names and synchronous_commit levels, and learned the durability-vs-latency-vs-availability trade-offs.

Häufig gestellte Fragen

Ist die Lektion „Synchrone und asynchrone Replikation“ kostenlos?

Ja — der vollständige Text von „Synchrone und asynchrone Replikation“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Advanced PostgreSQL: Indexing, Partitioning, Replication-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Synchrone und asynchrone Replikation“?

Verstehen Sie die Zielkonflikte zwischen Haltbarkeit und Latenz bei synchroner und asynchroner physischer Replikation in PostgreSQL. Du übst Advanced PostgreSQL: Indexing, Partitioning, Replication mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um Advanced PostgreSQL: Indexing, Partitioning, Replication zu starten?

Keine Vorkenntnisse erforderlich. Advanced PostgreSQL: Indexing, Partitioning, Replication auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Synchrone und asynchrone Replikation“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion Code schreiben und ausführen?

Ja. Jede Advanced PostgreSQL: Indexing, Partitioning, Replication-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Replikationskonzepte verstehen
  2. Physische Replikation (Streaming)
  3. Einen Standby-Server einrichten
  4. Synchrone und asynchrone Replikation
← Zurück zu Advanced PostgreSQL: Indexing, Partitioning, Replication