From owner-freebsd-questions@FreeBSD.ORG Tue Aug 1 21:25:13 2006 Return-Path: X-Original-To: questions@freebsd.org Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 70C6216A4DE for ; Tue, 1 Aug 2006 21:25:13 +0000 (UTC) (envelope-from wmoran@collaborativefusion.com) Received: from mx00.pub.collaborativefusion.com (mx00.pub.collaborativefusion.com [206.210.89.199]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CD0743D49 for ; Tue, 1 Aug 2006 21:25:12 +0000 (GMT) (envelope-from wmoran@collaborativefusion.com) Received: from collaborativefusion.com (mx01.pub.collaborativefusion.com [206.210.89.201]) (TLS: TLSv1/SSLv3,256bits,AES256-SHA) by wingspan with esmtp; Tue, 01 Aug 2006 17:25:12 -0400 id 00056405.44CFC6B8.00013C92 Received: from Internal Mail-Server (206.210.89.202) by mx01 (envelope-from wmoran@collaborativefusion.com) with AES256-SHA encrypted SMTP; 1 Aug 2006 17:21:39 -0400 Date: Tue, 1 Aug 2006 17:25:13 -0400 From: Bill Moran To: questions@freebsd.org 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> Organization: Collaborative Fusion X-Mailer: Sylpheed version 2.2.6 (GTK+ 2.8.20; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Subject: Re: Reducing the timeout on a TCP connection X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Aug 2006 21:25:13 -0000 In response to Philip Hallstrom : > > 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.