Skip to content
This repository was archived by the owner on Oct 17, 2022. It is now read-only.

Commit 9571d82

Browse files
authored
Further improve fd limit increase docs (#567)
1 parent 86e7e7f commit 9571d82

File tree

1 file changed

+38
-39
lines changed

1 file changed

+38
-39
lines changed

src/maintenance/performance.rst

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -90,51 +90,66 @@ Erlang
9090
------
9191

9292
Even if you've increased the maximum connections CouchDB will allow,
93-
the Erlang runtime system will not allow more than 1024 connections by
94-
default. Adding the following directive to ``(prefix)/etc/default/couchdb`` (or
95-
equivalent) will increase this limit (in this case to 4096)::
93+
the Erlang runtime system will not allow more than 65536 connections by
94+
default. Adding the following directive to ``(prefix)/etc/vm.args`` (or
95+
equivalent) will increase this limit (in this case to 102400)::
9696

97-
export ERL_MAX_PORTS=4096
97+
+Q 102400
9898

99-
CouchDB versions up to 1.1.x also create Erlang Term Storage (`ETS`_) tables for
100-
each replication. If you are using a version of CouchDB older than 1.2 and
101-
must support many replications, also set the ``ERL_MAX_ETS_TABLES`` variable.
102-
The default is approximately 1400 tables.
99+
Note that on Windows, Erlang will not actually increase the file descriptor
100+
limit past 8192 (i.e. the system header–defined value of ``FD_SETSIZE``). On
101+
macOS, the limit may be as low as 1024. See `this tip for a possible
102+
workaround`_ and `this thread for a deeper explanation`_.
103103

104-
Note that on Mac OS X, Erlang will not actually increase the file descriptor
105-
limit past 1024 (i.e. the system header–defined value of ``FD_SETSIZE``). See
106-
`this tip for a possible workaround`_ and `this thread for a deeper
107-
explanation`_.
108-
109-
.. _ETS: http://www.erlang.org/doc/man/ets.html
110104
.. _this tip for a possible workaround: http://erlang.org/pipermail/erlang-questions/2011-December/063119.html
111105
.. _this thread for a deeper explanation: http://erlang.org/pipermail/erlang-questions/2011-October/061971.html
112106

113107
Maximum open file descriptors (ulimit)
114108
--------------------------------------
115109

116-
Most \*nix operating systems impose various resource limits on every process.
110+
In general, modern UNIX-like systems can handle very large numbers of file
111+
handles per process (e.g. 100000) without problem. Don't be afraid to increase
112+
this limit on your system.
113+
117114
The method of increasing these limits varies, depending on your init system and
118115
particular OS release. The default value for many OSes is 1024 or 4096. On a
119116
system with many databases or many views, CouchDB can very rapidly hit this
120117
limit.
121118

122-
If your system is set up to use the Pluggable Authentication Modules (`PAM`_)
123-
system (as is the case with nearly all modern Linuxes), increasing this limit
119+
For systemd-based Linuxes (such as CentOS/RHEL 7, Ubuntu 16.04+, Debian 8
120+
or newer), assuming you are launching CouchDB from systemd, you must
121+
override the upper limit via editing the override file. The best practice
122+
for this is via the ``systemctl edit couchdb`` command. Add these lines to
123+
the file in the editor::
124+
125+
[Service]
126+
LimitNOFILE=65536
127+
128+
...or whatever value you like. To increase this value higher than 65536, you
129+
must also add the Erlang ``+Q`` parameter to your ``etc/vm.args`` file by
130+
adding the line::
131+
132+
+Q 102400
133+
134+
The old ``ERL_MAX_PORTS`` environment variable is ignored by the version of
135+
Erlang supplied with CouchDB.
136+
137+
If your system is set up to use the Pluggable Authentication Modules (`PAM`_),
138+
and you are **not** launching CouchDB from systemd, increasing this limit
124139
is straightforward. For example, creating a file named
125140
``/etc/security/limits.d/100-couchdb.conf`` with the following contents will
126-
ensure that CouchDB can open up to 10000 file descriptors at once::
141+
ensure that CouchDB can open up to 65536 file descriptors at once::
127142

128143
#<domain> <type> <item> <value>
129-
couchdb hard nofile 10000
130-
couchdb soft nofile 10000
144+
couchdb hard nofile 65536
145+
couchdb soft nofile 65536
131146

132147
If you are using our Debian/Ubuntu sysvinit script (``/etc/init.d/couchdb``),
133148
you also need to raise the limits for the root user::
134149

135150
#<domain> <type> <item> <value>
136-
root hard nofile 10000
137-
root soft nofile 10000
151+
root hard nofile 65536
152+
root soft nofile 65536
138153

139154
You may also have to edit the ``/etc/pam.d/common-session`` and
140155
``/etc/pam.d/common-session-noninteractive`` files to add the line::
@@ -143,25 +158,9 @@ You may also have to edit the ``/etc/pam.d/common-session`` and
143158

144159
if it is not already present.
145160

146-
For systemd-based Linuxes (such as CentOS/RHEL 7, Ubuntu 16.04+, Debian 8
147-
or newer), assuming you are launching CouchDB from systemd, you must also
148-
override the upper limit by creating the file
149-
``/etc/systemd/system/<servicename>.d/override.conf`` with the following
150-
content::
151-
152-
[Service]
153-
LimitNOFILE=#######
154-
155-
and replacing the ``#######`` with the upper limit of file descriptors CouchDB
156-
is allowed to hold open at once.
157-
158161
If your system does not use PAM, a `ulimit` command is usually available for
159162
use in a custom script to launch CouchDB with increased resource limits.
160-
Typical syntax would be something like `ulimit -n 10000`.
161-
162-
In general, modern UNIX-like systems can handle very large numbers of file
163-
handles per process (e.g. 100000) without problem. Don't be afraid to increase
164-
this limit on your system.
163+
Typical syntax would be something like `ulimit -n 65536`.
165164

166165
.. _PAM: http://www.linux-pam.org/
167166

0 commit comments

Comments
 (0)