ulimit Calculator
Calculate recommended ulimit values for file descriptors, processes and memory.
About ulimit Calculator
Every socket, log file and temp file a server opens consumes one file descriptor, so a high-concurrency service can exhaust the default 1024 ulimit -n very quickly. The raw requirement multiplies expected concurrent connections by the average files/sockets each one opens, and a safety factor is applied on top to absorb bursts, slow-closing connections and auxiliary file handles that are easy to undercount.
Formula
Recommended ulimit
recommended = connections × files_per_connection × safety_factor
- c
- concurrent connections
- f
- average files/sockets per connection
- k
- safety factor
Worked example
With the default values below, ulimit Calculator returns Recommended ulimit -n of 22,500. Change any input above and every figure here is recalculated in your browser.
Inputs used
- Concurrent Connectionsminimum 0
- 5,000
- Average Files/Sockets per Connectionminimum 0
- 3
- Safety Factorminimum 1
- 1.5
Results
- Raw Requirement
- 15,000
- Recommended ulimit -n
- 22,500
- Rounded Recommendation
- 23,000
- limits.conf Entry
- * soft nofile 23000 * hard nofile 23000
Step by step
- 1Values used
- 2Recommended ulimit
- 3Recommended ulimit -n= 22,500
- 4Rounded Recommendation= 23,000
- 5Raw Requirement= 15,000
- 6limits.conf Entry= * soft nofile 23000 * hard nofile 23000
Assumptions and limits
- The result is derived only from the 3 inputs listed above. Anything not among them is not part of the calculation.
- In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
- Figures are rounded for display to whole numbers, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.
How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.
Frequently Asked Questions
What is the default ulimit -n on most Linux distributions?
Most distributions default the soft limit to 1024 file descriptors per process, which is far too low for high-concurrency servers like web servers, databases or message brokers handling thousands of simultaneous connections.
What safety factor should I use?
A factor of 1.5-2x over the raw calculated need is common, providing headroom for connection spikes, slow-closing sockets (TIME_WAIT), and file handles opened for logging or temporary files that are easy to forget when estimating.
Where do I actually set the ulimit for a systemd service?
Add LimitNOFILE=<value> under the [Service] section of the unit file (or a drop-in), then run `systemctl daemon-reload` and restart the service — this is more reliable than /etc/security/limits.conf for services not started through a login shell.
