lang/php

PHP workman Container helloWorld

C/H 2018. 6. 12. 08:30

Workerman

composer require workerman/workerman
vi serve.php
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
$worker = new Worker('tcp://0.0.0.0:1337');
$worker->count=3;
$worker->onMessage = function($connection, $data)
{
    $msg = "hello World";
    $connection->send("HTTP/1.1 200 OK\r\nConnection: keep-alive\r\nServer: workerman\r\nContent-Length: ".strlen($msg)."\r\n\r\n{$msg}");
};
Worker::runAll();
php serve.php start -d

#other shell
ab -n 10000 -c 10 -k http://127.0.0.1:1337/
..
Document Path:          /
Document Length:        11 bytes

Concurrency Level:      10
Time taken for tests:   0.094 seconds
Complete requests:      10000
Failed requests:        0
Keep-Alive requests:    10000
Total transferred:      930000 bytes
HTML transferred:       110000 bytes
Requests per second:    106857.01 [#/sec] (mean)
Time per request:       0.094 [ms] (mean)
Time per request:       0.009 [ms] (mean, across all concurrent requests)
Transfer rate:          9704.79 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.0      0       0
Processing:     0    0   0.1      0       3
Waiting:        0    0   0.1      0       3
Total:          0    0   0.1      0       3

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


반응형

'lang > php' 카테고리의 다른 글

PHP Laravel Framework helloWorld  (0) 2018.06.15
PHP reactPHP helloWorld  (0) 2018.06.14
php codeignier3 framework helloWorld  (0) 2018.06.11
PHP Slim Framework helloWorld  (0) 2018.06.07
PHP7 event, libevent Installation  (0) 2018.06.06