Re: libpq connectoin redirect

Lists: pgsql-hackers
From: feng tian <ft_uw(at)hotmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: libpq connectoin redirect
Date: 2010-04-21 05:03:10
Message-ID: BAY144-W986879BF29F093C17E6F280090@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Hi,

I want to load balance a postgres server on 4 physical machines, say 127.0.0.11-14. I can set up a pgbouncer on 127.0.0.10 and connection pooling to my four boxes. However, the traffic from/to clients will go through an extra hop. Another way to do this, is to send the client an "redirect" message. When client connect to 127.0.0.10, instead of accepting the connection, it can reply to client telling it to reconnect to one of the server on 127.0.0.11-14.

I am planning to write/submit a patch to do that. I wonder if there is similar effort in extending libpq protocol, or, if you have better ideas on how to achieve this.

Thank you,
Feng


_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5


From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: libpq connectoin redirect
Date: 2010-04-21 21:06:47
Message-ID: 4BCF68E7.2000004@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

feng tian wrote:
> Hi,
>
> I want to load balance a postgres server on 4 physical machines, say
> 127.0.0.11-14. I can set up a pgbouncer on 127.0.0.10 and connection
> pooling to my four boxes. However, the traffic from/to clients will
> go through an extra hop. Another way to do this, is to send the
> client an "redirect" message. When client connect to 127.0.0.10,
> instead of accepting the connection, it can reply to client telling it
> to reconnect to one of the server on 127.0.0.11-14.
>
> I am planning to write/submit a patch to do that. I wonder if there
> is similar effort in extending libpq protocol, or, if you have better
> ideas on how to achieve this.

how do you plan on maintaining consistency, transactional integrity and
atomicity of updates across these 4 machines?


From: James William Pye <lists(at)jwp(dot)name>
To: feng tian <ft_uw(at)hotmail(dot)com>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq connectoin redirect
Date: 2010-04-21 22:52:39
Message-ID: E1274ECA-F991-4BE1-B68E-233209997F75@jwp.name
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Apr 20, 2010, at 10:03 PM, feng tian wrote:
> Another way to do this, is to send the client an "redirect" message. When client connect to 127.0.0.10, instead of accepting the connection, it can reply to client telling it to reconnect to one of the server on 127.0.0.11-14.

ISTM that this would be better handled at a higher-level. That is, given a server (127.0.0.10) that holds 127.0.0.11-14. Connect to that server and query for the correct target host.


From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: feng tian <ft_uw(at)hotmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: libpq connectoin redirect
Date: 2010-04-22 05:30:40
Message-ID: 4BCFDF00.6080101@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

feng tian wrote:
> Hi,
>
> I want to load balance a postgres server on 4 physical machines, say 127.0.0.11-14. I can set up a pgbouncer on 127.0.0.10 and connection pooling to my four boxes. However, the traffic from/to clients will go through an extra hop. Another way to do this, is to send the client an "redirect" message. When client connect to 127.0.0.10, instead of accepting the connection, it can reply to client telling it to reconnect to one of the server on 127.0.0.11-14.

One common way to do that is to set up one DNS entry for those 4 IP
addresses.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com


From: feng tian <ft_uw(at)hotmail(dot)com>
To: <lists(at)jwp(dot)name>
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq connectoin redirect
Date: 2010-04-22 16:42:06
Message-ID: BAY144-W63D0F0E614A37FDDA973280080@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


While these can be handled at higher level, for example, by setting
up LDAP or as Hekki suggested, tricking DNS, the problem is that
I don't have control of how the user connect to the server. They
may not use LDAP. Solution like pgbouncer has advantages. User
just get one ip/port and everything else happens automatically.

Thanks,

> Subject: Re: [HACKERS] libpq connectoin redirect
> From: lists(at)jwp(dot)name
> Date: Wed, 21 Apr 2010 15:52:39 -0700
> CC: pgsql-hackers(at)postgresql(dot)org
> To: ft_uw(at)hotmail(dot)com
>
> On Apr 20, 2010, at 10:03 PM, feng tian wrote:
> > Another way to do this, is to send the client an "redirect" message. When client connect to 127.0.0.10, instead of accepting the connection, it can reply to client telling it to reconnect to one of the server on 127.0.0.11-14.
>
> ISTM that this would be better handled at a higher-level. That is, given a server (127.0.0.10) that holds 127.0.0.11-14. Connect to that server and query for the correct target host.

_________________________________________________________________
Hotmail is redefining busy with tools for the New Busy. Get more from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_2


From: feng tian <ft_uw(at)hotmail(dot)com>
To:
Cc: <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: libpq connectoin redirect
Date: 2010-04-22 16:51:12
Message-ID: BAY144-W6A8957F6B5422B3D522A980080@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Hi, John,

The change will be on the libpq client side. I am not saying this is a general
solution for the distributed transaction/scale out. However, in many cases, it
is very useful. For example, in my case, I have about 100 departments each has
it own database. The balance machine can just redirect to the right box according
to database/user. The 4 boxes I have may not even get domain name or static IP.
Another scenario, if I have some kind of replication set up, I can send transaction
processing to master and analytic reporting query to slaves.

Thanks,
Feng

feng tian wrote:
Hi,

I want to load balance a postgres server on 4 physical
machines, say
127.0.0.11-14. I can set up a pgbouncer on 127.0.0.10 and
connection
pooling to my four boxes. However, the traffic from/to clients
will
go through an extra hop. Another way to do this, is to send
the
client an "redirect" message. When client connect to
127.0.0.10,
instead of accepting the connection, it can reply to client
telling it
to reconnect to one of the server on 127.0.0.11-14.

I am planning to write/submit a patch to do that. I wonder if
there
is similar effort in extending libpq protocol, or, if you have
better
ideas on how to achieve this.

how do you plan on maintaining consistency, transactional
integrity and
atomicity of updates across these 4 machines?

_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4