DNS resolution of PHPcurl (curl in PHP is slow)

Source: Internet
Author: User
DNS resolution of PHPcurl (the curl in PHP is slow): 1. use the curl function in the project to call an interface and find that the response is slow. 2. change the host address to the IP address of the Interface Server, fast response? First, we made a DNS service on other servers, hoping to speed up the DNS resolution (intranet resolution), and found that the system curl is very fast, but the DNS resolution problem with php PHP curl (the curl in PHP is slow)

Problem:

1. use the curl function to call an interface in the project and find that the response is slow.

2. change the host address to the IP address of the Interface Server. the response is very fast.

?

First, we made a DNS service on other servers, hoping to speed up the DNS resolution (intranet resolution). We tried to find that the system curl was very fast, but it was still very slow to execute the function using php curl.

?

In the php script, the interface domain name is resolved. through the gethostbyname () function, we found that the corresponding ip address is still the original ip address, which was not resolved again. in the past, PHP cached DNS resolution, after the domain name is resolved again, php is not restarted, so the original DNS resolution content is still used.

?

Solution:

? ? Restart php to solve the problem.

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: info-contact@alibabacloud.com 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.