Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Aug 2006 17:25:13 -0400
From:      Bill Moran <wmoran@collaborativefusion.com>
To:        questions@freebsd.org
Subject:   Re: Reducing the timeout on a TCP connection
Message-ID:  <20060801172513.4fc802ab.wmoran@collaborativefusion.com>
In-Reply-To: <20060801150300.G11829@bravo.pjkh.com>
References:  <20060801150226.0c911297.wmoran@collaborativefusion.com> <20060801150300.G11829@bravo.pjkh.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In response to Philip Hallstrom <freebsd@philip.pjkh.com>:

> > I'm writing some monitoring scripts, and I'm having some trouble because
> > the TCP seems to wait 90 seconds before giving up on initiating a
> > connection.
> >
> > (The script is in PHP, testing a PostgreSQL database.  Neither PHP nor
> > libpq (which PHP's PostgreSQL support is based on) seem to have any
> > settings that can be used to adjust this timeout).
> 
> http://www.php.net/fsockopen
> 
> Last parameter is a timeout value... I'd imagine the other socket calls 
> have something similar... whether or not it's honored I dunno, but it is 
> there.
> 
> Although maybe i'm misunderstanding the question.

Thanks, Philip.  Between your and Ted's advice, I've decided to do a three-
tiered test.  

1) I test to see if I can establish a socket with fsockopen, with a fairly
   short timeout.  This gives me a quick response in the event of a total
   failure that takes the server offline.
2) I then test using pg_connect() which has (apparently) a 90s timeout,
   but gives me more thorough testing in case PG is running, but
   misbehaving.
3) Finally I execute a simple but telling SQL query that will give me a
   cursory feel for whether the data in the datbase is healthy.

This gives me a lot of config values for various timeouts and the ability
to check for several scenarios (from total HW failure, to PostgreSQL going
bonkers) with configurable reaction times.  Further testing should help me
to understand what numbers make good timeouts for the various stages.

-- 
Bill Moran
Collaborative Fusion Inc.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060801172513.4fc802ab.wmoran>