Jump to content

PHP/MySQL Process CPU Limit


sv4rog

Recommended Posts

Hi, i am developing a PHP5/MySQL website and testing it on my local machine, on an Apache server. And I have a problem.

I have written a PHP script that does a lot of computing and MySQL queries. I start it from a link on one of the pages on the site and when it's complete, and when it's done it writes in the output a sort of a "OK, DONE" statement on the next page.

This script has a lot of loops and can take up to 15 minutes to complete. The problem is that, while it is running, it takes up all of my CPU power, and I can't browse/do other stuff on the site until it's over.

 

It's definitely CPU, not memory - i tried to change memory_limit but it doesn't help.

 

Is there any way that I can limit the amount of CPU available to a single script???

 

(I don't mind if the script takes longer to complete, as long as I can do other stuff on the page comfortably while it is running.)

Link to comment
Share on other sites

What I would do is split the script into "multiple processes", IE after 1,000 records run, sleep for 100 seconds etc. That way its not too much of a strain. Or another way to do it is to do the 1,000 records deal than sleep the script and do a header refresh, so it clears up the memory etc.

 

Dunno if that would help but give it a try.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.