unlimit -n

Hello,
I am runnig Mac OS X Yosemite 10.10.1 and I red that it is recommended to increase the number of files you can open (with ‘unlimit -n’).
I am fairly new to this kind of issue, and wonder what this means (increase the number of files you can open)
And how exactly do I ‘unlimit -n’ ?
I have ran the other sudo commands recommended, but do I run ‘unlimit -n’ ? Just type it in the terminal?

Cheers,

Magnus

OS Tuning

Depending on your OS, you might have to tweak a few options so that you can massively open new sockets and reach heavy load.

For example, on X platforms, you imperatively have to increase the number of files you can open with ulimit -n.

Under Mac OS/X Lion you need to run the following commands in order to “unbuckle the belts”:

sudo sysctl -w kern.maxfilesperproc=200000
sudo sysctl -w kern.maxfiles=200000 

sudo sysctl -w net.inet.ip.portrange.first=1024

ulimit, not unlimit

sorry, but how do I do ‘increase the number of open files’ I can open?
Do you have a command I can run to increase it?

Cheers

Running ulimit -a gives me this:

`


xxx$ ulimit -a

core file size          (blocks, -c) 0

data seg size           (kbytes, -d) unlimited

file size               (blocks, -f) unlimited

max locked memory       (kbytes, -l) unlimited

max memory size         (kbytes, -m) unlimited

open files                      (-n) 2560

pipe size            (512 bytes, -p) 1

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 709

virtual memory          (kbytes, -v) unlimited

`

Hi Magnus,

My understanding is that on a Unix based system a file is opened
before a TCP/IP connection is made (everything is file). The number of
concurrent open files has a default limit which can be increased.

On a Linux server, I use this line to increase the file open limit:
https://github.com/BBC/gatling-load-tests/blob/master/support/scripts/set-up.sh#L15

There are different commands in a different file for OS X.
http://stackoverflow.com/questions/34588/how-do-i-change-the-number-of-open-files-limit-in-linux

"""
On OS X, this same data must be set in /etc/sysctl.conf.

kern.maxfilesperproc=166384
kern.maxfiles=8192
"""
There number of open files set for the OS can be retrieved using:

$ ulimit -n
2048

(You may need to reboot for the open file limit to take effect).

Many Thanks

Aidy