2013-03-04 4 views
1

내 웹 사이트와 파트너 웹 사이트간에 데이터를 전송할 때 cURL을 사용하고 있습니다.php cURL - 느린 업로드 한도 - 최적화하는 방법?

요청이 매우 길지만 (~ 18 초), 정보량은 아주 적습니다 (~ 207 바이트). curlinfo 문서에

17.418212 total_time : Total transaction time in seconds for last transfer 
0.064612 namelookup_time : Time in seconds until name resolving was complete 
0.437222 connect_time : Time in seconds it took to establish the connection 
0.946509 pretransfer_time : Time in seconds from start until just before file transfer begins 
17.418172 starttransfer_time : Time in seconds until the first byte is about to be transferred 
0 redirect_count : Number of redirects 
0 redirect_time : Time in seconds of all redirection steps before final transaction was started 
207 size_upload : Total number of bytes uploaded 
11 speed_upload : Average upload speed 
130 size_download : Total number of bytes downloaded 
7 speed_download : Average download speed 

: 여기

// Send the subscription   
$resource = curl_init($url); 
curl_setopt($resource, CURLOPT_RETURNTRANSFER, true); 
curl_setopt($resource, CURLOPT_POST, count($postFields)); 
curl_setopt($resource, CURLOPT_POSTFIELDS, $postString); 
$result = curl_exec($resource); 

이 (가) curlinfo 디버그의 결과입니다 : 여기

요청 생성하려면 코드입니다 http://curl.haxx.se/libcurl/c/curl_easy_getinfo.html를, 그것이라고 그 size_upload 및 speed_upload 바이트와 ​​초당 바이트 수입니다.

매우 빠르지 않습니까? 다른 디버그 정보는 어디에서 찾을 수 있습니까?이 속도를 향상 시키려면 어떻게해야합니까?

추가 정보 : 데이터를 전송 및 수신 두 서버 좋은 대역폭 이 모두 그것은 서버 측에서 성능 문제처럼 보이는 같은 도시

+2

1 컬링 호출을 디버깅 한 경우 +1. curl 문제가있는 대부분의 사용자는 curl_error()에 대해서조차 모른다. 스택 오버플로에 오신 것을 환영합니다! :) –

+1

브라우저에서 요청을 할 때 요청이 얼마나 빠릅니까? 원격 스크립트가 데이터를 생성하는 데 17 초가 걸릴 수 있습니까? –

+0

서버 측에서 성능 문제가있는 것 같습니다. – Kamil

답변

0

에 있습니다.()에 의해보고 curl_getinfo

속도는 다음과 같이 계산된다 :을 totalTime curl_exec는 실행 시간이다

bytesPerSecond = totalBytesReceived/totalTime 

.

서버 응답이 지연되는 경우 (서버가 사용 중입니다.) 마지막 밀리 초 내에 60 바이트를 가져 오는 데 1 분 정도 걸릴 수 있으며보고 된 속도는 초당 1 바이트가됩니다. 서버 간의 네트워크 연결 속도는 중요하지 않습니다.

+0

아, 네 바이트/초 카운트 방법으로 분명하다. 나는 직관적으로이 업로드 속도를 네트워크 연결로 보았지만이 방법은 많은 의미가있다. 귀하의 대답 + Pekka의 통찰력은 올바른 방향으로 나를 잡았습니다. – np87

+0

@ np1987 그럼 어떻게 든 서버 측에서 코드를 최적화해야합니다. 행운을 빕니다. – Kamil