MongoDB可用的连接 [英] MongoDB available connections
问题描述
我在Windows,Mac和Linux上安装了MongoDB.
我使用所有默认参数运行MongoDB,并在mongo上输入命令db.serverStatus().connections
来检查可用连接.
I installed MongoDB on Windows, Mac and Linux.
I run MongoDB with all default arguments and I enter a command db.serverStatus().connections
on mongo to check the available connections.
这是我的观察,Windows 7具有19999,Mac仅具有203,Linux具有818.因此,我想问一下是什么使可用连接数有所不同,并且有可能增加可用连接吗?
Here is my observation, Windows 7 has 19999, Mac has only 203 and Linux has 818. Therefore, I would like to ask what makes the number of available connections different and is it possible to increase the available connections?
谢谢.
推荐答案
对于类似UNIX的系统(例如Linux和OS X),连接限制由
For UNIX-like systems (i.e. Linux and OS X), the connection limit is governed by ulimits. MongoDB will use 80% of the available file descriptors for connections, which is why you see 203 on Mac (~80% of 256) and 819 on Linux (~80% of 1024).
MongoDB文档包括用于生产系统的推荐设置.通常,您无需在开发环境上更改此设置,但是如果连接限制被认为较低,则会在启动时看到警告.
The MongoDB documentation includes recommended settings for production systems. Typically you wouldn't need to change this on development environments, but you will see a warning on startup if the connection limits are considered low.
在MongoDB 2.4和更早版本中,无论ulimit如何,每个服务器最多有20,000个连接的硬编码连接.从MongoDB 2.6起已删除了此最大值.
In MongoDB 2.4 and earlier, there is a hard-coded maximum of 20,000 connections per server irrespective of the ulimits. This maximum has been removed as at MongoDB 2.6.
还有一个 maxConns
MongoDB配置指令,可以用于将连接限制为比ulimits允许的连接更低.
这篇关于MongoDB可用的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!