rc15385 Posted December 1, 2012 Posted December 1, 2012 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..
Piotr GRD Posted December 1, 2012 Posted December 1, 2012 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.
Shinryuu Posted December 1, 2012 Posted December 1, 2012 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.
rc15385 Posted December 2, 2012 Author Posted December 2, 2012 i am trying to submit same form multiple times from another site.. say 100 times in one loop..
Shinryuu Posted December 2, 2012 Posted December 2, 2012 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now