I would like to develop an app and want to come up a nice value for my daemon process. but I found no guideline for this.

Some articles say that backup tasks should have higher nice value (which means lower priority), but I couldn't find what kind of process should have lower nice value.

If there is no such guideline for setting nice value, wouldn't it just be a terrible world where every daemon setting their nice value to -20, which is the highest priority?


Is there a guideline for setting nice values for application developers?

No, because that's not something you can control; nor should you try to. (You will just annoy the system administrators who advise their bosses about software purchasing decisions.)

It requires root permissions to give your process higher priority. A well-designed daemon shouldn't run as root. The exceptions to this are very rare, and ALL of them directly relate to system management—not "applications" in the usual meaning of the word. If you aren't writing software for some sort of system management, you shouldn't be designing your application to run as root in the first place. So you won't even have the ability to give your application a higher priority.

If you want to give your application a lower priority, you can. In most cases you wouldn't do this, though; you would leave it to the system administrator to manage. Maybe if "low resource footprint" is one of your selling points, you would want to make sure it comes true by coding this in.

Are there guidelines for setting nice values for system administrators?

Yes, of course. This all comes under the heading of "system tuning." This revised version of your question is really too broad for the Stack Exchange format, but in a nutshell:

  1. Test before you tune. If IO is your bottleneck don't imagine you will solve things with renice.
  2. Prioritize the process(es) that are the actual reason you have that machine in the first place (e.g. if it's an LDAP server, prioritize LDAP processes).
  3. If a non-essential process is hogging resources (by actual test, not assumption—see point 1), clamp it down to prevent this.

...I couldn't find what kind of process should have lower nice value.

See point 2 above. It depends on the actual purpose of the machine as a whole.

  • I am assuming I am running my daemon with root privilege since I am actually developing some system management apps. So in this case, is there a guideline for setting nice values? – johnlinp Dec 29 '17 at 8:25
  • @林自均, do you have any reason to believe that the default nice value would cause problems? The most basic guideline about nice values is, "if you don't have a definite reason to fiddle with it, leave it alone." – Wildcard Dec 29 '17 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.