Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkl47-0002U8-9a for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Dec 2012 00:29:47 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tkl46-0004AC-DN for pgsql-jdbc@arkaria.postgresql.org; Tue, 18 Dec 2012 00:29:46 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkl45-0004A7-HA for pgsql-jdbc@postgresql.org; Tue, 18 Dec 2012 00:29:45 +0000 Received: from moutng.kundenserver.de ([212.227.126.171]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tkl43-0007ov-Ab for pgsql-jdbc@postgresql.org; Tue, 18 Dec 2012 00:29:44 +0000 Received: from [10.1.1.3] (124-169-225-8.dyn.iinet.net.au [124.169.225.8]) by mrelayeu.kundenserver.de (node=mrbap4) with ESMTP (Nemesis) id 0MhD7J-1TXKuT1Knh-00MM29; Tue, 18 Dec 2012 01:29:41 +0100 Message-ID: <50CFB8EC.6070402@2ndquadrant.com> Date: Tue, 18 Dec 2012 08:29:32 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Scott Harrington CC: pgsql-jdbc@postgresql.org Subject: Re: performance problem of Failover Datasource? References: <4DFA5A86.9030301@acm.org> <4DFA671F.2050005@acm.org> <4DFA9704.4000209@hogranch.com> <4DFAB403.5010309@acm.org> <4DFAB5B8.5010603@hogranch.com> <4DFAB9E2.4070905@acm.org> <1334056170219-5629626.post@n5.nabble.com> <1355303340886-5736270.post@n5.nabble.com> <50C9B102.2060208@cn.fujitsu.com> <50CA959E.4060603@cn.fujitsu.com> <50CB29BD.6090903@cn.fujitsu.com> <50CC2279.3090301@cn.fujitsu.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:zoYeMTLNu0/P5OSDYGmxZ0AlkTqPCrlMhx8weVxlLqT /acBf6fPpmVl0jDzv/wm71U9al2sCI6sGWZZ0t8+b5GBNdsXNS KJv/Ij5r8U6zJAP28Bickw7CWg2wRS4ISuAkeskH9ds4Z3sAlR roBmCtwA2bvcE0devQbtqv/HeI/ea7SDZ+nXN8zCGJOdK2h5b1 xPJ2esAuFrvaJuA3uUomJczSmzhGMtYP9gijh9QW0F1DILzUtG yqWuYskbLIt2k37DfV1Rej9meXl2b/D2n6lsjaypSevJpV3NrY sHBSinPP6ZcrHjT0eQ+QsYKxNQRqbhUycdWFaWVPSLF3diCTuX wr1/vOroCfx84PtM7fQ8= X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org On 16/12/2012 12:19 AM, Scott Harrington wrote: > On Sat, 15 Dec 2012, Chen Huajun wrote: > >> In this patch,I use Collections.synchronizedSet to synchronize within >> multi-threads. But i worry about locking operation is a litter >> frequent by Collections.synchronizedSet and may affect performance. I >> think using keword "synchronized" explicitly instead of >> Collections.synchronizedSet may reduce times of locking.Is there any >> better suggestion? >> >> In addition, I have a idea. By adjusting the order of hosts we also >> can implement a simple load balance while all of the hosts are master >> or read only slave. For example: Basically pick up the server >> randomly.If one server had dead remove it from the candidates, and >> retry the next server. And after a while(can be configured) re-add >> the dead host to the candidates because the dead server may had been >> repaired. >> >> What about that? > > Perhaps instead you could abstract this logic into a > org.postgresql.util.HostChooser interface, which would replace the > HostSpec[] array that currently gets passed around. There's certainly value to that. We're almost certainly goin to want to support things like connecting to any slave and asking it "which server is the master I should connect to" in future, so a way to abstract host selection would be a big win. -- Craig Ringer http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc