Re: Persistent Connections in Webserver Environment

From: Scott Marlowe <smarlowe(at)g2switchworks(dot)com>
To: Hannes Dorbath <light(at)theendofthetunnel(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Persistent Connections in Webserver Environment
Date: 2005-05-02 15:41:26
Message-ID: 1115048486.13303.1445.camel@state.g2switchworks.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, 2005-05-02 at 10:32, Hannes Dorbath wrote:
> On 02.05.2005 16:41, Marco Colombo wrote:
>
> > Have you measured the real gain in using persistent connections at all?
>
> As simple as possible:
>
> <?php
> require_once('Benchmark/Timer.php');
> $timer =& new Benchmark_Timer();
> $timer->start();
>
> pg_pconnect('host=myhost dbname=database user=user');
> pg_query("SET search_path TO myschema;");
>
> $q = "SELECT u.login FROM users WHERE u.user_id = 1;";
>
> $qr = pg_query($q);
>
> print_r(pg_fetch_all($qr));
>
> $timer->setMarker('Database');
> $timer->stop();
> $timer->display();
> ?>
>
> Results:
>
> pconnect: 0.001435995101928
> connect: 0.016793966293335

But if the average PHP script takes 50 milliseconds to start up and 100
milliseconds to run, then either one is still pretty much noise.

Plus, neither benchmark is interesting really until you have pretty good
parallel load running.

It may well be that pconnect makes a difference under heavier load. But
most the time, I've seen one or two queries that could be tuned make a
much larger difference than using pconnect.

And, if you haven't got apache / postgresql configured properly and run
out of connections, the connect time goes from 16 mS to hours as your
users wait for you to fix the connectivity issues. :)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hannes Dorbath 2005-05-02 16:17:26 Re: Persistent Connections in Webserver Environment
Previous Message Hannes Dorbath 2005-05-02 15:40:05 Re: Persistent Connections in Webserver Environment