Jump to content

Recommended Posts

Posted

I am using curl in loop which is causing high server load please help to reduce server load and manage memory leak..

 

I am using same handle to reduce execution time but it is consuming high resources..

Posted

Probably no-one will be able to help you without seeing your code and knowing how you use it.

Some general advices that I can give you are:

- remember to close every cURL handle after not using it anymore to free up server resources;

- if you want to make multiple connections at once multi cURL may be good choice;

- I found that often inserting some small pause inside of the loop while waiting for the multi cURL finishes the job in the form of ie. usleep(200) makes a big difference in a CPU usage.

Posted
Some general advices that I can give you are: - remember to close every cURL handle after not using it anymore to free up server resources;

 

He's trying to be efficient and using the same handle, my guess is he might actually be bottlenecking it by doing so, eg his next loop is being processed using the same handle as the previous before it, the previous instance, has had a chance to finish.

 

If he explains what he's trying to do perhaps there might be a better solution, but making the process sleep before restarting is probably best at the moment.

Posted

If you have access to the remote form set the action to the PHP script responsible for processing it on here without cURL.

 

If not just tell your script to sleep before rerunning the loop, this will give the server a chance to complete the processing and hopefully prevent the script from recursively chomping more and more system resources.

 

Better yet drop the loop count to something more reasonable.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...