walkor / workerman

An asynchronous event driven PHP socket framework. Supports HTTP, Websocket, SSL and other custom protocols.
http://www.workerman.net
MIT License
11.12k stars 2.26k forks source link

Question: What http workers do ? #1003

Closed foremtehan closed 8 months ago

foremtehan commented 8 months ago

In this example:

<?php
Adapterman::init();

$http_worker = new Worker('http://localhost:8080');
$http_worker->count = cpu_count();
$http_worker->name = env('APP_NAME');

...

Can someone explain why we have to create mutiple http workers? I'm new to this idea. If the event loop (async) needs several http workers to manage parallel incoming requests, how is it different from php-fpm? Why it can't use a single thread like node ?

walkor commented 8 months ago

Creating multiple processes can fully utilize the CPU, while using only one process can only utilize one CPU.