The example in this article describes the usage of php asynchronous multi-threaded swoole. Share it with everyone for your reference. The specific analysis is as follows:
swoole redefines the high-performance network communication framework of PHP language and provides asynchronous multi-threaded services of PHP language. The following example can confirm this function.
Generally speaking, Swoole provides asynchronous multi-threaded server in PHP language, asynchronous TCP/UDP network client, asynchronous MySQL, database connection pool, AsyncTask, message queue, millisecond timer, asynchronous file reading and writing, asynchronous DNS query.
Swoole has been heard before, and it is an artifact when used as a game server... I experienced it a little today, built an environment under ubuntu, and tested it
The specific test code is as follows:
<?php
class page extends Controller
{
function index()
{
$data = createModel('UserInfo')->get(12)->get();
$this->swoole->tpl->assign('data',$data);
$html = $this->swoole->tpl->fetch('test.html');
$time = $this->showTime();
return $html.$time;
}
}
shell
ab -c 100 -n 1000 -k http://127.0.0.1/index/
Requests per second
Time per request (mean)
Time per request (mean, across all concurrent requests)Operation method:
Swoole EventTCP SWOOLECTCP SWOOLE BLOCKP Apache/PreFork
Single Process
571.70 [#/SEC] 174.916 [MS] 1.749 [MS] 659.01 [#/SEC]
151.743 [MS]
[MS]
561.24 [#/sec] 7178.178 [ms]
1.782
80.57
1241.083 [ms]
12.411 [ms]
4 process
1153.63 [#/sec]
86.683 [ms]
0.867 [ms]
1010.08 [#/sec]
99.002 [ ms]
0.990 [ms]
1094.58 [#/sec]
91.359 [ms]
0.914 [ms]

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver Mac version
Visual web development tools

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





