search
HomePHP FrameworkSwooleWhat problem did swoole solve?

What problem did swoole solve?

Dec 12, 2019 pm 01:56 PM
swoole

What problem did swoole solve?

#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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function