SlideShare a Scribd company logo
PostgreSQL Replication
T
o
r
o
n
t
o
P
U
G   Steven Singer
    ssinger_pg@sympatico.ca
    FreeNode: stevenSn

                              July 28 2008
Who am I
T   SELECT * FROM pg_user where name='Steve'
o
r   ●   PostgreSQL user since 6.5
o   ●   Author of contrib/dbmirror
n       included with 7.x
t   ●   Software developer for a local
o       consulting company
P
U
    ●   Occasional contributor to side
        projects
G
The Golden Rule
T
o
r   ●   You can't have everything
o   ●   What you want != what you
n       need
t   ●   Determine need from
o       requirements
P
U
    ●   Be prepared to accept trade-
        offs
G
    ●   If you've already been sold on
        Oracle RAC, go and buy RAC
The Choices
T
o                         pgcluster
                                         pl/proxy
r               slony
                          pgcluster-II
                                         Mammoth
o          dbmirror                       RepDB
n       longdist                          Bucardo
t   pgpool
                                          Cybercluster

o   pgpool-II
                                              erserve
                                               rserv
P   Sequioa                        NTT WAL shipping
U   PITR
                             pg_dump/pg_restore
G     postgres-r      pyReplica    EDB Replicator
Why Replication?
T
o
r   ●   Because it is fun?
o   ●   So you can buy twice the
n       number of licenses?
t   ●   To distribute your data?
o
P
    ●   So you can be buzzword
U       compliant?
G
Fail-Over
T
o
r   ●   Goal: To have additional
o       database servers standing by in
n       case of:
t       –   Hardware Failure
o       –   DBA/Application mistakes
P       –   Maintenance
U   ●   Turning on a standby means
G       failing the master
Automatic or manual
T
o
r   ●   Who makes the decision to
o       promote a slave to a master?
n   ●   Computer or human?
t   ●   Look at your possible failures,
o       how can you detect them?
P
U
    ●    When will the wrong decision
        be made?
G
Load Balancing
T
o
r   ●   Goal: Improve performance by
o       adding more servers
n   ●   Master slave or multi-master?
t   ●   You can only do queries on
o       slaves
P
U
    ●   Multi-Master is really hard
G
Load Balancing : slaves
T
o
r   ●   Send queries to slaves
o   ●   Run query parts on machines
n       and combine results
t   ●   Partition some data across
o       servers (sharding)
P
U
    ●   Topic on its own
G   Question: How stale will you allow your slaves to be?
Trigger based
T            Replication
o
r   ●   Slony, Longdiste, Bucardo
o   ●   Uses ON INSERT,ON
n       UPDATE,ON DELETE triggers
t   ●   Slaves jump between consistent
o       snapsnots of master
P
U
    ●   Asynchronous
G   ●   Performance impact on master
    ●   No triggers will fires on DDL
Slony
T
o
r   ●   www.slony.info
o   ●   Developed by Afillias
n   ●   Async trigger based,
t       master/slave
o
P
    ●   Most widely deployed Postgreql
U       replication solution
G   ●   Very flexible
    ●   Allows for complicated setups
    ●   Some rough edges
Longdiste
T
o
r   ●   https://developer.skype.com/Sk
o       ypeGarage/DbProjects/SkyTools
n   ●   Async trigger based, master
t       slave
o   ●   Part of SkyTools from Skype
P
U
    ●   Based on experience with Slony
        but simpler; less features
G
    ●   Can't cascade slaves
    ●   No switchover support (Today)
Bucardo
T
o
r   ●   http://bucardo.org
o   ●   Async trigger based
n   ●   Developed by backcountry.com
t
o   ●   Allows multi-master writes with
P       user specified conflict
U       resolution
G
Middleware based
T       statement replication
o
r   ●   pgpool-II, pgcluster, Continuent,
o       GridSQL
n   ●   Sits in-between your application
t       and PostgreSQL
o   ●   Redirects SQL to one or more of
P       your databases
U   ●   How do you know all databases
G       contain the same data?
Middleware - Issues
T
o   ●   INSERT INTO x VALUES (rand())
r   ●   Functions/Stored Procedures, or
o       timestamps are a bad idea
n   ●   How do you ensure things
t       happen in the same order on all
o       nodes?
P   ●   What if a COMMIT on the
U       second node fails?
G
    ●   Limitations fine for some
        applications
