From owner-freebsd-performance@FreeBSD.ORG Wed Nov 24 19:17:07 2004 Return-Path: Delivered-To: freebsd-performance@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 23E7616A4CE; Wed, 24 Nov 2004 19:17:07 +0000 (GMT) Received: from otter3.centtech.com (moat3.centtech.com [207.200.51.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7D64643D4C; Wed, 24 Nov 2004 19:17:06 +0000 (GMT) (envelope-from anderson@centtech.com) Received: from [10.177.171.220] (neutrino.centtech.com [10.177.171.220]) by otter3.centtech.com (8.12.3/8.12.3) with ESMTP id iAOJH3OJ066087; Wed, 24 Nov 2004 13:17:04 -0600 (CST) (envelope-from anderson@centtech.com) Message-ID: <41A4DE2A.6090200@centtech.com> Date: Wed, 24 Nov 2004 13:16:58 -0600 From: Eric Anderson User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.3) Gecko/20041110 X-Accept-Language: en-us, en MIME-Version: 1.0 To: akhthar@carmatec.com References: <200411250002.37764.akhthar@carmatec.com> In-Reply-To: <200411250002.37764.akhthar@carmatec.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-performance@freebsd.org Subject: Re: Mbuf errors X-BeenThere: freebsd-performance@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Performance/tuning List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Nov 2004 19:17:07 -0000 Akhthar Parvez. K wrote: > Hi All, > > Mysql service is going down continously in my system due to lack of memory > space. > > I checked the messages log and found the following error message. > > All mbuf clusters exhausted, please see tuning(7). > > I have no idea about mbuf cluster. Can anyone please help me to fix the issue. > > I hope the information below will help you. [..snip..] > Following is the output of netstat -m > > 3797/14672/26624 mbufs in use (current/peak/max): > 3791 mbufs allocated to data > 2 mbufs allocated to fragment reassembly queue headers > 4 mbufs allocated to socket names and addresses > 3704/6656/6656 mbuf clusters in use (current/peak/max) > 16980 Kbytes allocated to network (85% of mb_map in use) > 106522 requests for memory denied > 1545 requests for memory delayed > 0 calls to protocol drain routines > > Please let me know if you need more info regarding this. > Thank you in advance. This isn't really security related, more performance related, so I'm moving it to that list (freebsd-performance@). The answer to your question is right in your email! In the tuning man page, it says: kern.ipc.nmbclusters may be adjusted to increase the number of network mbufs the system is willing to allocate. Each cluster represents approx- imately 2K of memory, so a value of 1024 represents 2M of kernel memory reserved for network buffers. You can do a simple calculation to figure out how many you need. If you have a web server which maxes out at 1000 simultaneous connections, and each connection eats a 16K receive and 16K send buffer, you need approximately 32MB worth of network buffers to deal with it. A good rule of thumb is to multiply by 2, so 32MBx2 = 64MB/2K = 32768. So for this case you would want to set kern.ipc.nmbclusters to 32768. We recommend values between 1024 and 4096 for machines with mod- erates amount of memory, and between 4096 and 32768 for machines with greater amounts of memory. Under no circumstances should you specify an arbitrarily high value for this parameter, it could lead to a boot-time crash. The -m option to netstat(1) may be used to observe network clus- ter use. Older versions of FreeBSD do not have this tunable and require that the kernel config(8) option NMBCLUSTERS be set instead. More and more programs are using the sendfile(2) system call to transmit files over the network. The kern.ipc.nsfbufs sysctl controls the number of file system buffers sendfile(2) is allowed to use to perform its work. This parameter nominally scales with kern.maxusers so you should not need to modify this parameter except under extreme circumstances. See the TUNING section in the sendfile(2) manual page for details. So basically you need to use sysctl to adjust (increase) the kern.ipc.nmbclusters number. Eric -- ------------------------------------------------------------------------ Eric Anderson Sr. Systems Administrator Centaur Technology When in doubt, mumble; when in trouble, delegate; when in charge, ponder ------------------------------------------------------------------------