Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

PHP curl request is slow

Posted on 2014-01-10
5
2,970 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 83

Accepted Solution

by:
Dave Baldwin earned 167 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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 333 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 109

Assisted Solution

by:Ray Paseur
Ray Paseur earned 333 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I think I know what this error means, but I need some other eyes on it... 32 49
PHP Echo with auto submit 8 28
DNS zone 3 25
Separate DNS forwarding 2 17
Occasionally you run into the website or two that will not resolve properly using your own DNS servers.  Some people simply set up global forwarders for their DNS server.  I don’t recommend doing this because it can cause problems resolving addresse…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

808 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