swoole hyperf CPU密集计算初体验

swoole hyperf CPU密集计算初体验

class IndexController extends AbstractController
{
    public function index()
    {
        $ss=0;
        for($i=0;$i<1000000000;$i++){
             $ss+=$i;
        }
        echo $ss;
        echo '
';
        echo date('Y-m-i H:i:s');
        $user = $this->request->input('user', 'Hyperf');
        $method = $this->request->getMethod();

        return [
            'method' => $method,
            'message' => "Hello {$user}.",
        ];
    }
}

2个客户端并发执行   然而结果很意外 没有堵塞线程 结果就是hyperf 在cpu密集计算中不会堵塞线程 他会挂起 交互执行

原文地址:https://www.cnblogs.com/newmiracle/p/14029230.html