Thread: server protocol used by Postgres

server protocol used by Postgres

From
Peter Korsgaard
Date:
Hi!

I'm working on a SQL proxy for distributing load as a project at
university. The idea is to have a system, which can transparently be
inserted between an existing database and its clients, to allow the
system performance (selects) to scale by adding more databases as the
load increases. This way we don't need to recode the clients.

Below is a diagram of the system.
 Client 1                                    Database 1
 _____                                         _____
 |   |                                         |   |
 |   |<-----         Proxy (distributor) ----->|   |
 |___|     |     SQL     _____     SQL   |     |___|
           ------------->|   |<-----------
   .                     |   |                   .
   .       ------------->|___|<-----------       .
           |     SQL               SQL   |
 Client n  |                             |   Database m
 _____     |                             |     _____
 |   |     |                             |     |   |
 |   |<-----                             ----->|   |
 |___|                                         |___|

All databases contain a replicate of the same data. From the clients'
point of view the proxy looks like a normal postgres database.

The job of the proxy is to look at the querys: If the query is a
select it can be transmitted to only on of the databases, but if it is
an update/insert it has to go to all of them. Furthermore it should
monitor the set of databases, and exclude databases that stop working,
and update them when thay again become available.

I have been browsing a bit around the develop corner at postgresql.org
and looking at the c client library, but I haven't been able to find
any information about the protocol used between the postgres database and
the clients, Is such information available anywhere, or could anyone
point me to areas of interest in the postgres server code?

Thanks in advance!

--
Bye, Peter Korsgaard


Re: server protocol used by Postgres

From
Tom Lane
Date:
Peter Korsgaard <jacmet@control.auc.dk> writes:
> I have been browsing a bit around the develop corner at postgresql.org
> and looking at the c client library, but I haven't been able to find
> any information about the protocol used between the postgres database and
> the clients,

See the developer's guide at
http://www.postgresql.org/devel-corner/docs/postgres/
especially chapter 4,
http://www.postgresql.org/devel-corner/docs/postgres/protocol.htm

            regards, tom lane

Re: server protocol used by Postgres

From
Peter Korsgaard
Date:
On Thu, 2 Nov 2000, Tom Lane wrote:

> > and looking at the c client library, but I haven't been able to find
> > any information about the protocol used between the postgres database and
> > the clients,
>
> See the developer's guide at
> http://www.postgresql.org/devel-corner/docs/postgres/

Doh! Yes, it is right there, sorry!

Instead of reimplementing the protocol I might be able to use some of the
existing code, could you direct me to the specific areas of interest in
the sourcecode?

--
Bye, Peter Korsgaard