Answer the question
In order to leave comments, you need to log in
How to speed up requests through curl?
DD!
There is a script that sends a series of requests to the same site with different data. I noticed that it takes too long, it turned out that the time from sending a request to receiving a response is about 6 seconds. I think it's too much.
the code is like this:
echo "\t\t\t\t[" . date("H:i:s d.m") . "]Send request\n";
$curl = new Curl();
$response = $curl->get($url);
echo "\t\t\t\t[" . date("H:i:s d.m") . "]Got response\n";
Answer the question
In order to leave comments, you need to log in
Are you creating a new curl instance before each request? curl automatically tries to use keep-alive (maintaining a connection) and multiple requests to the same site will go faster if 2+ requests do not have connection establishment overhead. I also recommend looking at the output of the curl_getinfo command (I don’t know what it is called in yii2-curl), which will indicate what exactly and how much time the curl spends on and based on this it will be possible to draw conclusions whether it is possible to improve something there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question