• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

how to limit a customer or subscription plans apache CPU usage?

Sven L.

Regular Pleskian
plesk 11.5.30#14
centos 6.4

Hello,

I am getting warning per mail whenever one of my domains executes a scheduled php script (twice per day)
Server health parameter "Services > Apache CPU usage" changed its status from "green" to "red".

this script seems produce a lot of heat, but we need this script to happen.

it moves around 1,5GB of fotos around and converts a XML file to myphp

is there any way i can limit how much apache CPU a domain, customer, subscription or whatever uses? can i set it somehow to never exceed 25%? it doesnt matter if the script takes longer.
 
hm, actually I might be totally off. reading the alarm email a bit more, there is a specific process causing this, and i am not sure if it's related to what i said above

Server health parameter "Services > Apache CPU usage" changed its status from "green" to "red".

top - 15:12:32 up 7 days, 23:21, 0 users, load average: 2.03, 2.46, 2.39
Tasks: 188 total, 3 running, 185 sleeping, 0 stopped, 0 zombie
Cpu(s): 35.6%us, 0.1%sy, 0.5%ni, 63.6%id, 0.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 5993156k total, 2614804k used, 3378352k free, 329624k buffers
Swap: 393208k total, 15064k used, 378144k free, 1432152k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
3697 root 20 0 335m 31m 17m R 98.4 0.5 11424:21 sw-engine
17843 root 20 0 335m 31m 17m R 98.4 0.5 1000:53 sw-engine
5625 root 20 0 15028 1152 828 R 2.0 0.0 0:00.01 top
sw-engine being the culprit.

i have searched the forum a bit and found this: http://kb.parallels.com/en/112543
but that's for plesk 10, this should not apply anymore in plesk 11.5?

also, after around 20 minutes (which is the time that users script needs) the alarm level goes back to green with another email.
 
Why do you involve Apache in your Cron? You could just schedule and run the php script through shell with php -f /var/www/vhosts/domain.ltd/httpdocs/script.php, and this would not affect your Apache health ..
 
hm, actually I might be totally off. reading the alarm email a bit more, there is a specific process causing this, and i am not sure if it's related to what i said above


sw-engine being the culprit.

i have searched the forum a bit and found this: http://kb.parallels.com/en/112543
but that's for plesk 10, this should not apply anymore in plesk 11.5?

also, after around 20 minutes (which is the time that users script needs) the alarm level goes back to green with another email.

Is that all there's in the email? Because I do not see sw-engine causing the Apache Alarm ...Besides sw-engine now runs on Nginx and not apache as used to be ..
 
the quoted part is in one single email. title : apache cpu load and then showing sw-engine as consuming all the cpu

and about your previous question, this is the scheduled task, under the user of that domain, running twice a day:

php /var/www/vhosts/domain.tld/httpdocs/cron/update.php >/dev/null 2>&1


i don't have enough knowledge to know if apache is the culprit, i don't know what sw-engine is the only thing i know is that i get this warning email and it is around the same time that script is running.


even tho all my assumptions might be wrong, i would still like to know how to deal with customers who create heavy load scripts. and ofc how to fix this warning.
 
how to deal with customers who create heavy load scripts

1. First, you need to limit php execution time by setting a lower value eg..
Code:
max_execution_time = 30

2. You need to limit how much memory every php script can consume at any one time eg...
Code:
memory_limit = 256M

3. CSF / LFD can help monitor and track any scripts running for longer than the defined time and at your choice it can kill them for you...
4. Reduce your apache KeepAliveTimeout to even 2 seconds and it's Timeout

and several other tips (google search should you give extensive info on this subject)

Code:
ps -ef | grep php
Should show you a list of php scripts running
 
Last edited:
Mate my mem limit is set pretty low already and I couldn't care less if a script would run for 3 days as long as I doesn't consume so much CPU. So... How can I do that?

I don't want to kill customer scripts after a timeout I want to reduce their CPU usage.
 
So, obviously what you're saying is that it cannot be done with plesk...

I don't want to tamper too much with the OS because too many stuff reverts each update and all manual done stuff needs to be redone everytime we migrate.

Also in a previous message you say you don't think sw-engine is causing this alerts? How comes when there are two processes at 98,4% CPU ?
 
So, obviously what you're saying is that it cannot be done with plesk...

Yes, it can't!

you say you don't think sw-engine is causing this alerts...

Like I said earlier, Plesk engine now uses Nginx and thus Apache wouldn't complain because of it ..However, a possibility could be sw-engine used up much of your CPU / Menory that Apache couldn't find any free to use, thus triggering the notification ...
 
Like I said earlier, Plesk engine now uses Nginx and thus Apache wouldn't complain because of it ..However, a possibility could be sw-engine used up much of your CPU / Menory that Apache couldn't find any free to use, thus triggering the notification ...

i suspect it's not related to apache.

i just noticed on my smartphone (i have the plesk remote thingy) that i got alarms for "web cpu usage"... so maybe the wording "apache" of the email is just wrong and it is in reality nginx. i dont know.

anyways, i'd really love to hear from plesk an official response on how to limit cpu usage of php scripts, even if it has to be done with 3rd party tools like abdi so kindly searched for me, but i want to know what parallels has to say on the matter to not break anything.
 
Back
Top