Re: [HACKERS] postgres processes

From: wieck(at)debis(dot)com (Jan Wieck)
To: rems(at)gdansk(dot)sprint(dot)pl (Remigiusz Sokolowski)
Cc: pgsql-general(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] postgres processes
Date: 1999-06-11 10:44:05
Message-ID: m10sOn7-0003kGC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Remigiusz Sokolowski wrote:

>
> Hi!
> I have following problem:
>
> I use php with postgres as backend. Every time, I run some queries,
> postgres creates a lot of processes - this causes extremely high processor
> usage.
> I execute some queries in quasi-parallel way, cause I need its results.
> But other are executing and every time I free result - all of those
> queries are executing on the same connection. So is it normal, that I get
> so much processes? And if there is some way to limit it? Or may be change
> process live time?

That's a general problem when using PostgreSQL in the
background for Apache CGI or php scripts.

The defaults in the Apache configuration are

StartServers 5
MaxClients 256
MinSpareServers 5
MaxSpareServers 10

This means, that at startup Apache will create 5 server
processes that can handle requests simultaneously. When the
site gets busy and some of them take longer to handle
requests (especially scripting requests), it will start new
servers (max one per second) until the limit of 256 parallel
server processes is reached. If they finish their requests
and become idle again, some of them get killed if there are
more than 10 idle Apache processes.

This is normally a good policy. It ensures that small file
requests can still get served while some long running CGI's
block their server process.

In the case of having PostgreSQL in the background, any such
CGI request causes another backend to get started too. So
when there's a peak of such requests, PostgreSQL will have to
serve more parallel queries, Apache will start more servers
to handle the incoming requests, causing more PostgreSQL
connections and more parallel queries...

What you can try is to take down the MaxClients directive in
the Apache configuration. But that would mean, that a plain
html file request, that could be served in milliseconds, will
have to wait if all servers are blocked waiting for CGI's.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Remigiusz Sokolowski 1999-06-11 11:45:57 Re: [HACKERS] postgres processes
Previous Message Hub.Org News Admin 1999-06-11 10:43:40

Browse pgsql-hackers by date

  From Date Subject
Next Message Remigiusz Sokolowski 1999-06-11 11:45:57 Re: [HACKERS] postgres processes
Previous Message Daniel Kalchev 1999-06-11 10:38:57 Re: [HACKERS] another locale problem