Set Max Open Files in RHEL 7 for Apache with dispatcher plugin (AEM, CQ5)
Sometimes (often) as sysadmin you have to recalculate the resources available for your managed software, include Apache Web Server. By default, this kind of parameters are sufficient with low rates of transactions, but in seasoned applications this is not always true.
AEM dispatchers runs as Apache plugin, and sometimes you could get log messages such as:
[Sat Nov 17 12:08:06 2018] [E] [pid 346] Unable to open temporary file : No such file or directory
[Sat Nov 17 13:31:04 2018] [E] [pid 7357] Unable to open temporary file : No such file or directory
[Sat Nov 17 13:31:04 2018] [E] [pid 7346] Unable to open temporary file : No such file or directory
This happens when Apache tries to open nonexistent file due to it could not be created before. Remember, Apache starts some threads/process (depends on your mpm) and they have limits (related to operating system) which under heavy workload will unveil them.
22.2 Limiting Resource Usage
============================You can specify limits for the resource usage of a process. When the
process tries to exceed a limit, it may get a signal, or the system call
by which it tried to do so may fail, depending on the resource. Each
process initially inherits its limit values from its parent, but it can
subsequently change them.There are two per-process limits associated with a resource:"current limit"
The current limit is the value the system will not allow usage to
exceed. It is also called the "soft limit" because the process
being limited can generally raise the current limit at will."maximum limit"
The maximum limit is the maximum value to which a process is
allowed to set its current limit. It is also called the "hard
limit" because there is no way for a process to get around it. A
process may lower its own maximum limit, but only the superuser may
increase a maximum limit.
Getting current resources
Usually we are logged with the same operating system user which we want to setup. But, there are situations where the user has not terminal (/usr/bin/false), this is when /proc file system comes handy. In order to get his run-time values you have to inspect the process. Next picture shows how our Apache (a.k.a Dispatcher) are running and could be appreciate low Max Open Files.
Setting Max Open Files
In order to enhance the number of incoming requests we have to set unit files (only in systemd systems) as follow:
Then you have to reboot Apache process in order to take new values.
Do not forget measure how this change improve your Apache performance, if it is necessary, make changes again… Until you are acquiescent. Always is good know what is your resource limit assignation, in my RHEL 7:
There are not silver bullets in tuning
As you surely know, when you are tuning there is no universal recipes, so, you have organize you changes and make it in ordered fashion, measure and change again. It’s like a scientific method. Personally I rather make changes step-by-step instead of open