오늘은 대한입니다.
sun's longitude:299 48 16.16 
· 자유게시판 · 묻고답하기 · 알파문서 · RPMS list
· 사용자문서 · 팁/FAQ모음 · 리눅스Links · 자료실
· 서버정보 · 운영자 · Books/FAQ · FreeBSD
/board/delete.php:소스보기  
알파문서
자주 잊어먹거나, 메모해 둘 필요성이 있는 팁이나 문서, 기타 등등
[*** 쓰기 금지단어 패턴 ***]
글 본문 중간에 업로드할 이미지를 추가하는 방법 : @@이미지이름@@
ex) @@foo.gif@@
 ★ 글 지우기 항목입니다. 한번 더 생각하시고 결정하십시오.!!!
제목 119 : [PHP] stream, socket benchmark
 이름  산이 [홈]http://linuxchannel.net/
[PHP] client stream(blocking), socket(blocking/non-blocking) download Benchmark with server KeepAlive

2005.03.29 san2(at)linuxchannel.net

benchmark source :
- http://ftp.linuxchannel.net/devel/php_download/


1. client blocking (fsockopen) benchmark
------------------------------------------------------------------------------------
clinet server KeepAlive On server KeepAlive Off HTTP header
------------------------------------------------------------------------------------
NA(feof) 3965.9 KB/sec* 10718.7KB/sec
Connection 10882.1 KB/sec 10904.4KB/sec close
timeout 4017.3 KB/sec* 10769.2KB/sec
buf check 3984.5 KB/sec* 10811.5KB/sec  
Connection + timeout 11094.3 KB/sec 11382.6KB/sec close
Connection + buf check 10700.1 KB/sec 11489.4KB/sec close
timeout + buf check 10059.0 KB/sec 11073.0KB/sec
Connection + timeout + buf check 10589.5 KB/sec 11497.5KB/sec close
------------------------------------------------------------------------------------

PHP guide
(
Connection: close [+ ...] // <-- recommend
or
timeout + buf check [+ ...]
)

example
(
$req = "GET /path HTTP/1.1\r\nHost: hostname\r\nConnection: close\r\n\r\n";
$fp = fscokopen(...);
stream_set_timeout($fp,0,500000); // some recommend
fwrite($fp,$req);
while($buf = fread($fp,4096))
{
$rbuf .= $buf;
...
}
fclose($fp);
)


2. client blocking (socket) benchmark
------------------------------------------------------------------------------------
clinet server KeepAlive On server KeepAlive Off HTTP header
------------------------------------------------------------------------------------
NA(socket_read) 4014.9KB/sec* 11463.8KB/sec
Connection 11491.0KB/sec 11465.4KB/sec close
timeout 11372.2KB/sec 11482.3KB/sec
buf(1M) 4007.5KB/sec* 11294.7KB/sec
Connection + timeout 11373.5KB/sec 11496.8KB/sec close
Connection + buf(1M) 11500.8KB/sec 11017.5KB/sec close
timeout + buf(1M) 11373.2KB/sec 11499.9KB/sec
Connection + timeout + buf(1M) 11369.1KB/sec 11378.3KB/sec close
------------------------------------------------------------------------------------

PHP guide
(

Connection: close [+ ...]
or
timeout [+ ...]
)

example
(
$req = "GET /path HTTP/1.1\r\nHost: hostname\r\nConnection: close\r\n\r\n";
$timeout = array('sec'=>0,'usec'=>500000);
$sock = socket_create(...);
socket_set_option($sock,...,SO_RCVTIMEO,$timeout); // some recommend
socket_connect(...);
socket_write($sock,$req);
while($buf = socket_read($sock,1048576))
{
$rbuf .= $buf;
...
}
socket_close($sock);
)


3. client non-blocking (socket) benchmark
------------------------------------------------------------------------------------
clinet server KeepAlive On server KeepAlive Off HTTP header
------------------------------------------------------------------------------------
NA(socket_read) 11352.4KB/sec CLOSE_WAIT*
Connection CLOSE_WAIT* CLOSE_WAIT* close
timeout 11343.1KB/sec CLOSE_WAIT*
buf(1M) 11361.0KB/sec CLOSE_WAIT*
Connection + timeout CLOSE_WAIT* CLOSE_WAIT* close
Connection + buf(1M) CLOSE_WAIT* CLOSE_WAIT* close
timeout + buf(1M) 11359.1KB/sec CLOSE_WAIT*
Connection + timeout + buf(1M) CLOSE_WAIT* CLOSE_WAIT* close
------------------------------------------------------------------------------------

PHP guide
(
buf check [+ ...]
)

example
(
$req = "GET /path HTTP/1.1\r\nHost: hostname\r\nConnection: close\r\n\r\n";
$timeout = array('sec'=>0,'usec'=>500000);
$sock = socket_create(...);
socket_set_option($sock,...,SO_RCVTIMEO,$timeout); // some recommend
socket_connect(...);
socket_write($sock,$req);
socket_set_nonblock($sock); // set to non-blocking mode
$stream = array($sock);
while(@socket_select($stream,$write=NULL,$except=NULL,0,500000) !== FALSE)
{
if(!in_array($sock,$stream)) break;
if($buf = @socket_read($sock,1048576))
{
$rbuf .= $buf;
...
} else break; // good idea, EOF, buf check
}
socket_close($sock);
)


4. client non-blocking buf check (socket) benchmark

------------------------------------------------------------------------------------
clinet server KeepAlive On server KeepAlive Off HTTP header
------------------------------------------------------------------------------------
NA(socket_read) 10870.7KB/sec 11455.9KB/sec
Connection 11488.1KB/sec 11481.9KB/sec close
timeout 10869.7KB/sec 11165.4KB/sec
buf(1M) 10872.9KB/sec 11494.5KB/sec
Connection + timeout 10903.7KB/sec 11496.6KB/sec close
Connection + buf(1M) 11500.6KB/sec 11500.2KB/sec close
timeout + buf(1M) 10880.3KB/sec 11399.8KB/sec
Connection + timeout + buf(1M) 11500.1KB/sec 11498.4KB/sec close
------------------------------------------------------------------------------------

PHP guide
(
buf check [+ ...]
)


example
(
same as above example
)


EOF
2005년 03월 30일 23:29:45 수(저녁)  from 211.243.181.98
File ☆ 자료(파일:php-stream-socket-benchmark.xls)가 있는 글입니다. !!!
0
암호: 공용 보안 SSL 서버가 준비되기 전까지는 off 합니다

apache lighttpd linuxchannel.net 
Copyright 1997-2026. linuxchannel.net. All rights reserved.

Page loading: 0.01(server) + (network) + (browser) seconds