PHP Curl Slowness

前端 未结 7 922
隐瞒了意图╮
隐瞒了意图╮ 2021-02-04 02:44

For some reason my curl call is very slow. Here is the code I used.

$postData = \"test\"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,         


        
相关标签:
7条回答
  • 2021-02-04 02:49

    CURL has some problems with DNS look-ups. Try using IP address instead of domain name.

    0 讨论(0)
  • 2021-02-04 02:51

    try this

    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
    
    0 讨论(0)
  • 2021-02-04 02:52

    The curl functions in php directly use the curl command line tool under *nix systems.

    Therefore it really only depends on the network speed since in general curl itself is much faster than a webbrowser since it (by default) does not load any additional data like included pictures, stylesheets etc. of a website.

    It might be possible that you are not aware, that the network performance of the server on which you were testing your php script is way worse than on your local computer where you were testing with the browser. Therefore both measurements are not really comparable.

    0 讨论(0)
  • 2021-02-04 02:59

    Adding "curl_setopt($ch, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);" solved here. Any problem with this solution?

    0 讨论(0)
  • 2021-02-04 03:05

    Curl has the ability to tell exactly how long each piece took and where the slowness is (name lookup, connect, transfer time). Use curl_getinfo (http://www.php.net/manual/en/function.curl-getinfo.php) after you run curl_exec.

    If curl is slow, it is generally not the PHP code, it's almost always network related.

    0 讨论(0)
  • 2021-02-04 03:09

    generally thats acceptable when you are loading contents or posting to slower end of world. curl call are directly proportional to your network speed and throughput of your webserver

    0 讨论(0)
提交回复
热议问题