linux epoll 大并发

file-max

内核最大打开文件handle数。

The value in file-max denotes the maximum number of file handles that the Linux kernel will allocate. When you get lots of error messages about running out of file handles, you might want to increase this limit.

查看方式

cat /proc/sys/fs/file-max

设置方式

echo "num" > /proc/sys/fs/file-max

持续配置

/etc/sysctl.conf

fs.file-max="num"

最大值

可以使用  grep MemTotal /proc/meminfo | awk '{printf("%d",$2/10)}' 获取推荐值。

内核每个打开得文件描述符会占用1k得空间。如果默认值大于系统10%的内存,会自动降低。比如 机器 24G内存,最大合理值为25,165,824 / 10 = 25,165,82。

the kernel comments suggest approximately one kilobyte per file for the kernel’s data, and will reduce the default value of file-max (8192) if that ends up representing more than 10% of memory when the system boots 

勘误

inode-max: linux内核已经不再限制了。

/proc/sys/fs/inode-max (only present until Linux 2.2)

This file contains the maximum number of in-memory inodes. This value should be 3-4 times larger than the value in file-max, since stdin, stdout and network sockets also need an inode to handle them. When you regularly run out of inodes, you need to increase this value.

Starting with Linux 2.4, there is no longer a static limit on the number of inodes, and this file is removed.

实时监测

cat /proc/sys/fs/file-nr

只读状态监测,三列: 当前分配文件handles个数,未使用handles,最大handles。最大handles为file-max.

 

nr_open

单个进程最大打开文件handle数。

This denotes the maximum number of file-handles a process can allocate. Default  value is 1024*1024 (1048576) which should be enough for most machines. Actual limit depends on RLIMIT_NOFILE resource limit.

查看方式

 cat /proc/sys/fs/nr_open

设置方式

echo "num" > cat /proc/sys/fs/nr_open

持续配置

/etc/sysctl.conf

fs.nr_open="num"

最大值

the maximum value of fs.nr_open is limited to sysctl_nr_open_max in kernel, which is 2147483584 on x86_64.

int sysctl_nr_open_max = __const_min(INT_MAX, ~(size_t)0/sizeof(void *)) &
                         -BITS_PER_LONG;

 

该值为/etc/security/limits.conf 中nofile的最大值。

max_user_watches

epooll 最大监听

/proc/sys/fs/epoll/max_user_watches (since Linux 2.6.28)
              This specifies a limit on the total number of file descriptors
              that a user can register across all epoll instances on the
              system.  The limit is per real user ID.  Each registered file
              descriptor costs roughly 90 bytes on a 32-bit kernel, and
              roughly 160 bytes on a 64-bit kernel.  Currently, the default
              value for max_user_watches is 1/25 (4%) of the available low
              memory, divided by the registration cost in bytes.

 

查看方式

cat /proc/sys/fs/epoll/max_user_watches

设置方式

echo "50395750" > /proc/sys/fs/epoll/max_user_watches

持续配置

/etc/sysctl.conf

fs.epoll.max_user_watches=50395750

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值