phpapacheapache2nicerenice

Does PHP proc_nice leave Apache threads at new priority setting?


When executing proc_nice(), is it actually nice'ing Apache's thread?

If so, and if the current user (non-super user) can't renice to its original priority is killing the Apache thread appropriate (apache_child_terminate) on an Apache 2.0x server?

The issue is that I am trying to limit the impact of an app that allows the user to run Ad-Hack queries. The Queries can be massive and the resultant transform on the data requires a lot of Memory and CPU.

I've already re-written the process to be more stream based - helping with the memory consumption, but I would also like the process to run a lower priority. However I can't leave the Apache thread in low priority as we have a lot of high-priority web services running on this same box.

TIA


Solution

  • In that kind of situation, a solution if often to not do that kind of heavy work within the Apache processes, but either :


    As often as possible, especially if the heavy calculations take some time, I would go for the second solution :


    Another (nice-looking, but I haven't tried it yet) solution would be to use some kind of tool like, for instance, Gearman :

    Gearman provides a generic application framework to farm out work to other machines or processes that are better suited to do the work.
    It allows you to do work in parallel, to load balance processing, and to call functions between languages.
    It can be used in a variety of applications, from high-availability web sites to the transport of database replication events.
    In other words, it is the nervous system for how distributed processing communicates.