SlideShare a Scribd company logo
Replication Solutions for
            PostgreSQL
             Peter Eisentraut
          petere@postgresql.org
What's in a Term?
•   Replication?
•   Clustering?
•   High availability?
•   Failover?
•   Standby?

• Putting data on more than one computer

                                           2
Space of Possibilities
• Goals
  • What do you want to achieve?
• Techniques
  • How can this be implemented?
• Solutions
  • What software is available to do this?




                                             3
Goals
• High availability
• Performance
  • Read
  • Write
• Wide-area networks
• Offline peers



                              4
Goal: High Availability
• No one wants “low availability”!
• Provisions for system failures
  • Software faults
  • Hardware faults
  • External interference




                                     5
Goal: Read Performance
• Applications with:
  • many readers (e.g., library information system)
  • resource-intensive readers (e.g., data
    warehousing)
• Distribute readers on more hardware.
• Most often, one physical machine is
  enough.



                                                  6
Goal: Write Performance
• Applications with:
  • Many writers
• Distribute writers on more hardware?
  • Constraint checking, conflict resolution?!?
• Faster writing contradicts replication.
  • Partition, don't replicate!
  • RAID 0/striping is not replication – it makes
    things “worse”.
  • RAID 10 is a good idea, but not the topic here.
                                                  7
Goal: Wide-Area Networks
• Faster access across WANs
• Reading?
  • Local copies
• Writing?
  • Synchronization?




                               8
Goal: Offline Peers
• Synchronize data with laptops,
  handhelds, ...
• “Road warriors”
• May be considered very-low-latency WANs




                                        9
Techniques
• Replication
  • Master/Slave
     • Asynchronous
     • Synchronous
  • Multi-Master
     • Asynchronous
     • Synchronous
• Proxy
• Standby system
                             10
Technique: Replication
   Master/Slave Asynchronous
• High(er) availability(?)
• Read performance
  • Load spreading,
    load balancing
• Offline peers              M   asy c
                                    n    S
  (unidirectional sync.)




                                             11
Technique: Replication
    Master/Slave Synchronous
• High availibility
• Better read
  performance
• Worse write
  performance         M   sy c
                            n    S




                                     12
Technique: Replication
   Multi-Master Asynchronous
• Read performance
• Faster access across
  WANs
• Manage offline peers
                         M           M
• Requires conflict          asy c
                                n


  resolution mechanism



                                         13
Technique: Replication
       Multi-Master Synchronous
•   “Holy grail of replication”
•   High availability
•   Read performance
•   Difficult to get good
                                  M          M
    write performance                 sy c
                                        n




                                                 14
Technique: Proxy
• High availability
• Read performance
• Proxy instance should       Proxy
  be redundant
• Transparent to the
  application
                          C           C



                                          15
Technique: Standby System
• High availability




                      M   sy c
                            n    S




                                     16
Constraints
• Hardware
• Operating system
• Application




                           17
No Built-In Solution?
• FIXME




                              18
Solutions
•   Slony-I, -II
•   PGCluster
•   DBMirror
•   pgpool
•   WAL replication
•   Sequoia
•   DRBD
•   Shared storage
                             19
Solution: Slony-I
(Slony ← слоны ← elephants)
• Asynchronous master/slave replication
• Multiple slaves, cascading possible
• Particularly useful for:
  • Read performance (load balancing with pgpool)
  • Limited form of high availability
  • Offline slaves via file-based log shipping
http://www.slony.info/

                                               20
Solution: Slony-II
• Synchronous master/master
  replication?
• See Gavin Sherry's session for details




                                           21
Solution: PGCluster
• Synchronous master/master replication
• Replicates the query string
• Particularly useful for:
  • Load balancing
  • High availability



http://pgcluster.projects.postgresql.org/
                                            22
Solution: DBMirror
• Asynchronous master/slave replication
• Very simple (compared to Slony-I)
• Particularly useful for:
  • Read performance
  • Offline peers



contrib/dbmirror/ in PostgreSQL source tree
                                              23
Solution: pgpool
• Connection pool daemon for PostgreSQL
• Supports simple proxying
• Useful as frontend for Slony-I




http://pgpool.projects.postgresql.org/
                                          24
Solution: WAL Replication
• Use the “archived” WAL logs for “recovery”
  on a standby system
• Disadvantages:
  • Only full database cluster replication
  • Master and slave must be binary-compatible
  • Rather slow across network
• Useful for:
  • High availability

                                                 25
Solution: Sequoia
• Formerly C[lustered]-JDBC
• Proxy offering clustering, load
  balancing and failover services
• Particularly useful for:
  • High availability
  • Read performance
• Currently only for Java/JDBC applications
http://sequoia.continuent.org/

                                              26
Solution: DRBD
•   File system (block device) replication
•   Linux kernel module
•   Standby system
•   Useful for:
    • High availability
    • Secure any service, not just a database system


