swoole2 - Worker process and TaskWorker

1.swoole process model

  swoole is a framework for a multi-process model, when starting a process swoole application, altogether will create 2 + n + m threads, n is the number of worker processes, m is TaskWorker number of processes, a master process and a manager process, relationship As shown below

  

  Master process-based process, which creates Manager processes, Reactor threading Work / thread

  Where the relationship between the three processes are:

  Reactor threads:

  • Responsible for maintaining client TCPconnections, network processing IO, protocol processing, send and receive data
  • It is completely non-blocking asynchronous mode
  • All of Cthe code, in addition to Start/ Shudownevent callback, but does not execute any PHP code
  • The TCPclient buffering incoming data, spliced, split into a complete request packet
  • ReactorOperate in a multi-threaded manner

  Worker process

  • Accepted by the Reactorthread posted request packet, and executes the PHPcallback data processing
  • Generating response data and sent to Reactorthe thread, the Reactorsending thread to the TCPclient
  • Can be asynchronous non-blocking mode, it can be synchronous blocking mode
  • WorkerRun as multiple processes

  TaskWorker process 

  • Accepted by the Workerprocess by the swoole_server->task/taskwaitmethod of delivery of mission
  • Processing tasks, and returns the data (using swoole_server->finish) to the Workerprocess
  • Completely synchronous blocking mode
  • TaskWorkerRun as multiple processes

Guess you like

Origin www.cnblogs.com/jint-php7/p/11672343.html