Version: All
Overview
Many UNIX/Linux software requesting to set process' limit using ulimit command. This includes Oracle RDBMS, Apache httpd, Apache Tomcat, any file server, Cognos Analytics, call center servers, media server, Java base server, etc.
No vendor in any major application explain the objective of setting ulimit, and eventually the daemon/process hang or crash due to hitting such OS limit per user.
For reader who has no idea what is ulimit, the short description is that this is to configure user level's OS limit for any process run and own by the user. This includes number of active open network connection, number of active open files, max file limit, max process RAM, etc. This is not available in Windows, so anyone who never proper learn UNIX, they will miss this, or even miss this configuration.
Often, may IT personnel don't follow vendor's documentation to install the software. Some vendor's document might even provided low value instead of a formula to properly tune the ulimit. You need to understand that many developers do not understand OS, including UNIX OS, so it is challenging for a someone who don't understand OS to provide OS tuning parameter and value.
Eventually, this leads to many daemons hanging and even crash. As an OS administrator, or software support personnel, it will be helpful to resolve the hanging, or even prevent it reach that critical state when the daemon start to behaving poorly, if you are able to catch it before it crash.
This post introduce a Linux commands which you can change the ulimit at in real time without restarting the daemon, or OS. This command required to be run as root:
- RedHat RHEL - prlimit
- Documentation: https://man7.org/linux/man-pages/man1/prlimit.1.html
- Documentation: https://linux.die.net/man/2/prlimit
- Ubuntu - chpst
- Documentation: https://manpages.ubuntu.com/manpages/lunar/man8/chpst.8.html
For the rest of the post, I will just refer to RHEL command of prlimit, as most company will use RHEL to run their software.
Usage
Command prlimit can be used to change the ulimit for a specific process in real time without shutting it down, or reboot OS.
You need to always specify the process ID, or called PID in "ps" command's output. So the syntax will always to include "-p <PID" such as "prlimit -p <PID of Oracle>"
Following ulimit configuration can be configure in real time:
- RAM related
- max data size (RAM) - parameter -d
- max resident set size RSS (RAM) - parameter -m
- max stack size (RAM > stack) - parameter -s
- Storage related
- max file size (storage) - parameter -f
- max number of open files - parameter -n
- max number of file locks - parameter -x
- Messaging related
- max number of bytes in POSIX message queue - parameter -q
- Process
- max number of processes - parameter -u
Each OS resource usage has a different command to check their current utilization, so you can search in Internet to identify how much is the usage before tune up these values. I might write a new blog post if this page is getting sufficient hit, such as more than 50,000 hit.
By adjusting the ulimit of the active process in real time, you can avoid unplan downtime during business hour, and schedule a proper maintenance window to tune the OS.
1 comment:
I was struggling with system resource limits while playing around with game data, and adjusting unlimit settings really helped. Especially for something detailed like a Dark Souls Map , keeping your system optimized makes a noticeable difference.
Post a Comment