http://www.drbd.org/
                                                  27
Solution: Shared Storage
•   NAS, iSCSI, Fiberchannel, ...
•   Available from many vendors
•   Standby system
•   Useful for:
    • High availability
    • Secure any service, not just a database system
• Single storage system is a possible point of
  failure

                                                  28
Summary
• Plenty of solutions for diverse applications
• Make a (project) plan.




                                                 29
Suggestions
• Minimum for any production installation:
  • Sensible disk clustering
     • RAID 10
     • Tablespace management
     • Separate disk(s) for WAL
  • DRBD or shared storage
• Slony-I for load balancing or warehousing
• Java developers consider Sequoia


                                              30
Outlook
•   Slony-II
•   WAL replication management
•   XA support
•   More packaging efforts




                                 31
The End
Replication Solutions for PostgreSQL




                                       32

More Related Content

PDF
PostgreSQL Scaling And Failover
PDF
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
ODP
PostgreSQL Replication in 10 Minutes - SCALE
PDF
Postgres & Red Hat Cluster Suite
 
PPT
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
PDF
PostgreSQL High Availability in a Containerized World
PDF
PostgreSQL replication
PDF
PostreSQL HA and DR Setup & Use Cases
PostgreSQL Scaling And Failover
Best Practices of HA and Replication of PostgreSQL in Virtualized Environments
PostgreSQL Replication in 10 Minutes - SCALE
Postgres & Red Hat Cluster Suite
 
Building tungsten-clusters-with-postgre sql-hot-standby-and-streaming-replica...
PostgreSQL High Availability in a Containerized World
PostgreSQL replication
PostreSQL HA and DR Setup & Use Cases

What's hot (20)

PDF
Tuning DB2 in a Solaris Environment
PDF
Built-in Replication in PostgreSQL
PDF
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
PPTX
PostgreSQL and Linux Containers
PDF
Postgres on OpenStack
 
PDF
Architecture for building scalable and highly available Postgres Cluster
PDF
Linux tuning to improve PostgreSQL performance
PDF
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
PDF
Best Practices with PostgreSQL on Solaris
PPT
PostgreSQL9.3 Switchover/Switchback
PPT
Deploying Maximum HA Architecture With PostgreSQL
PDF
Linux internals for Database administrators at Linux Piter 2016
PDF
My experience with embedding PostgreSQL
PDF
Geographically Distributed PostgreSQL
ODP
Gluster 3.3 deep dive
PDF
Out of the box replication in postgres 9.4
PDF
Deep Dive into RDS PostgreSQL Universe
PDF
Deploying postgre sql on amazon ec2
PPTX
PostgreSQL Hangout Parameter Tuning
PDF
PostgreSQL Disaster Recovery with Barman
Tuning DB2 in a Solaris Environment
Built-in Replication in PostgreSQL
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
PostgreSQL and Linux Containers
Postgres on OpenStack
 
Architecture for building scalable and highly available Postgres Cluster
Linux tuning to improve PostgreSQL performance
Problems with PostgreSQL on Multi-core Systems with MultiTerabyte Data
Best Practices with PostgreSQL on Solaris
PostgreSQL9.3 Switchover/Switchback
Deploying Maximum HA Architecture With PostgreSQL
Linux internals for Database administrators at Linux Piter 2016
My experience with embedding PostgreSQL
Geographically Distributed PostgreSQL
Gluster 3.3 deep dive
Out of the box replication in postgres 9.4
Deep Dive into RDS PostgreSQL Universe
Deploying postgre sql on amazon ec2
PostgreSQL Hangout Parameter Tuning
PostgreSQL Disaster Recovery with Barman
Ad

Viewers also liked (9)

PDF
Introduction to pg_cheat_funcs
PDF
PostgreSQL HA
PDF
Storage Replication in High-Performance High-Availability Environments
PDF
High Availability Storage (susecon2016)
PDF
HA+DRBD+Postgres - PostgresWest '08
PDF
Development of 8.3 In India
PDF
PostgreSQL9.0アップデート レプリケーションがやってきた!
PPT
]project-open[ Screenshots
PDF
Drbd9 and drbdmanage_june_2016
Introduction to pg_cheat_funcs
PostgreSQL HA
Storage Replication in High-Performance High-Availability Environments
High Availability Storage (susecon2016)
HA+DRBD+Postgres - PostgresWest '08
Development of 8.3 In India
PostgreSQL9.0アップデート レプリケーションがやってきた!
]project-open[ Screenshots
Drbd9 and drbdmanage_june_2016
Ad

Similar to Replication Solutions for PostgreSQL (20)

PDF
High Scalability Toronto: Meetup #2
PPTX
Intro to Big Data and NoSQL
KEY
Writing Scalable Software in Java
KEY
Leveraging MongoDB: An Introductory Case Study
PPTX
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
PDF
End of RAID as we know it with Ceph Replication
PDF
Petabyte scale on commodity infrastructure
PDF
Java scalability considerations yogesh deshpande
PDF
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
PPTX
Lessons learned from running Spark on Docker
PDF
Scalable Persistent Storage for Erlang: Theory and Practice
KEY
MongoDB Case Study at NoSQL Now 2012
PDF
Building Stream Infrastructure across Multiple Data Centers with Apache Kafka
PPTX
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
PDF
Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...
PDF
What CloudStackers Need To Know About LINSTOR/DRBD
PDF
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
KEY
Polyglot and functional (Devoxx Nov/2011)
PDF
Scalability, Availability & Stability Patterns
PDF
MongoBoston - MongoHQ
High Scalability Toronto: Meetup #2
Intro to Big Data and NoSQL
Writing Scalable Software in Java
Leveraging MongoDB: An Introductory Case Study
Kafka 0.8.0 Presentation to Atlanta Java User's Group March 2013
End of RAID as we know it with Ceph Replication
Petabyte scale on commodity infrastructure
Java scalability considerations yogesh deshpande
Jay Kreps on Project Voldemort Scaling Simple Storage At LinkedIn
Lessons learned from running Spark on Docker
Scalable Persistent Storage for Erlang: Theory and Practice
MongoDB Case Study at NoSQL Now 2012
Building Stream Infrastructure across Multiple Data Centers with Apache Kafka
A Survey of Advanced Non-relational Database Systems: Approaches and Applicat...
Nagios Conference 2014 - Jeremy Rust - Avoiding Downtime Using Linux High Ava...
What CloudStackers Need To Know About LINSTOR/DRBD
Modeling, estimating, and predicting Ceph (Linux Foundation - Vault 2015)
Polyglot and functional (Devoxx Nov/2011)
Scalability, Availability & Stability Patterns
MongoBoston - MongoHQ

More from Peter Eisentraut (20)

PDF
Programming with Python and PostgreSQL
PDF
Getting Started with PL/Proxy
PDF
Linux distribution for the cloud
PDF
Most Wanted: Future PostgreSQL Features
ODP
Porting Applications From Oracle To PostgreSQL
PDF
Porting Oracle Applications to PostgreSQL
PDF
PostgreSQL and XML
PDF
XML Support: Specifications and Development
PDF
PostgreSQL: Die Freie Datenbankalternative
PDF
The Road to the XML Type: Current and Future Developments
PDF
Access ohne Access: Freie Datenbank-Frontends
PDF
PostgreSQL and PL/Java
PDF
PostgreSQL News
PDF
PostgreSQL News
PDF
Access ohne Access: Freie Datenbank-Frontends
PDF
Docbook: Textverarbeitung mit XML
PDF
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
PDF
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
PDF
Spaß mit PostgreSQL
PDF
The Common Debian Build System (CDBS)
Programming with Python and PostgreSQL
Getting Started with PL/Proxy
Linux distribution for the cloud
Most Wanted: Future PostgreSQL Features
Porting Applications From Oracle To PostgreSQL
Porting Oracle Applications to PostgreSQL
PostgreSQL and XML
XML Support: Specifications and Development
PostgreSQL: Die Freie Datenbankalternative
The Road to the XML Type: Current and Future Developments
Access ohne Access: Freie Datenbank-Frontends
PostgreSQL and PL/Java
PostgreSQL News
PostgreSQL News
Access ohne Access: Freie Datenbank-Frontends
Docbook: Textverarbeitung mit XML
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail Sy...
Collateral Damage: Consequences of Spam and Virus Filtering for the E-Mail S...
Spaß mit PostgreSQL
The Common Debian Build System (CDBS)

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPTX
Cloud computing and distributed systems.
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Machine learning based COVID-19 study performance prediction
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Empathic Computing: Creating Shared Understanding
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Chapter 3 Spatial Domain Image Processing.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Cloud computing and distributed systems.
Reach Out and Touch Someone: Haptics and Empathic Computing
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Understanding_Digital_Forensics_Presentation.pptx
Dropbox Q2 2025 Financial Results & Investor Presentation
20250228 LYD VKU AI Blended-Learning.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Machine learning based COVID-19 study performance prediction
The Rise and Fall of 3GPP – Time for a Sabbatical?
Digital-Transformation-Roadmap-for-Companies.pptx
Empathic Computing: Creating Shared Understanding
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Big Data Technologies - Introduction.pptx
Chapter 3 Spatial Domain Image Processing.pdf

Replication Solutions for PostgreSQL

  • 1. Replication Solutions for PostgreSQL Peter Eisentraut petere@postgresql.org
  • 2. What's in a Term? • Replication? • Clustering? • High availability? • Failover? • Standby? • Putting data on more than one computer 2
  • 3. Space of Possibilities • Goals • What do you want to achieve? • Techniques • How can this be implemented? • Solutions • What software is available to do this? 3
  • 4. Goals • High availability • Performance • Read • Write • Wide-area networks • Offline peers 4
  • 5. Goal: High Availability • No one wants “low availability”! • Provisions for system failures • Software faults • Hardware faults • External interference 5
  • 6. Goal: Read Performance • Applications with: • many readers (e.g., library information system) • resource-intensive readers (e.g., data warehousing) • Distribute readers on more hardware. • Most often, one physical machine is enough. 6
  • 7. Goal: Write Performance • Applications with: • Many writers • Distribute writers on more hardware? • Constraint checking, conflict resolution?!? • Faster writing contradicts replication. • Partition, don't replicate! • RAID 0/striping is not replication – it makes things “worse”. • RAID 10 is a good idea, but not the topic here. 7
  • 8. Goal: Wide-Area Networks • Faster access across WANs • Reading? • Local copies • Writing? • Synchronization? 8
  • 9. Goal: Offline Peers • Synchronize data with laptops, handhelds, ... • “Road warriors” • May be considered very-low-latency WANs 9
  • 10. Techniques • Replication • Master/Slave • Asynchronous • Synchronous • Multi-Master • Asynchronous • Synchronous • Proxy • Standby system 10
  • 11. Technique: Replication Master/Slave Asynchronous • High(er) availability(?) • Read performance • Load spreading, load balancing • Offline peers M asy c n S (unidirectional sync.) 11
  • 12. Technique: Replication Master/Slave Synchronous • High availibility • Better read performance • Worse write performance M sy c n S 12
  • 13. Technique: Replication Multi-Master Asynchronous • Read performance • Faster access across WANs • Manage offline peers M M • Requires conflict asy c n resolution mechanism 13
  • 14. Technique: Replication Multi-Master Synchronous • “Holy grail of replication” • High availability • Read performance • Difficult to get good M M write performance sy c n 14
  • 15. Technique: Proxy • High availability • Read performance • Proxy instance should Proxy be redundant • Transparent to the application C C 15
  • 16. Technique: Standby System • High availability M sy c n S 16
  • 17. Constraints • Hardware • Operating system • Application 17
  • 19. Solutions • Slony-I, -II • PGCluster • DBMirror • pgpool • WAL replication • Sequoia • DRBD • Shared storage 19
  • 20. Solution: Slony-I (Slony ← слоны ← elephants) • Asynchronous master/slave replication • Multiple slaves, cascading possible • Particularly useful for: • Read performance (load balancing with pgpool) • Limited form of high availability • Offline slaves via file-based log shipping http://www.slony.info/ 20
  • 21. Solution: Slony-II • Synchronous master/master replication? • See Gavin Sherry's session for details 21
  • 22. Solution: PGCluster • Synchronous master/master replication • Replicates the query string • Particularly useful for: • Load balancing • High availability http://pgcluster.projects.postgresql.org/ 22
  • 23. Solution: DBMirror • Asynchronous master/slave replication • Very simple (compared to Slony-I) • Particularly useful for: • Read performance • Offline peers contrib/dbmirror/ in PostgreSQL source tree 23
  • 24. Solution: pgpool • Connection pool daemon for PostgreSQL • Supports simple proxying • Useful as frontend for Slony-I http://pgpool.projects.postgresql.org/ 24
  • 25. Solution: WAL Replication • Use the “archived” WAL logs for “recovery” on a standby system • Disadvantages: • Only full database cluster replication • Master and slave must be binary-compatible • Rather slow across network • Useful for: • High availability 25
  • 26. Solution: Sequoia • Formerly C[lustered]-JDBC • Proxy offering clustering, load balancing and failover services • Particularly useful for: • High availability • Read performance • Currently only for Java/JDBC applications http://sequoia.continuent.org/ 26
  • 27. Solution: DRBD • File system (block device) replication • Linux kernel module • Standby system • Useful for: • High availability • Secure any service, not just a database system http://www.drbd.org/ 27
  • 28. Solution: Shared Storage • NAS, iSCSI, Fiberchannel, ... • Available from many vendors • Standby system • Useful for: • High availability • Secure any service, not just a database system • Single storage system is a possible point of failure 28
  • 29. Summary • Plenty of solutions for diverse applications • Make a (project) plan. 29
  • 30. Suggestions • Minimum for any production installation: • Sensible disk clustering • RAID 10 • Tablespace management • Separate disk(s) for WAL • DRBD or shared storage • Slony-I for load balancing or warehousing • Java developers consider Sequoia 30
  • 31. Outlook • Slony-II • WAL replication management • XA support • More packaging efforts 31
  • 32. The End Replication Solutions for PostgreSQL 32