Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Question about cURL CPU usage
Old 08-04-2011, 07:17 PM Question about cURL CPU usage
Super Talker

Posts: 113
Trades: 0
Often when I use cURL in a script it takes several seconds to return a page. Is the script using 100% CPU during this time? I ask because I want to have a loop that requests lots of pages (over a hundred) using cURL, but because cURL takes a second or two per page, if it uses 100% CPU during this time then that would be really bad for the server!
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-04-2011, 07:43 PM Re: Question about cURL CPU usage
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
Could the website you're asking for just be slow? Keep in mind that your server and theirs have to both respond to get a fast response.

Try it on a site like Google. Google is lightning fast, so it'll help calculate how fast your own server is.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!

Last edited by Physicsguy; 08-04-2011 at 09:20 PM.. Reason: Speling error fix
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-04-2011, 08:59 PM Re: Question about cURL CPU usage
Super Talker

Posts: 113
Trades: 0
Yes, it's definitely possible that it's slow, and that's why the cURL requests take several seconds. I can try with another website like Google, as you suggested, but what I'm wondering is whether the script takes 100% of the server CPU while it's waiting for the page, or if it doesn't take processor during that time?
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Old 08-04-2011, 09:19 PM Re: Question about cURL CPU usage
Physicsguy's Avatar
404 - Title not found

Posts: 920
Name: Scott Kaye
Location: Ontario
Trades: 0
I've never messed around with cron. By doing some quick Googles (is that a word?) I've found that cron uses 'very little' CPU, which is a good thing, otherwise your website (and whole server!) would be bogged down running a cron job every day. You wouldn't want to take up your entire server's resources, which you most likely don't own yourself, to just check a simple URL, which you wouldn't.
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
Old 08-04-2011, 10:12 PM Re: Question about cURL CPU usage
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Cron and CURL are two completely different things. The answer is the same for either one however:

No they are not using 100% of your CPU.

There is an easy way to test this:
PHP Code:
$start time();
while(
time() - $start 5){}

$content file_get_contents('http://google.com');

$start time();
while(
time() - $start 5){} 
I'm using file_get_contents instead of cURL but the concept is the same. You'll notice 100% utilization (on one processor) for about five seconds, then a drop, then 100% for another five seconds.

What's happening is the process is asleep while it is waiting for an HTTP response.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is offline
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 08-04-2011, 10:22 PM Re: Question about cURL CPU usage
Super Talker

Posts: 113
Trades: 0
Quote:
What's happening is the process is asleep while it is waiting for an HTTP response.
Exactly what I was trying to figure out, thanks!!
Learnin' n00b is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Question about cURL CPU usage
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.25497 seconds with 12 queries