Increasing MongoDB soft rlimits on Mac OS X

May 18, 2015, 6:30 pm
Author: James Griffiths

If you've installed MongoDB on Mac OS X (and this will more than likely be applicable to similar UNIX based systems such as Linux) you may be greeted with the following warning when running the mongo daemon process in your Terminal application:

** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000

Looks a little cryptic doesn't it? Let's take a look at what this means and how to fix it...

It's all about resources

With most UNIX based OS's system resources such as network connections, files and threads are limited and controlled on a per-process and per-user basis. Known as "ulimits" these controls and limitations prevent excessive consumption of system resources by a single user.

Generally, for development purposes, if these limits are low they won't cause any problems with the functioning and usage of MongoDB. The exception to this would be if you needed to work with a large number of files or connections.

That said it's a good idea to resolve those low limits as it helps ready your database for any potential increase in requirements (say for a new project with larger datasets).

Fixing that warning

Increasing those limits is easily done with the following command issued in your Terminal application (but be sure to exit the mongo shell first with CTRL + C):

ulimit -n 1024

What the above command does it to set the per user limitation for file descriptors on both hard and soft limits. Hard limits refer to the absolute maximum number of processes that a user can have active at any single time while soft limits refer to the limit that is enforced for a session or process.

If you'd like to learn more about working with ulimits you can view the following page concerning managing system resources for MongoDB.

Now, if you run the mongo daemon process you should no longer be confronted with that warning concerning soft rlimits being too low.


« Return to Posts

Post a comment

All comments are welcome and the rules are simple - be nice and do NOT engage in trolling, spamming, abusiveness or illegal behaviour. If you fail to observe these rules you will be permanently banned from being able to comment.