search
HomePHP FrameworkSwooleCan PHPfpm and swoole coexist?

Can PHPfpm and swoole coexist?

Dec 12, 2019 am 10:50 AM
swoole

Swoole: The PHP asynchronous network communication engine for production environments enables PHP developers to write high-performance asynchronous concurrent TCP, UDP, Unix Socket, HTTP, and WebSocket services.

Can PHPfpm and swoole coexist?

Swoole can be widely used in the Internet, mobile communications, enterprise software, cloud computing, online games, Internet of Things (IOT), Internet of Vehicles, smart homes and other fields.

Using PHP Swoole as a network communication framework can greatly improve the efficiency of enterprise IT R&D teams and focus more on developing innovative products. (Recommended learning: swoole video tutorial)

php-fpm long connection              

Mainly maintain TCP long connection in php-fpm With the SWOOLE_KEEP option provided by the swoole extension, after the client sets this option, the connection will not be closed when the request ends, and the TCP connection can be reused after new requests arrive.

In addition, the bottom layer has built-in long connection detection capability.

When executing $client->connect(), it automatically detects whether the connection is available. If the reused connection has expired, the bottom layer will re-create a new TCP long connection.

Automatically clean up junk data when executing $client->connect() to avoid service exceptions caused by residual data from the last client timeout

$socket = new \swoole_client(SWOOLE_SOCK_TCP | SWOOLE_KEEP, WOOLE_SOCK_SYNC);
$socket->set(array(
    'open_length_check' => true,
    'package_max_length' => $this->packet_maxlen,
    'package_length_type' => 'N',
    'package_body_offset' => RPCServer::HEADER_SIZE,
    'package_length_offset' => 0,
));

The above is the detailed content of Can PHPfpm and swoole coexist?. 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 Article

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

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