# swoole_phalcon_cli **Repository Path**: lswwyp/swoole_phalcon_cli ## Basic Information - **Project Name**: swoole_phalcon_cli - **Description**: swoole + phalconcli - **Primary Language**: PHP - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2019-07-17 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **ab实测【1核1G centos7.4,phalcon3.4,PHP7.2,swoole4.4】** ``` [root@localhost ~]# ab -c 100 -n 1000000 -k -r http://127.0.0.1:9502/main/index This is ApacheBench, Version 2.3 <$Revision: 1430300 $> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking 127.0.0.1 (be patient) Completed 100000 requests Completed 200000 requests Completed 300000 requests Completed 400000 requests Completed 500000 requests Completed 600000 requests Completed 700000 requests Completed 800000 requests Completed 900000 requests Completed 1000000 requests Finished 1000000 requests Server Software: Lw.Server-01 Server Hostname: 127.0.0.1 Server Port: 9502 Document Path: /main/index Document Length: 16 bytes Concurrency Level: 100 Time taken for tests: 93.333 seconds Complete requests: 1000000 Failed requests: 0 Write errors: 0 Keep-Alive requests: 1000000 Total transferred: 192000000 bytes HTML transferred: 16000000 bytes Requests per second: 10714.30 [#/sec] (mean) Time per request: 9.333 [ms] (mean) Time per request: 0.093 [ms] (mean, across all concurrent requests) Transfer rate: 2008.93 [Kbytes/sec] received Connection Times (ms) min mean[+/-sd] median max Connect: 0 0 0.0 0 3 Processing: 1 9 1.6 9 64 Waiting: 1 9 1.6 9 64 Total: 1 9 1.6 9 64 Percentage of the requests served within a certain time (ms) 50% 9 66% 9 75% 10 80% 10 90% 10 95% 10 98% 12 99% 14 100% 64 (longest request) ``` >doc ``` // setting 'task_max_request' => 0, 'task_worker_num' => 1, 'dispatch_mode' => 2, // Request function onRequest($request, $response) { $response->header('Server', 'Lw.Server-01'); $_POST = $request->post; $_GET = $request->get; $_FILES = $request->files; //$this::$serv->reload();// 热更新application... reload workers $cmf = explode('/', $request->server['request_uri']); $arguments = []; if (isset($cmf[1])) { $arguments['task'] = $cmf[1]; } if (isset($cmf[2])) { $arguments['action'] = $cmf[2]; } ob_start(); $this::$application->handle($arguments); $result = ob_get_contents(); ob_end_clean(); $response->header('Cache-Control', 'max-age=3600'); $response->end($result); } // MainTask public function indexAction() { echo "
"; $this->serv->task($_POST); //print_r($this->db->fetchOne('show tables;')); echo "index-task\n"; } // onTask function onTask($serv, $task_id, $from_id, $data) { $this::$application->db->insertAsDict('system_log', [ 'uid' => 8961701, 'ip_addr' => 1, 'node' => 'session/login', 'created_at' => $_SERVER['REQUEST_TIME'], 'content' => 'content' ]); // $this::$application->logger->info(json_encode($data)); } // onWorkerStart * 开启事务,数据库写入更快,但整体QPS承载较弱 * 不开事务,QPS可达21057.71 [#/sec] (mean) ```