0

In CentOs as from version 6 there is a by default process limit 1024 for every user i.e /etc/security/limits.d/90-nproc.conf

*          soft    nproc   1024

I have to execute a backend service/daemon "myservice", which require a bigger value in process limits. So I have to override pre-configured limit (1024). For that purpose I tried to create separate entries for root and myuser ( user running myservice ).

myuser          soft    nproc   5000
root            soft    nproc   5000

and then

service myservice restart

now limit was increased and seems that issue has been solved! but it was temporarily, after system reboot limit was again to 1024. (NOTE: myservice was configured to start at boot)

It seems that it happened due to init process who is responsible to start each service on system, hence "myserivce" as a child inherited parent's limits (init has 1024 limit by default).

I googled to find if there is any way to increase limits for init, but was not enough lucky to find any! I have tried to alter/etc/security/limits.d/90-nproc.conf

*          soft    nproc   5000

but still same, after reboot init still have 1024 limit and myservice also has 1024 limit

NOTE: if I restart myservice from shell prompt then it get accepted limits (5000) but I want to start it automatically after every reboot.

Can somebody guide me, How I can increase process limit for "myservice", and preserve it after reboot ?

Nasir Iqbal
  • 109
  • 5
  • Are you trying to increase the open file descriptor limit? (`nofile`) This seems to be your intent in the first sentence. Or, the [per-user process limit?](https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/chap-Security_Guide-Securing_Your_Network.html#sect-Security_Guide-Workstation_Security-Applying_Account_Limits) (`nproc`) – Aaron Copley Apr 15 '14 at 17:11
  • actually I want to increase both, just mentioned one – Nasir Iqbal Apr 15 '14 at 17:24
  • http://serverfault.com/a/589258/50647 ??? – Aaron Copley Apr 21 '14 at 14:02

1 Answers1

1

I think your problem could be two-fold. You appear to only be increasing the soft limit but not the hard limit. If the hard limit default is lower than the defined soft limit, I think you will continue to be constrained by the lower value.

Also, these are the per-user limits but not necessarily the kernel's system-wide configured limit. You may need to set the value with the appropriate sysctl command. (Make it persistent in /etc/sysctl.conf.)

For example, this will set the Kernel's maximum for file descriptors. (The Kernel tracks processes with open files, so this same key is related for both ulimit values.

sysctl -w fs.file-max=10000

(I think this is likely to be the part that is lacking persistence in your current configuration based on its omission.)

Then, you can set the per-user limits in /etc/security/limits.conf.

* soft nofile 2500
* hard nofile 5000

And /etc/security/limits.d/90-nproc.conf.

* soft nproc 2500
* hard nproc 5000

These values are examples only, of course and you can replace the asterisks with your user.

Aaron Copley
  • 12,525
  • 5
  • 47
  • 68