Swoole Multiprocessing

Taking advantage of multicore, you have to use multiple processes in you server or application. You can build multiple processes application easily with the features provided by Swoole.

Create and manage multiple processes

Multiple processes can run simultaneously (without context-switching) in multi-core processors. You can create multiple Linux processes in several ways:

  1. Define and manage multiple Worker processes in Server.
  2. Define and manage multiple Task Worker processes in Server.
  3. Create and manage one process with Swoole Process.
  4. Create and manage multiple identical processes with Swoole Process Pool.
  5. You can use fork or pcntl_fork.

Share data across multiple processes

  1. Use multiple process safe counter defined with Swoole Atomic.
  2. Use Swoole Table as in memory KV storage.

Interprocess synchronization

  1. Use Swoole Atomic wait and wakeup for synchronization.
  2. Use Swooel Lock for synchronization.