From owner-freebsd-stable@FreeBSD.ORG Wed May 19 12:22:40 2004 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3D50216A4CE for ; Wed, 19 May 2004 12:22:40 -0700 (PDT) Received: from cashmere.blitzed.org (cashmere.blitzed.org [82.195.232.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id E363C43D49 for ; Wed, 19 May 2004 12:22:39 -0700 (PDT) (envelope-from andy@freebsdwiki.org) Received: by cashmere.blitzed.org (Postfix, from userid 10000) id 1AD6C111C67; Wed, 19 May 2004 19:22:30 +0000 (GMT) Date: Wed, 19 May 2004 19:22:30 +0000 From: Andy Smith To: FreeBSD STABLE Message-ID: <20040519192229.GN457@cashmere.blitzed.org> Mail-Followup-To: FreeBSD STABLE References: <20040519023025.GM457@cashmere.blitzed.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="orrA+Dc/uYZgnQka" Content-Disposition: inline In-Reply-To: <20040519023025.GM457@cashmere.blitzed.org> X-Uptime: 9 days X-URL: http://freebsdwiki.org/User:Andy User-Agent: Mutt/1.5.6i Subject: Re: Which resource am I running out of here? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 May 2004 19:22:40 -0000 --orrA+Dc/uYZgnQka Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 19, 2004 at 02:30:26AM +0000, Andy Smith wrote: > I have an application which needs to open a lost of TCP connections > at once. Up until now I have been telling this application to limit > itself to 1024 file descriptors at once, but today I thought I would > let it rip and increase it to 4096. >=20 > When I did this, I started noticing errors in other applications on > the same machine, such as postfix: >=20 > 9905D27F28 4026 Tue May 18 23:53:55 mark@example.org > (connect to mail.example.com[67.15.16.50]: Can't assign requested ad= dress) > kari@example.com >=20 > Also emulating a HTTP connection: >=20 > $ telnet babylon.otherwize.co.uk 80 > Trying 212.13.198.54... > telnet: connect to address 212.13.198.54: Can't assign requested address I had some suggestions off-list. One said it might be mbufs, but netstat doesn't really confirm: $ netstat -m 139/688/26624 mbufs in use (current/peak/max): 135 mbufs allocated to data 2 mbufs allocated to ancillary data 2 mbufs allocated to socket names and addresses 86/370/6656 mbuf clusters in use (current/peak/max) 912 Kbytes allocated to network (4% of mb_map in use) 0 requests for memory denied 0 requests for memory delayed 0 calls to protocol drain routines Another suggested I was running out of ephemeral ports: $ sysctl -a | grep portrange net.inet.ip.portrange.lowfirst: 1023 net.inet.ip.portrange.lowlast: 600 net.inet.ip.portrange.first: 1024 net.inet.ip.portrange.last: 5000 net.inet.ip.portrange.hifirst: 49152 net.inet.ip.portrange.hilast: 65535 If my application is using first -> last then I can this would be quite likely: I'm opening over 4000 TCP connections at once. But I thought it used hifirst -> hilast. I also increased kern.ipc.somaxconn from 128 to 1024 but this did not appear to help. Are there any other resource limits which people think I should be changing? The connections are very short-lived, perhaps no more than 30 seconds each, and hardly any data goes over them. Okay, while writing this email I used lsof to see what TCP conections my app had. They do all seem to have source ports within the first -> last range. $ sudo sysctl net.inet.ip.portrange.last=3D20000 net.inet.ip.portrange.last: 5000 -> 20000 seem to have removed my problem. Thanks! --=20 http://freebsdwiki.org/ - Encrypted mail welcome - keyid 0xBF15490B --orrA+Dc/uYZgnQka Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAq7P1IJm2TL8VSQsRAvynAJ4wkKs9pn1zjmi79NRfNyYZF0khHwCfZdRr bp/sySvBjt+KA5kua2M10C4= =lYdT -----END PGP SIGNATURE----- --orrA+Dc/uYZgnQka--