3. </openswoole> Introduction
● Open Swoole is a high-performance network framework based on an event-driven,
asynchronous, non-blocking I/O coroutine programming model for PHP.
● Designed for building large scale concurrency systems. It is written in C/C++ and installed as
a PHP extension. Enabling PHP developers to write code in a more efficient manner, taking
advantage of event-loops and fibers/coroutines.
● Providing you with an easy to use coroutine API and allowing you to use existing libraries
within the PHP ecosystem.
What is Open Swoole?
5. </openswoole> What is a coroutine?
Coroutines are computer program components that generalize subroutines for
non-preemptive multitasking, by allowing execution to be suspended and
resumed.
A coroutine can be simply understood as a thread, but this thread is in user
mode and does not require the participation of the operating system. The cost
of creating, destroying and switching is very low. Unlike threads, the coroutine
cannot use multiple CPU core because it operates in user space but Swoole
provides a multi-process model to tackle this limitation.
8. </openswoole> Architecture
The differences between Open Swoole with PHP-FPM the traditional PHP model are:
● Open Swoole supports TCP, UDP and UnixSocket
● Open Swoole uses Non-blocking I/O mode with epoll or kqueue
● Open Swoole forks several worker processes based on CPU core number to utilise all CPU cores.
● Open Swoole supports Long-live connections for WebSocket server or TCP/UDP server.
● Open Swoole supports more server-side protocols: TCP/UDP/HTTP/HTTP2/WebSocket
● Open Swoole preload PHP files into memory.
● Open Swoole can manage and reuse the status in memory with PHP Swoole Memory Management Modules.
● Coroutine based concurrency compare with waterfall in PHP-FPM.