#php's existing application methods are all based on http, which is relatively weak for situations that require fast real-time response. For example, online games or push services generally need to maintain long-term communication with users. A tcp connection for real-time response and push information.
#swoole is designed to solve such application scenarios. (Recommended learning: SWOOLE Video Tutorial )
# Swoole Realization
Swoole is written in pure C, not depending on other third -party libraries .
swoole does not use libevent, so there is no need to install libevent
swoole does not rely on PHP's stream/sockets/pcntl/posix/sysvmsg and other extensions
socket Part
swoole uses the underlying socket system call.
IO event loop
The event loop of the main process uses select/poll, because there are only a few file descriptors in the main thread, just use select/poll
Use epoll/kqueue in the reactor thread/worker process
The task process does not have an event loop, and the process will cycle and block the read pipe
Many people use strace -p to view swoole The main process can only see the poll system call. The correct way to view it is strace -f -p
Multiple processes/multithreads
Multiple processes use the fork() system call
Multiple threads use pthread thread library
EventFd
Swoole uses eventfd as a mechanism for thread/inter-process message notification.
Timerfd
Swoole uses timerfd to implement the timer
SIgnalfd
signalfd is used in swoole To achieve signal shielding and processing. It can effectively avoid the problem of threads/processes being interrupted by signals and the system calling restart. The reactor thread will not receive any signals in the main process.
The above is the detailed content of What problem did swoole solve?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
