Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6240BB5DC35 for ; Wed, 17 Aug 2011 03:06:19 -0300 (ADT) 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 06103-02 for ; Wed, 17 Aug 2011 06:06:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from softlayer.compulab.co.il (50.23.254.54-static.reverse.softlayer.com [50.23.254.54]) by mail.postgresql.org (Postfix) with ESMTP id 63305B5DC37 for ; Wed, 17 Aug 2011 03:06:07 -0300 (ADT) Received: from [62.90.235.247] (port=56807 helo=zimbra-mta.compulab.co.il) by softlayer.compulab.co.il with esmtp (Exim 4.69) (envelope-from ) id 1QtZGP-0002sb-4y for pgsql-general@postgresql.org; Wed, 17 Aug 2011 09:06:05 +0300 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 2DB337E94A8 for ; Wed, 17 Aug 2011 09:06:04 +0300 (IDT) X-Virus-Scanned: amavisd-new at compulab.co.il Received: from zimbra-mta.compulab.co.il ([127.0.0.1]) by localhost (zimbra-mta.compulab.co.il [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id N-LqWEClqN-N for ; Wed, 17 Aug 2011 09:06:03 +0300 (IDT) Received: from [10.1.1.27] (sim-pc.compulab.local [10.1.1.27]) by zimbra-mta.compulab.co.il (Postfix) with ESMTP id 2EEB07E94A4 for ; Wed, 17 Aug 2011 09:06:03 +0300 (IDT) Message-ID: <4E4B5A38.20008@compulab.co.il> Date: Wed, 17 Aug 2011 09:05:44 +0300 From: Sim Zacks User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Lightning/1.0b2 Thunderbird/3.1.11 MIME-Version: 1.0 To: pgsql-general@postgresql.org Subject: Re: Using Postgresql as application server References: <4E46D0D7.3090700@officenet.no> <4E49B47E.8020401@ringerc.id.au> In-Reply-To: <4E49B47E.8020401@ringerc.id.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - softlayer.compulab.co.il X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - compulab.co.il X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.132 tagged_above=-5 required=5 tests=BAYES_00=-1.9, KHOP_DYNAMIC=0.768 X-Spam-Level: X-Archive-Number: 201108/535 X-Sequence-Number: 178817 On 08/16/2011 03:06 AM, Craig Ringer wrote: > On 15/08/2011 10:36 PM, Merlin Moncure wrote: >> On Sat, Aug 13, 2011 at 2:30 PM, Andreas Joseph Krogh >> wrote: >>> No, PG has never, and will never, act as an application-server. >> Why in the world not? > > The biggest reason is safety. Beyond that, the lack of autonomous > transactions, stored procedures, in-DB timers, and support for any > protocol other than the native Pg database query protocol mean it's also > rather impractical. > > I guess theoretically one could embed a JVM / Python instance / whatever > in the postmaster and have it spawn new backends for incoming > connections with other protocols. But ... why? Why add all that > complexity and - more importantly - contaiminate PostgreSQL's address > space with more code that can fail when you don't have to? PLs and user > C procedures are already risk enough as far as I'm concerned. > As I've mentioned in other posts, we are using postgresql as a hybrid application server and have found it to be very practical and easy to code. For functions that need to run on a regular basis, we use a cron job, though from what I understand pgAgent should be able to handle that just as well. Instead of using Listen/Notify to tell an application to send e-mails, we have an email function written in plpython that sends the email directly. The reason to do this is because it gives you "write once" code which makes your application pretty much client-agnostic. PG already spawns a new backend for each connection. So your specialized code has little chance of hosing the whole database. We connect to other databases when we need to, mostly mysql using the MySQLdb python module, to move data to and from our website. Scalability would be increased with multi-master replication, which bucardo currently does (I haven't tested it yet). One issue you have is using database style hardware for application server needs, which may be more expensive.