Skip site navigation (1) Skip section navigation (2)

Re: refusing connections based on load ...

From: Neal Norwitz <neal(at)metaslash(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: The Hermit Hacker <scrappy(at)hub(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: refusing connections based on load ...
Date: 2001-04-24 03:12:20
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Tom Lane wrote:

> A less dangerous way of approaching it might be to have an option
> whereby the postmaster invokes 'uptime' via system() every so often
> (maybe once a minute?) and throttles on the basis of the results.
> The reaction time would be poorer, but security would be a whole lot
> better.

Rather than do system('uptime') and incur the process start-up each time,
you could do fp = popen('vmstat 60', 'r'), then just read the fp.

I believe vmstat is fairly standard.  For those systems 
which don't support vmstat, it could be faked with a shell script.

You could write the specific code to handle each arch, but it's
a royal pain, because it's so different for many archs.

Another possibility could be to read from /proc for those systems
that support /proc.  But I think this will be more variable than
the output from vmstat.  Vmstat also has the added benefit of
providing other information.

I agree with Tom about not wanting to open up /dev/kmem, 
due to potential security problems.


In response to


pgsql-hackers by date

Next:From: Tom LaneDate: 2001-04-24 03:21:25
Subject: Re: refusing connections based on load ...
Previous:From: Larry RosenmanDate: 2001-04-24 03:07:12
Subject: Re: refusing connections based on load ...

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group