Что такое репликация базы данных и какие у неё особенности?
Asked at
AI answer
Replication is the maintenance of data copies across multiple database nodes. Usually, changes are written to a primary node and propagated to replicas; some systems also support a multi-master setup.
Main approaches:
- Synchronous replication confirms a write after it has been applied on the replicas: data is more consistent, but writes may be slower and depend on node availability.
- Asynchronous replication confirms a write sooner: it is usually faster, but replication lag and loss of the latest changes in the event of a failure are possible.
Replication is used to improve availability, distribute read traffic, and support disaster recovery. It does not replace backups. When designing a system, consider replication latency and lag, failover to a standby node, write conflicts, and data consistency. For example, after writing to the primary database, a read from a lagging replica may temporarily return an old value.
Also asked at Касперский
Similar questions
- What types of database replication are there (based on synchronization timing), and what is sent from the master to the replica?
- How should we run queries against the database: in an infinite loop or on a schedule? How will we read and account for data from the replica?
- What are the features of working with replication in databases?
- What are the advantages and disadvantages of using database replication?
- What types of replication does PostgreSQL support?