Multi-Master Replication Using Slony
Who Am I? Jim Mlodgenski Co-organizer of NYCPUG
Founder of Cirrus Technologies
Former Chief Architect of EnterpriseDB
What is Mult-Master? Multiple phyiscal servers in a cluster allow for the updating of data Increases Availability
Increases performance Most noticable over a WAN
CAP Theorem The theory put forth by Brewer that only 2 of the 3 are possible in a distributed system C onsistency
A vailability
P artition Tolerance
Sync vs. Async Synchronous All transactions applied to all server before a success is returned to the client Simpler to design and architect
At the expense of performance
Sync vs. Async Asynchronous A transaction is applied to a single server before a success is returned to the client About the same performance as a single server
Need to deal with conflict resolution
Existing Solutions Bucardo
PgPool
RubyRep
Bucardo Asynchronous multi-master, master-slave, event based replication solution Used in several production deployments
Limited to 2 masters
PgPool Synchronous statement based, multi-master replication solution Much more than a replication solution
Need to deal with Nondeterministic functions
RubyRep Asynchronous multi-master, event based replication solution Not a PostgreSQL only solution
Limited to 2 masters
What is Slony? Asynchronous master-slave, event based replication solution Proven production use cases
Cascading replication
Retail Store Problem Corporate HQ controls the pricing
The stores  control the daily sales information
Retail Store Problem The information pushed down for HQ is exactly what Slony is good at The tables controlled at HQ replicates to the many stores
The tables at the stores are read-only
Retail Store Problem A single replication set can control this May need to cascade if there are many stores slonik <<_EOF_ cluster name = HQ; node 1 admin conninfo = 'dbname=hq'; node 2 admin conninfo = 'dbname=store1'; node 3 admin conninfo = 'dbname=store2'; node 4 admin conninfo = 'dbname=store3'; node 5 admin conninfo = 'dbname=store4'; node 6 admin conninfo = 'dbname=store5'; init cluster ( id=1, comment = 'HQ Node'); create set (id=1, origin=1, comment='All HQ tables'); set add table (set id=1, origin=1, id=1, fully qualified name = 'public.items', comment='items table'); set add table (set id=1, origin=1, id=2, fully qualified name = 'public.prices', comment='prices table'); store node (id=2, comment = 'Store1 node', event node=1); store path (server = 1, client = 2, conninfo='dbname=hq'); store path (server = 2, client = 1, conninfo='dbname=store1'); ...
Retail Store Problem Replicating all of the stores data to HQ is the challenge Use table inheritance

Multi-Master Replication with Slony

  • 1.
  • 2.
    Who Am I?Jim Mlodgenski Co-organizer of NYCPUG
  • 3.
    Founder of CirrusTechnologies
  • 4.
    Former Chief Architectof EnterpriseDB
  • 5.
    What is Mult-Master?Multiple phyiscal servers in a cluster allow for the updating of data Increases Availability
  • 6.
    Increases performance Mostnoticable over a WAN
  • 7.
    CAP Theorem Thetheory put forth by Brewer that only 2 of the 3 are possible in a distributed system C onsistency
  • 8.
  • 9.
  • 10.
    Sync vs. AsyncSynchronous All transactions applied to all server before a success is returned to the client Simpler to design and architect
  • 11.
    At the expenseof performance
  • 12.
    Sync vs. AsyncAsynchronous A transaction is applied to a single server before a success is returned to the client About the same performance as a single server
  • 13.
    Need to dealwith conflict resolution
  • 14.
  • 15.
  • 16.
  • 17.
    Bucardo Asynchronous multi-master,master-slave, event based replication solution Used in several production deployments
  • 18.
    Limited to 2masters
  • 19.
    PgPool Synchronous statementbased, multi-master replication solution Much more than a replication solution
  • 20.
    Need to dealwith Nondeterministic functions
  • 21.
    RubyRep Asynchronous multi-master,event based replication solution Not a PostgreSQL only solution
  • 22.
    Limited to 2masters
  • 23.
    What is Slony?Asynchronous master-slave, event based replication solution Proven production use cases
  • 24.
  • 25.
    Retail Store ProblemCorporate HQ controls the pricing
  • 26.
    The stores control the daily sales information
  • 27.
    Retail Store ProblemThe information pushed down for HQ is exactly what Slony is good at The tables controlled at HQ replicates to the many stores
  • 28.
    The tables atthe stores are read-only
  • 29.
    Retail Store ProblemA single replication set can control this May need to cascade if there are many stores slonik <<_EOF_ cluster name = HQ; node 1 admin conninfo = 'dbname=hq'; node 2 admin conninfo = 'dbname=store1'; node 3 admin conninfo = 'dbname=store2'; node 4 admin conninfo = 'dbname=store3'; node 5 admin conninfo = 'dbname=store4'; node 6 admin conninfo = 'dbname=store5'; init cluster ( id=1, comment = 'HQ Node'); create set (id=1, origin=1, comment='All HQ tables'); set add table (set id=1, origin=1, id=1, fully qualified name = 'public.items', comment='items table'); set add table (set id=1, origin=1, id=2, fully qualified name = 'public.prices', comment='prices table'); store node (id=2, comment = 'Store1 node', event node=1); store path (server = 1, client = 2, conninfo='dbname=hq'); store path (server = 2, client = 1, conninfo='dbname=store1'); ...
  • 30.
    Retail Store ProblemReplicating all of the stores data to HQ is the challenge Use table inheritance