Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PHP curl request is slow

Posted on 2014-01-10
5
Medium Priority
?
3,421 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
[X]
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
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to implement server side field validation and display customized error messages to the client.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 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