Unix Technical Forum

Keeping processes open for re-use

This is a discussion on Keeping processes open for re-use within the Pgsql Performance forums, part of the PostgreSQL category; --> Dear All Looking at the processes running on our server, it appears that each time a web server program ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql Performance

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-19-2008, 09:44 AM
Hilary Forbes
 
Posts: n/a
Default Keeping processes open for re-use

Dear All

Looking at the processes running on our server, it appears that each time a web server program makes a call to the database server, we start a new process on the database server which obviously has a start up cost. In Apache, for example, you can say at start up time,that you want the machine to reserve eg 8 processes and keep them open at all times so you don't have this overhead until you exceed this minimum number. Is there a way that we can achieve this in Postgres? We have a situation whereby we have lots of web based users doing short quick queries and obviously the start up time for a process must add to their perceived response time.

Thanks
Hilary





Hilary Forbes
DMR Limited (UK registration 01134804)
A DMR Information and Technology Group company (www.dmr.co.uk)
Direct tel 01689 889950 Fax 01689 860330
DMR is a UK registered trade mark of DMR Limited
************************************************** ********
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-19-2008, 09:44 AM
Csaba Nagy
 
Posts: n/a
Default Re: Keeping processes open for re-use

On Thu, 2006-11-09 at 13:35, Hilary Forbes wrote:
> [snip] Is there a way that we can achieve this in Postgres? We have a
> situation whereby we have lots of web based users doing short quick
> queries and obviously the start up time for a process must add to
> their perceived response time.


Yes: google for "connection pooling". Note that different solutions
exist for different programming languages, so you should look for
connection pooling for the language you're using.

HTH,
Csaba.



---------------------------(end of broadcast)---------------------------
TIP 7: You can help support the PostgreSQL project by donating at

http://www.postgresql.org/about/donate

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-19-2008, 09:44 AM
imad
 
Posts: n/a
Default Re: Keeping processes open for re-use

Yes. This is connection pooling. You can find a lot of examples from
the internet on connection pooling, rather source codes. Also keep in
mind that connection pools can be maintained on the application as
well as the database server side. Check which one suits you.


--Imad
www.EnterpriseDB.com


On 11/9/06, Hilary Forbes <hforbes@dmr.co.uk> wrote:
> Dear All
>
> Looking at the processes running on our server, it appears that each time a
> web server program makes a call to the database server, we start a new
> process on the database server which obviously has a start up cost. In
> Apache, for example, you can say at start up time,that you want the machine
> to reserve eg 8 processes and keep them open at all times so you don't have
> this overhead until you exceed this minimum number. Is there a way that we
> can achieve this in Postgres? We have a situation whereby we have lots of
> web based users doing short quick queries and obviously the start up time
> for a process must add to their perceived response time.
>
> Thanks
> Hilary
>
>
>
>
>
> Hilary Forbes
> DMR Limited (UK registration 01134804)
> A DMR Information and Technology Group company (www.dmr.co.uk)
> Direct tel 01689 889950 Fax 01689 860330
> DMR is a UK registered trade mark of DMR Limited
> ************************************************** ********


---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-19-2008, 09:44 AM
Shane Ambler
 
Posts: n/a
Default Re: Keeping processes open for re-use

Csaba Nagy wrote:
> On Thu, 2006-11-09 at 13:35, Hilary Forbes wrote:
>> [snip] Is there a way that we can achieve this in Postgres? We have a
>> situation whereby we have lots of web based users doing short quick
>> queries and obviously the start up time for a process must add to
>> their perceived response time.

>
> Yes: google for "connection pooling". Note that different solutions
> exist for different programming languages, so you should look for
> connection pooling for the language you're using.
>


If you are using PHP then persistent connections may be a simpler way if
it is enough for your needs.

Basically replace pg_connect with pg_pconnect

Other languages may have a similar option.

http://php.net/manual/en/features.pe...onnections.php


--

Shane Ambler
pgSQL@007Marketing.com

Get Sheeky @ http://Sheeky.Biz

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-19-2008, 09:44 AM
Joshua D. Drake
 
Posts: n/a
Default Re: Keeping processes open for re-use

On Fri, 2006-11-10 at 12:39 +1030, Shane Ambler wrote:
> Csaba Nagy wrote:
> > On Thu, 2006-11-09 at 13:35, Hilary Forbes wrote:
> >> [snip] Is there a way that we can achieve this in Postgres? We have a
> >> situation whereby we have lots of web based users doing short quick
> >> queries and obviously the start up time for a process must add to
> >> their perceived response time.

> >
> > Yes: google for "connection pooling". Note that different solutions
> > exist for different programming languages, so you should look for
> > connection pooling for the language you're using.
> >

>
> If you are using PHP then persistent connections may be a simpler way if
> it is enough for your needs.


I would actually suggest pg_pool over pg_pconnect.

Joshua D. Drake


>
> Basically replace pg_connect with pg_pconnect
>
> Other languages may have a similar option.
>
> http://php.net/manual/en/features.pe...onnections.php
>
>

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate




---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-19-2008, 09:45 AM
Jean-Max Reymond
 
Posts: n/a
Default Re: Keeping processes open for re-use

2006/11/10, Joshua D. Drake <jd@commandprompt.com>:
>
> I would actually suggest pg_pool over pg_pconnect.
>


Please, can you explain advantages of pg_pool over pg_connect ?

--
Jean-Max Reymond
CKR Solutions Open Source
Nice France
http://www.ckr-solutions.com

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-19-2008, 09:45 AM
Richard Huxton
 
Posts: n/a
Default Re: Keeping processes open for re-use

Jean-Max Reymond wrote:
> 2006/11/10, Joshua D. Drake <jd@commandprompt.com>:
>>
>> I would actually suggest pg_pool over pg_pconnect.
>>

>
> Please, can you explain advantages of pg_pool over pg_connect ?


He said pg_pconnect (note the extra "p"). This provides permanent
connections to the database from PHP. However, you will end up with one
connection per Apache process running (without running multiple Apache
setups to serve different content types). Since many processes will be
serving images or static content you have a lot of wasted, idle,
connections.

Now, pg_pool allows you to maintain a small number of active connections
(say 20 or 50) and have PHP connect to your pgpool server. It allocates
the next free connection it holds and so lets you minimise the number of
connections to PostgreSQL.

HTH
--
Richard Huxton
Archonet Ltd

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:29 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com