Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Unix知識 >> 關於Unix

FreeBSD 之 All mbuf clusters exhausted 問題解析

日誌中出現 /kernel: All mbuf clusters exhausted, please see tuning(7).,並伴隨 No buffer space available,可用 netstat -m 觀察:

37/3840/10048 mbufs in use (current/peak/max)
32/2512/2512 mbuf clusters in use (current/peak/max)
5984 Kbytes allocated to network (79% of mb_map in use)
17044 requests for memory denied
828 requests for memory delayed

原因在於預設的 kern.ipc.nmbclusters 太小,某些請求配置不到記憶體而延誤。每個 cluster 約 2K,值 1024 代表保留 2M 內核記憶體作網路緩衝。

如何估算

例如一台 web 伺服器最多 1000 個並發連接、每個吃 16K 收發緩衝,約需 32MB 網路緩衝;粗略乘以 2 得 64MB,再除以 2K 得 32768,即需把 nmbclusters 設為 32768。記憶體少的機器建議 1024–4096,記憶體充裕者 4096–32768。切勿設太隨意的值,以免開機崩潰。可用 netstat -m 查看緩衝使用情況;舊版 FreeBSD 無此 sysctl,需設內核選項 NMBCLUSTERS。

LINT 相關說明

options NMBCLUSTERS=1024
# 每個 mbuf 消耗 256 bytes,未指定時系統會自動調整(約為 NMBCLUSTERS 的 4 倍)

傳說調整 NBUF 也有效。總之,適度調大網路緩衝即可解決此問題。

Copyright © Linux教程網 All Rights Reserved