Sequoia
T
o
r   ●   http://sequoia.continuent.org/Hom
o   ●   Middleware
n   ●   Supports multiple RDBMS
t
o   ●   Has its own journaling
P   ●   Ensure all SQL writers
U       understand how it works
G
PITR
T
o
r   ●   Point-In Time Recovery
o   ●   WAL segments are sent to the
n       slaves
t   ●   Aysnc (today)
o
P
    ●   Can't query slaves (today)
U       unless you bring them up
G   ●   Rolling slaves with ZFS?
    ●   Only good for failover (today)
Multi-Master
T
o
r   ●   If the same row is changed on
o       two servers around the same
n       time?
t   ●   Solving this in the general
o       sense is really hard.
P   ●   Don't go here unless you
U       need to
G
Works in progress
T
o
r   ●   Not Production Ready
o   ●   Serious technical problems to
n       be worked out
t   ●   If your up for a challenge
o
P
    ●   Good place to spend your RAC
U       budget
G
postgres-r
T
o
r   ●   Multi Master based on a group
o       communication system
n   ●   All nodes process all
t       statements in the same order
o       (total order)
P   ●   Depends on a GCS like Spread
U   ●   Recently open-sourced
G
pgcluster-II
T
o
r   ●   Multi Master
o   ●   Shared disc
n   ●   Presented at pgconn 07 not
t       released
o
P
    ●   Status unknown
U
G
Rules of Thumb
T
o
r   ●   PITR if it will meet your needs
o   ●   Slony or Longdiste if you need
n       to query your slaves
t   ●   Find a way around multi-master
o
P
    ●   Avoid statement based
U       solutions if consistency is
        important
G
Questions?
T
o
r
o
n
t
o
P
U   Steven Singer
G   ssinger_pg@sympatico.ca
    FreeNode: stevenSn

More Related Content

PPTX
Introduce gobject introspection
PDF
Introduction to Renjin, the alternative engine for R
ODP
GStreamer Instruments
PDF
Understanding how concurrency work in os
DOCX
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
PDF
Fisl13 gstreamer
PDF
PostgreSQL Development Today: 9.0
PDF
PostgreSQL Replication Solutions
Introduce gobject introspection
Introduction to Renjin, the alternative engine for R
GStreamer Instruments
Understanding how concurrency work in os
Bsdtw17: johannes m dieterich: high performance computing and gpu acceleratio...
Fisl13 gstreamer
PostgreSQL Development Today: 9.0
PostgreSQL Replication Solutions

Similar to PostgreSQL Replication (20)

PDF
Replication Solutions for PostgreSQL
PDF
Pg92 HA, LCA 2012, Ballarat
PDF
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
PDF
Open Source SQL Databases
ODP
Pro PostgreSQL, OSCon 2008
PDF
What every developer should know about database scalability, PyCon 2010
PDF
pgpool: Features and Development
PPTX
Megastore by Google
PDF
Asynchronous Replication for PostgreSQL Slony
PDF
Advanced MySQL Replication Architectures - Luis Soares
PDF
Postgres Vienna DB Meetup 2014
PDF
Elephants in the Cloud
PPTX
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
PDF
An evening with Postgresql
PDF
Implementing the Future of PostgreSQL Clustering with Tungsten
PDF
Where do I put this data? #lessql
PDF
Buytaert kris my_sql-pacemaker
PDF
Creating customized openSUSE versions with SUSE Studio
PDF
PostgreSQL Scaling And Failover
PPTX
No sql solutions - 공개용
Replication Solutions for PostgreSQL
Pg92 HA, LCA 2012, Ballarat
Streaming Replication (Keynote @ PostgreSQL Conference 2009 Japan)
Open Source SQL Databases
Pro PostgreSQL, OSCon 2008
What every developer should know about database scalability, PyCon 2010
pgpool: Features and Development
Megastore by Google
Asynchronous Replication for PostgreSQL Slony
Advanced MySQL Replication Architectures - Luis Soares
Postgres Vienna DB Meetup 2014
Elephants in the Cloud
SCALE 15x Minimizing PostgreSQL Major Version Upgrade Downtime
An evening with Postgresql
Implementing the Future of PostgreSQL Clustering with Tungsten
Where do I put this data? #lessql
Buytaert kris my_sql-pacemaker
Creating customized openSUSE versions with SUSE Studio
PostgreSQL Scaling And Failover
No sql solutions - 공개용
Ad

