«   2018/10   »
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
Archives
Today
153
Total
1,163,508
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

PHP reactPHP helloWorld 본문

Language/PHP

PHP reactPHP helloWorld

푸른바람 C/H 2018.06.14 08:30

ReactPHP

composer require 'react/react=*'
vi server.php
<?php
require_once(__DIR__. '/vendor/autoload.php');

$i = 0;
$app = function ($request, $response) use ($i) {
    $response->writeHead(200, array('Content-Type' => 'text/html'));
    $response->end("Hello World");
    $i++;
};

$loop = React\EventLoop\Factory::create();

$socket = new React\Socket\Server($loop);
$http = new React\Http\Server($socket, $loop);

$http->on('request', $app);
echo "Server running at http://127.0.0.1:1337\n";

$socket->listen(1337);
$loop->run();
php server.php
Server running at http://127.0.0.1:1337

# other shell
ab -n 10000 -c 10 http://127.0.0.1:1337/
...
Concurrency Level:      10
Time taken for tests:   1.943 seconds
Complete requests:      10000
Failed requests:        0
Keep-Alive requests:    0
Total transferred:      1200000 bytes
HTML transferred:       210000 bytes
Requests per second:    5146.61 [#/sec] (mean)
Time per request:       1.943 [ms] (mean)
Time per request:       0.194 [ms] (mean, across all concurrent requests)
Transfer rate:          603.12 [Kbytes/sec] received

Connection Times (ms)
                min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     1    2   0.2      2       4
Waiting:        1    2   0.2      2       4
Total:          1    2   0.2      2       4

Percentage of the requests served within a certain time (ms)
    50%      2
    66%      2
    75%      2
    80%      2
    90%      2
    95%      2
    98%      3
    99%      3
    100%      4 (longest request)


'Language > PHP' 카테고리의 다른 글

Python Scrapy 사이트 스크랩/크롤링  (0) 2018.06.28
PHP Laravel Framework helloWorld  (0) 2018.06.15
PHP reactPHP helloWorld  (0) 2018.06.14
PHP workman Container helloWorld  (0) 2018.06.12
php codeignier3 framework helloWorld  (0) 2018.06.11
PHP Slim Framework helloWorld  (0) 2018.06.07
0 Comments
댓글쓰기 폼