pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Travers <chris@travelamericas.com>
To: William Yu <wyu@talisys.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Postgresql replication
Date: Fri, 26 Aug 2005 10:26:44 -0700
Message-ID: <430F50D3.9090709@travelamericas.com> (raw)
In-Reply-To: <demg28$2k1m$1@news.hub.org>
References: <60fyszpby5.fsf@dba2.int.libertyrms.com>
	<20050824173106.76233.qmail@web53210.mail.yahoo.com>
	<deivg4$ura$1@news.hub.org>
	<dekdak$1v8e$1@news.hub.org>
	<430E5116.5000108@travelamericas.com>
	<demg28$2k1m$1@news.hub.org>

William Yu wrote:

> Chris Travers wrote:
>
>> Why not have the people who have rights to review this all write to 
>> the master database and have that replicated back?  It seems like 
>> latency is not really an issue.  Replication here is only going to 
>> complicate 
>
>
> What master database? Having a single master defeats the purpose of 
> load balancing to handle more users.

I guess I am thinking along different lines than you.  I was thinking 
that the simplest solution would be to have master/slave replication for 
*approved* transactions only and no replication for initial commits 
prior to approval.  This makes the assumption that a single transaction 
will be committed on a single server, and that a single transaction will 
not be split over multiple servers.  In this way, you can commit a 
pending transaction to any single server, and when it is approved, it 
gets replicated via the master.  See below for more.

>
>
> > things.  If it were me, I would be having my approval app pull data
> > from *all* of the databases independently and not rely on the
> > replication for this part.  The replication could then be used to
> > replicate *approved* data back to the slaves.
>
> If your app client happens to have high speed access to all servers, 
> fine. And you can guarantee uptime connections to all servers except 
> for the rare cases of hardware failure. The problem is if you don't, 
> you end up with every transaction running at the speed of the slowest 
> connection between a client and the farthest DB. While the final 
> status of a transaction does not need to show up anytime soon on a 
> user's screen, there still needs to be fast response for each 
> individual user action.

Well...  It depends on how it is implimented I guess.  If you pull 
transactional information in the background while the user is doing 
other things, then it shouldn't matter.  Besides, what should actually 
happen is that your connection is only as slow as the connection to the 
server which hosts the pending transaction you are trying to commit at 
the moment.  In this way, each request only goes to one server (the one 
which has the connection).  You could probably use DBI-Link and some 
clever materialized views to maintain the metadata at each location 
without replicating the whole transaction.  You could probably even use 
DBI-Link or dblink to pull the transactions in a transparent way.  Or 
you could replicate transactions into a pending queue dynamically...  
There are all sorts of ways you could make this respond well over slow 
connections.  Remember, PostgreSQL allows you to separate storage from 
presentation of the data, and this is quite powerful.

>
> How bad does the response get? I've done some simple tests comparing 
> APP <-LAN-> DB versus APP <-cross country VPN-> DB. Even simple 
> actions like inserting a recording and checking for a dupe key 
> violation (e.g. almost no bandwidth needed) takes about 10,000 times 
> longer than over a 100mbit LAN.

I think you could design a database such that duplicate keys are not an 
issue and only get checked on the master and then should never be a 
problem.

Thinking about it....  It seems here that one ends up with a sort of 
weird "multi-master" replication based on master/slave replication if 
you replicate these changes in the background (via another process, 
Notify, etc).

>
>
>> I still don't understand the purpose of replicating the pending data...
>
>
> Imagine a checking account. A request to make an online payment can be 
> made on any server. The moment the user submits a request, he sees it 
> on his screen. This request is considered pending and not a true 
> transaction yet. All requests are collected together via replication 
> and the "home" server for that account then can check the account 
> balance and decide whether there's enough funds to issue those payments.
>
Thinking about this....  The big issue is that you only want to 
replicate the deltas, not the entire account.  I am still thinking 
master/slave, but something where the deltas are replicated in the 
background or where the user, in checking his account, is actually 
querying the home server.  This second issue could be done via dblink or 
DBI-Link and would simply require that a master table linking the 
accounts with home servers be replicated (this should, I think, be 
fairly low-overhead).

Best Wishes,
Chris Travers
Metatron Technology Consulting



view thread (91+ messages)  latest in thread

Message-ID: <430F50D3.9090709@travelamericas.com>
Permalink:  ../430F50D3.9090709@travelamericas.com/
Also on:    postgresql.org/message-id/430F50D3.9090709@travelamericas.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: chris@travelamericas.com, wyu@talisys.com
  Subject: Re: Postgresql replication
  In-Reply-To: <430F50D3.9090709@travelamericas.com>
  References: <60fyszpby5.fsf@dba2.int.libertyrms.com> <20050824173106.76233.qmail@web53210.mail.yahoo.com> <deivg4$ura$1@news.hub.org> <dekdak$1v8e$1@news.hub.org> <430E5116.5000108@travelamericas.com> <demg28$2k1m$1@news.hub.org> <430F50D3.9090709@travelamericas.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox