S
S
Sergey Sokolov2017-09-08 12:04:44
PHP
Sergey Sokolov, 2017-09-08 12:04:44

Curl began to slow down more often. How to determine the cause?

The service constantly makes requests to the API of another service via curl. One request usually takes hundredths of a second.
Recently, “brake” requests have become more frequent, the time of which is right for a second, or even crashes according to the timeout, which I set to 10 seconds.
Moreover, the trend is negative - in general, there are more and more of them per day - because of this, the overall performance of the service is reduced.
On the side of the “that” service with API, the statistics cheerfully report the operating time of the methods in the norm, hundredths of a second. Those. like, they're fine.
How to understand what is the problem on my side? Maybe lack of memory, other resources? How to approach catching a bug?
upd . From the next hung request (updated the timeout for 5 seconds) such

data
"url"   : "https://api.xxx.xxx/xxxxxx...",
"content_type"              : null,
"http_code"                 : 0,
"header_size"               : 0,
"request_size"              : 242,
"filetime"                  : -1,
"ssl_verify_result"         : 0,
"redirect_count"            : 0,
"total_time"                : 5.004937,
"namelookup_time"           : 2.7e-5,
"connect_time"              : 2.8e-5,
"pretransfer_time"          : 2.9e-5,
"size_upload"               : 0,
"size_download"             : 0,
"speed_download"            : 0,
"speed_upload"              : 0,
"download_content_length"   : 910,
"upload_content_length"     : 0,
"starttransfer_time"        : 0,
"redirect_time"             : 0,
"certinfo"                  : [],
"primary_ip"                : "xxx.xxx.xxx.xxx",
"redirect_url"              : ""

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Dart, 2017-09-08
@gobananas

Look in curl_getinfo there is:
CURLINFO_TOTAL_TIME - operation execution time in seconds;
CURLINFO_NAMELOOKUP_TIME - server name resolution time in seconds;
CURLINFO_CONNECT_TIME - time taken to establish a connection, in seconds;
CURLINFO_PRETRANSFER_TIME - time elapsed from the beginning of the operation to the readiness for the actual data transfer, in seconds;
CURLINFO_STARTTRANSFER_TIME - time elapsed from the beginning of the operation until the moment of transfer of the first data byte, in seconds;
CURLINFO_REDIRECT_TIME - time spent on redirection, in seconds;
If all this quickly works out for you, then you have a problem, if one of the variables is large, then which one - look where the time delay goes. If they have a problem, then nothing much can be done here, if not in curl, then you can already think ...

M
Maxim Timofeev, 2017-09-08
@webinar

Maybe just the size of the content that the method returns has increased? Maybe there is an overlay? Maybe on the client then there is processing and there is a delay. Not much info, so just speculation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question