Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 24 Nov 2004 13:16:58 -0600
From:      Eric Anderson <anderson@centtech.com>
To:        akhthar@carmatec.com
Cc:        freebsd-performance@freebsd.org
Subject:   Re: Mbuf errors
Message-ID:  <41A4DE2A.6090200@centtech.com>
In-Reply-To: <200411250002.37764.akhthar@carmatec.com>
References:  <200411250002.37764.akhthar@carmatec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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
------------------------------------------------------------------------



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41A4DE2A.6090200>