Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id D217F1337B49 for ; Wed, 29 Dec 2010 07:25:56 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 90809-03 for ; Wed, 29 Dec 2010 11:25:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id D6C7A133616B for ; Wed, 29 Dec 2010 07:25:48 -0400 (AST) Received: from smadev.internal.net (localhost.internal.net [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id oBTBPjsh010512; Wed, 29 Dec 2010 13:25:45 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id oBTBPi84010511; Wed, 29 Dec 2010 13:25:44 +0200 (EET) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: Samuel Gendler , pgsql-jdbc@postgresql.org Subject: Re: PostgreSQL Authentication and Pooling in JBoss : static 'postgres' user VS dynamic jboss user Date: Wed, 29 Dec 2010 14:25:44 +0300 User-Agent: KMail/1.9.7 References: <201012281200.11993.achill@matrix.gatewaynet.com> <201012281713.27550.achill@matrix.gatewaynet.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201012291325.44403.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.451 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_BRBL_LASTEXT=1.449 X-Spam-Level: X-Archive-Number: 201012/87 X-Sequence-Number: 21325 =CE=A3=CF=84=CE=B9=CF=82 Tuesday 28 December 2010 20:08:59 =CE=B3=CF=81=CE= =AC=CF=88=CE=B1=CF=84=CE=B5: > On Tue, Dec 28, 2010 at 7:13 AM, Achilleas Mantzios < > achill@matrix.gatewaynet.com> wrote: >=20 > > > > You most probably are referring to a low-complexity system. > > Lets see this scenario. Imagine you want to indentify a cause for a var= iety > > of problems. Examples > > a) High load, you want to find what/who causes a very high load on the > > server > > >=20 > Unfortunately the most likely culprit in your system is going to be the h= uge > number of connections that postgres is having to deal with. You should r= ead > up on postgresql performance tuning and learn about how having large numb= ers > of connections to the server can impact postgresql performance. On the practical side, increasing the max_connections number to 2000 and ha= ving created 1000 connections on my test FreeBSD system did not produce any visible degradation in perfo= rmance.=20 Now on the theoretical side, It is true that connections eat up (some small= mem) from shared mem.=20 It is true that memory usage will increase by the use of work_mem when simu= ltaneous users perform sorting, etc also it is true that after several 100s of connections, the task of opening= a new connections becomes a rather expensive and resource intensive operation, but the end result is = nowhere as bad as you seem to believe. Anyways i am not endorsing anything of all this. All i am saying is that if someone has an accurate aproximation of the dist= ribution of connections and execution of statements in the system, then he can deploy a setup like = the one described, without killing his performance. Our system accepts about 100 distinct users per day average, with max value= observed during the last 10 months =3D 123 distinct users/day. (they are ordinary office employees) So simply setting max_connections=3D400 would solve the problem, (current v= alue is 100) even in the xtreme case when all 100 users run the most complex program in the app (requiring 4 con= nections), in the same time span (as defined by idle-timeout-minutes) (lets remind you here once again that we are talking about jboss here) Of course i will not have to do that. Post probably i will leave the curren= t value of max_connections, but i will have to play with idle-timeout-minutes, (decrease it, to make r= oom faster for new connections) >=20 > If you are looking for systemic problems that are related to authorizatio= n, > you are only going to create more of those kinds of problems by having su= ch > fine-grained authorization configuration within your database - forget to > grant an authority to user y on table x when some app state changes and y= ou > suddenly have authorization errors. This is not a problem, for every new table the initial auth script runs aga= in and it will be all right. (since GRANT ALL ON ALL TABLES IN SCHEMA to does not have any impact for future tables, otherwise not even that would be need). BTW, while we are at it, would you prefer "forgetting" to grant a user the = right to perform a certain task or giving anyone the power to exploit any SQL holes in the application run = by the one and only postgres super user? ;D >=20 > If you are looking for data issues like 'who was responsible for setting [snip] > If you > have high load and are write-mostly, then it could easily be an unaccepta= ble > increase (doubling) in load. >=20 Not only that, but i think that this is a userland solution. I prefer thing= s to be done system-wise. As an Example, if i deploy the setup as i present it here, and if indeed it= turns up to be a disaster it will cost me about 10 seconds to go into ../server/default/deploy/postgr= es-xa-ds.xml=20 comment the somesecdomain tag, uncomment= user and password and we are back to the same good old OnePool (JBossManagedConnectionPool) Now what would be ultra cool, is if we had the means to reauthenticate insi= de the same connection. As far as i have tested (but with a limited scope) with psql client, i didn= t manage to do that. If we could reauthenticate in the same connection, then we would have one s= tandard traditional pool with many shared connections and the user would be authenticated within thi= s existing connection. I do not know if this notion is supported in the postgersql protocol, jdbc,= or jboss pool in order to be a viable alternative. If smth like this existed it would bring an long lost (from the mainframe e= ra) functionality to the=20 J2EE world!! =2D-=20 Achilleas Mantzios