More from elliando dias (20)

PDF
Clojurescript slides
PDF
Why you should be excited about ClojureScript
PDF
Functional Programming with Immutable Data Structures
PPT
Nomenclatura e peças de container
PDF
Geometria Projetiva
PDF
Polyglot and Poly-paradigm Programming for Better Agility
PDF
Javascript Libraries
PDF
How to Make an Eight Bit Computer and Save the World!
PDF
Ragel talk
PDF
A Practical Guide to Connecting Hardware to the Web
PDF
Introdução ao Arduino
PDF
Minicurso arduino
PDF
Incanter Data Sorcery
PDF
PDF
Fab.in.a.box - Fab Academy: Machine Design
PDF
The Digital Revolution: Machines that makes
PDF
Hadoop + Clojure
PDF
Hadoop - Simple. Scalable.
PDF
Hadoop and Hive Development at Facebook
PDF
Multi-core Parallelization in Clojure - a Case Study
Clojurescript slides
Why you should be excited about ClojureScript
Functional Programming with Immutable Data Structures
Nomenclatura e peças de container
Geometria Projetiva
Polyglot and Poly-paradigm Programming for Better Agility
Javascript Libraries
How to Make an Eight Bit Computer and Save the World!
Ragel talk
A Practical Guide to Connecting Hardware to the Web
Introdução ao Arduino
Minicurso arduino
Incanter Data Sorcery
Fab.in.a.box - Fab Academy: Machine Design
The Digital Revolution: Machines that makes
Hadoop + Clojure
Hadoop - Simple. Scalable.
Hadoop and Hive Development at Facebook
Multi-core Parallelization in Clojure - a Case Study
Ad

Recently uploaded (20)

PDF
cuic standard and advanced reporting.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Encapsulation theory and applications.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Encapsulation theory and applications.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
20250228 LYD VKU AI Blended-Learning.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Chapter 3 Spatial Domain Image Processing.pdf
Understanding_Digital_Forensics_Presentation.pptx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Monthly Chronicles - July 2025
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Advanced methodologies resolving dimensionality complications for autism neur...
Modernizing your data center with Dell and AMD

PostgreSQL Replication

  • 1. PostgreSQL Replication T o r o n t o P U G Steven Singer ssinger_pg@sympatico.ca FreeNode: stevenSn July 28 2008
  • 2. Who am I T SELECT * FROM pg_user where name='Steve' o r ● PostgreSQL user since 6.5 o ● Author of contrib/dbmirror n included with 7.x t ● Software developer for a local o consulting company P U ● Occasional contributor to side projects G
  • 3. The Golden Rule T o r ● You can't have everything o ● What you want != what you n need t ● Determine need from o requirements P U ● Be prepared to accept trade- offs G ● If you've already been sold on Oracle RAC, go and buy RAC
  • 4. The Choices T o pgcluster pl/proxy r slony pgcluster-II Mammoth o dbmirror RepDB n longdist Bucardo t pgpool Cybercluster o pgpool-II erserve rserv P Sequioa NTT WAL shipping U PITR pg_dump/pg_restore G postgres-r pyReplica EDB Replicator
  • 5. Why Replication? T o r ● Because it is fun? o ● So you can buy twice the n number of licenses? t ● To distribute your data? o P ● So you can be buzzword U compliant? G
  • 6. Fail-Over T o r ● Goal: To have additional o database servers standing by in n case of: t – Hardware Failure o – DBA/Application mistakes P – Maintenance U ● Turning on a standby means G failing the master
  • 7. Automatic or manual T o r ● Who makes the decision to o promote a slave to a master? n ● Computer or human? t ● Look at your possible failures, o how can you detect them? P U ● When will the wrong decision be made? G
  • 8. Load Balancing T o r ● Goal: Improve performance by o adding more servers n ● Master slave or multi-master? t ● You can only do queries on o slaves P U ● Multi-Master is really hard G
  • 9. Load Balancing : slaves T o r ● Send queries to slaves o ● Run query parts on machines n and combine results t ● Partition some data across o servers (sharding) P U ● Topic on its own G Question: How stale will you allow your slaves to be?
  • 10. Trigger based T Replication o r ● Slony, Longdiste, Bucardo o ● Uses ON INSERT,ON n UPDATE,ON DELETE triggers t ● Slaves jump between consistent o snapsnots of master P U ● Asynchronous G ● Performance impact on master ● No triggers will fires on DDL
  • 11. Slony T o r ● www.slony.info o ● Developed by Afillias n ● Async trigger based, t master/slave o P ● Most widely deployed Postgreql U replication solution G ● Very flexible ● Allows for complicated setups ● Some rough edges
  • 12. Longdiste T o r ● https://developer.skype.com/Sk o ypeGarage/DbProjects/SkyTools n ● Async trigger based, master t slave o ● Part of SkyTools from Skype P U ● Based on experience with Slony but simpler; less features G ● Can't cascade slaves ● No switchover support (Today)
  • 13. Bucardo T o r ● http://bucardo.org o ● Async trigger based n ● Developed by backcountry.com t o ● Allows multi-master writes with P user specified conflict U resolution G
  • 14. Middleware based T statement replication o r ● pgpool-II, pgcluster, Continuent, o GridSQL n ● Sits in-between your application t and PostgreSQL o ● Redirects SQL to one or more of P your databases U ● How do you know all databases G contain the same data?
  • 15. Middleware - Issues T o ● INSERT INTO x VALUES (rand()) r ● Functions/Stored Procedures, or o timestamps are a bad idea n ● How do you ensure things t happen in the same order on all o nodes? P ● What if a COMMIT on the U second node fails? G ● Limitations fine for some applications
  • 16. Sequoia T o r ● http://sequoia.continuent.org/Hom o ● Middleware n ● Supports multiple RDBMS t o ● Has its own journaling P ● Ensure all SQL writers U understand how it works G
  • 17. PITR T o r ● Point-In Time Recovery o ● WAL segments are sent to the n slaves t ● Aysnc (today) o P ● Can't query slaves (today) U unless you bring them up G ● Rolling slaves with ZFS? ● Only good for failover (today)
  • 18. Multi-Master T o r ● If the same row is changed on o two servers around the same n time? t ● Solving this in the general o sense is really hard. P ● Don't go here unless you U need to G
  • 19. Works in progress T o r ● Not Production Ready o ● Serious technical problems to n be worked out t ● If your up for a challenge o P ● Good place to spend your RAC U budget G
  • 20. postgres-r T o r ● Multi Master based on a group o communication system n ● All nodes process all t statements in the same order o (total order) P ● Depends on a GCS like Spread U ● Recently open-sourced G
  • 21. pgcluster-II T o r ● Multi Master o ● Shared disc n ● Presented at pgconn 07 not t released o P ● Status unknown U G
  • 22. Rules of Thumb T o r ● PITR if it will meet your needs o ● Slony or Longdiste if you need n to query your slaves t ● Find a way around multi-master o P ● Avoid statement based U solutions if consistency is important G
  • 23. Questions? T o r o n t o P U Steven Singer G ssinger_pg@sympatico.ca FreeNode: stevenSn