From owner-freebsd-stable@FreeBSD.ORG Sat Sep 27 21:41:13 2008 Return-Path: Delivered-To: freebsd-stable@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E20CE106568B for ; Sat, 27 Sep 2008 21:41:13 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 5E4438FC13 for ; Sat, 27 Sep 2008 21:41:13 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id m8RLfBp5085972; Sat, 27 Sep 2008 23:41:11 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id m8RLfALZ085971; Sat, 27 Sep 2008 23:41:10 +0200 (CEST) (envelope-from olli) Date: Sat, 27 Sep 2008 23:41:10 +0200 (CEST) Message-Id: <200809272141.m8RLfALZ085971@lurza.secnetix.de> From: Oliver Fromme To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz In-Reply-To: <48DE9411.8010002@quip.cz> X-Newsgroups: list.freebsd-stable User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Sat, 27 Sep 2008 23:41:11 +0200 (CEST) Cc: Subject: Re: sysctl maxfiles X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Sep 2008 21:41:14 -0000 Miroslav Lachman wrote: > I don't know what files are "really" open in the meaning of > kern.maxfiles. I have webserver with about 100 hosted domains and there > is some numbers: > > root@roxy ~/# fstat -u www | wc -l > 9931 > root@roxy ~/# fstat -u root | wc -l > 718 > root@roxy ~/# fstat | grep httpd | wc -l > 6379 > root@roxy ~/# fstat | grep httpd | wc -l > 6002 > root@roxy ~/# fstat -u www | wc -l > 4691 > root@roxy ~/# sysctl kern.openfiles > kern.openfiles: 846 > > All above taken within few seconds. > > Can somebody explain the difference between kern.openfiles and fstat? Those are different things: fstat lists file descriptors, while kern.openfiles counts open file objects, which are often shared among processes. For example, when the apache master process forks its children, the children inherit the open file objects from the parent process. While every child has its own set of file descriptors (listed separately by fstat), they reference the same underlying open file objects, so they don't contribute separately to kern.openfiles. In the same way, fstat lists stdin + stdout + stderr for almost every process, but in most cases they are not separate file objects because they were inherited from the parent process. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M. Handelsregister: Registergericht Muenchen, HRA 74606, Geschäftsfuehrung: secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün- chen, HRB 125758, Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart FreeBSD-Dienstleistungen, -Produkte und mehr: http://www.secnetix.de/bsd "In My Egoistical Opinion, most people's C programs should be indented six feet downward and covered with dirt." -- Blair P. Houghton