BSD上Apache性能的调整(2)

**maxusers对其他kernel参数产生影响:
**

  • 进程的最大数目

  • 每个用户进程的最大数目

  • 系统打开文件数目限制

  • 每个用户打开文件数目限制

  • mbuf clusters最大数目

  • Proc/pgrp hash表大小

这些引申参数的定义公式在/usr/src/sys/conf/param.c中。这些计算出来的参数部分会被kernel配置文建里自己定义的值覆盖:

Network options. NMBCLUSTERS defines the number of mbuf clusters and

defaults to 256. This machine is a server that handles lots of traffic,

so we crank that value.

options NMBCLUSTERS=4096 # mbuf clusters at 4096

Misc. options

options CHILD_MAX=512 # maximum number of child processes
options OPEN_MAX=512 # maximum fds (breaks RPC svcs )

在许多情况下,NMBCLUSTERS应该设置的比第一眼看上去需要设置的值大的多。这是因为如果浏览器在传输中中断了连接,与特定连接相关的socket fd要在TIME_WAIT状态等几分钟才释放,在等待时mbuf并没有释放。另外,在服务器的timeouts中,一些连接会停留在FIN_WAIT_2状态,这个状态不会超时,浏览器又不会发出最终的FIN信号。

关于mbuf clusters更多的信息(From sys/mubf.h)

/*

  • Mbufs are of a single size, MSIZE (machine/machparam.h), which
  • includes overhead. An mbuf may add a single "mbuf cluster" of size
  • MCLBYTES (also in machine/machparam.h), which has no additional overhead
  • and is used instead of the internal data area; this is done when
  • at least MINCLSIZE of data must be stored.
    */
Published At
Categories with 服务器类
Tagged with
comments powered by Disqus