Curl_exec and wget do too slow, IPv6 trouble _php Tutorial

Source: Internet
Author: User
Tags reverse dns
Today, when using the PHP curl function, it is too slow to find that you need to wait about 5 seconds to get the results. When the same URL is accessed using a browser, the page is immediately available. It was later discovered that, even without PHP, it was slow to use the native command wget under Linux to get the web. It's so weird, it doesn't look like a program, it's a network setup problem.
When executing wget, it can be seen that blocking occurs in the DNS Domain name Resolution section.
$ wget
--2012-06-18 12:17:30--
Resolving ... # stalled here for about 5 seconds
Connecting to||:80 ... Connected.
HTTP request sent, awaiting response ... OK
length:unspecified [text/html]
Saving to:index.html?

[<=>] 5,200--.-k/s in 0s

2012-06-18 12:17:35 ($ mb/s)-index.html saved [5200]
I am using the development environment, the domain name resolves to an internal IP. Strangely enough, I use ping to get an IP address and return an ICMP message. Why is Wget's DNS resolution so slow?
Google to StackOverflow above also have a lot of people to mention this problem, there is said to be reverse DNS reverse Domain Name resolution problem, have said to add that domain name in the host file ... will not solve my problem. Baffled by the occasion, suddenly thought last week is IPv6 day, we shipped a mail said the company network has all enable IPV6. Would that be the reason? Follow this clue to find out, sure enough, suddenly enlightened.
$ wget-4
The result is returned in an instant. It seems that the operation has not helped us to bind a IPV6 address for this domain name, the entire network upgrade, the default will be the first to resolve the IPV6, in the case of the domain does not IPv6, will wait for IPV6 parsing failure timeout After the normal process to find IPv4 before.
For PHP Curl, just add the following sentence to solve the delay problem:
curl_setopt ($ch, Curlopt_ipresolve, CURL_IPRESOLVE_V4);
Many servers now have IPv6 but no routing and cannot really work, causing unexpected problems. I deeply realize that IPv6 road is long and endless ... true techarticle today, when using the PHP curl function, it is too slow to find that you need to wait about 5 seconds to get the results. While the same URL is accessed using a browser, you can get the page immediately ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.