Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PHP curl request is slow

Posted on 2014-01-10
5
Medium Priority
?
3,580 Views
Last Modified: 2014-01-15
Hi,

I'm using curl to retrieve sections of this page:
http://pastorlbm.com/index_03_newsevents.php

instead of the php include since it's by default disabled on networksolutions.

But it's so slow.

So I was reading on some posts that it could be a DNS issue. I found this script from here:
http://www.jeremyquinton.com/how-to-debug-slow-curl-requests-in-php/

and ran it and here is the output:

Array
(
    [url] => http://www.pastorlbm.com/
    [content_type] => text/html
    [http_code] => 200
    [header_size] => 284
    [request_size] => 56
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 0.03184
    [namelookup_time] => 0.003974
    [connect_time] => 0.005883
    [pretransfer_time] => 0.005965
    [size_upload] => 0
    [size_download] => 20988
    [speed_download] => 659170
    [speed_upload] => 0
    [download_content_length] => 20988
    [upload_content_length] => 0
    [starttransfer_time] => 0.030919
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [redirect_url] => 
)

Open in new window


So it seems the DNS namelookup doesn't seem to be the issue. What else could be causing this?

Thank you,
Victor
0
Comment
Question by:Victor Kimura
  • 2
  • 2
5 Comments
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 668 total points
ID: 39772242
It is a very slow page that takes about 14 seconds to load.  Part of that is caused by 5 "404 Not found" responses.  The initial page load is over 8 seconds before the browser can even start getting the rest of the files on the page.
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1332 total points
ID: 39773415
With something like this you can often use Firefox YSlow to find many of the reasons a page is slow to load.  You will also need Firebug.

My page load time for http://www.pastorlbm.com/ was sub-second.

My page load time for http://pastorlbm.com/index_03_newsevents.php was painfully slow.  There are a lot of files showing in the HTML, as well as JavaScript calls to external web services.  And the queries for the calendar may be slow, too.

Also, there is the markup... sigh.
http://validator.w3.org/check?uri=http%3A%2F%2Fpastorlbm.com%2Fhome.html&charset=%28detect+automatically%29&doctype=Inline&group=0
0
 

Author Comment

by:Victor Kimura
ID: 39774142
Ok, thanks, @Dave and @Ray. It's strange that the only real difference between those pages are the curl function calls which simply separate the page into sections. So all I'm doing is (instead of using PHP include) I'm using curl function calls to separate the left section, top, and footer sections so I can manage the code easier. But the resulting code I believe is all the same.

It's one of those terrible WYSIWYG from Network Solutions. It's temporary solution for now until I transition to something like Wordpress and some other hosted network provider that uses cPanel which I like.

I'll look at Yslow or G Pagespeed. I forgot to validate and I'm sure there are a lot of errors remaining. (sigh). I'll try and convince my pastor to switch but she said not right now I think. I'll try and clean up the code as best as possible and will report here.

Thank you, fellas!
0
 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1332 total points
ID: 39774698
PHP include() requires access to a disk drive, typically on the same server, so it's likely to be measured in the low milliseconds (7200 RPM means 8.3 ms per rotation, more or less).  In contrast, cURL means a trip to the internet, complete with domain name server lookups, socket connections, protocol handshakes, etc.  So it would be expected to be slower than include().  And a few cURL connections would be expected to be much slower that a few include()s.
0
 

Author Comment

by:Victor Kimura
ID: 39776235
Ok, thanks, Ray! I didn't know that (the differences in performance between include() and curl()).

I read that include shouldn't be used because of security issues and it's better to use curl. I'm using curl right now because include is disabled by the hosting provider Network Solutions.

If I'm simply separating the content sections (i.e. header, footer, left sections) by using include() - that is, if I could use it by my hosting provider - then what would the security risk be and is there a way to mitigate or eliminate the security risk by using include (as opposed to curl)?

Thanks
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Network ports are the threads that hold network communication together. They are an essential part of networking that can be easily ignore or misunderstood, my goals is to show those who don't have a strong network foundation how network ports opera…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question