Skip to content

Instantly share code, notes, and snippets.

@zmts
Last active February 27, 2023 15:50
Show Gist options
  • Save zmts/a83ba792ecf09e0fe70bc26f33a0eafd to your computer and use it in GitHub Desktop.
Save zmts/a83ba792ecf09e0fe70bc26f33a0eafd to your computer and use it in GitHub Desktop.
Lack of of file descriptors; Too many open files; Mac OS;

Lack of of file descriptors; Too many open files; Mac OS;

Mac OS X Catalina

Issue:

ab -c 300 -n 1000 https://super.com/api

This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking super.com (be patient)
socket: Too many open files (24)

Solution:

> ulimit -a
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       2784
-n: file descriptors                256

Increase file descriptors (it will applied not permanently, it will dropped out on reboot):

> ulimit -n 2048
-t: cpu time (seconds)              unlimited
-f: file size (blocks)              unlimited
-d: data seg size (kbytes)          unlimited
-s: stack size (kbytes)             8192
-c: core file size (blocks)         0
-v: address space (kbytes)          unlimited
-l: locked-in-memory size (kbytes)  unlimited
-u: processes                       2784
-n: file descriptors                2048

https://en.wikipedia.org/wiki/File_descriptor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment