Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Swoole in 5 Minutes [en]
Search
Christoph Lühr
February 06, 2018
Technology
1
12k
Swoole in 5 Minutes [en]
Blazingly-Fast, Event-Driven, Asynchronous PHP. Berlin PHP Usergroup 02/06/2018
Christoph Lühr
February 06, 2018
Tweet
Share
More Decks by Christoph Lühr
See All by Christoph Lühr
Vektor-Suche & LLMs
chluehr
0
96
Search, Embeddings & Vector-DBs
chluehr
0
120
Reality Check: Automated Content Production at Enterprise Scale with Pimcore
chluehr
0
65
The how and why of getting Freelancers
chluehr
0
70
Content & Master Data Management with Pimcore
chluehr
1
660
Master Data Management with Pimcore
chluehr
0
200
PIM & Master Data Management with Pimcore 5 [en]
chluehr
2
300
Digital Transformation & Master Data Management with Pimcore 5
chluehr
0
240
LXD System Containers [en]
chluehr
0
340
Other Decks in Technology
See All in Technology
Capitole du Libre 2025 - Keynote - Cloud du Coeur
ju_hnny5
0
120
LINEギフト・LINEコマース領域の開発
lycorptech_jp
PRO
0
340
仕様は“書く”より“語る” - 分断を超えたチーム開発の実践 / 20251115 Naoki Takahashi
shift_evolve
PRO
1
1.1k
学術的根拠から読み解くNotebookLMの音声活用法
shukob
0
130
リアーキテクティングのその先へ 〜品質と開発生産性の壁を越えるプラットフォーム戦略〜 / architecture-con2025
visional_engineering_and_design
0
3.8k
ABEMAのCM配信を支えるスケーラブルな分散カウンタの実装
hono0130
4
1k
持続可能なアクセシビリティ開発
azukiazusa1
6
280
TypeScript 6.0で非推奨化されるオプションたち
uhyo
12
3k
JavaScript パーサーに using 対応をする過程で与えたエコシステムへの影響
baseballyama
1
110
はじめての OSS コントリビューション 〜小さな PR が世界を変える〜
chiroito
4
350
単一Kubernetesクラスタで実現する AI/ML 向けクラウドサービス
pfn
PRO
1
340
AI時代の戦略的アーキテクチャ 〜Adaptable AI をアーキテクチャで実現する〜 / Enabling Adaptable AI Through Strategic Architecture
bitkey
PRO
14
6.9k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
76
5.1k
Building an army of robots
kneath
306
46k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
51k
BBQ
matthewcrist
89
9.9k
A designer walks into a library…
pauljervisheath
210
24k
jQuery: Nuts, Bolts and Bling
dougneiner
65
8k
Visualization
eitanlees
150
16k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.1k
Leading Effective Engineering Teams in the AI Era
addyosmani
8
1.1k
Faster Mobile Websites
deanohume
310
31k
Scaling GitHub
holman
463
140k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.8k
Transcript
Christoph Lühr @chluehr / bephpug 2018 "Fast, faster, Swoole" Teaser:
Swoole in 5 Minutes
None
SIN CE 2000
None
"Blazingly-Fast, Event-Driven, Asynchronous PHP."
None
$ pecl install swoole
$ brew install swoole
<?php $server = new \Swoole\Http\Server('0.0.0.0', 9000); $server->on('Request', function ($request, $response)
{ $response->end('OK'); }); $server->start();
<?php $loop = React\EventLoop\Factory::create(); $server = stream_socket_server('tcp://0.0.0.0:9000'); stream_set_blocking($server, 0); $loop->addReadStream($server,
function ($server) use ($loop) { $conn = stream_socket_accept($server); $data = "HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nHi\n"; $loop->addWriteStream($conn, function ($conn) use (&$data, $loop) { $written = fwrite($conn, $data); if ($written === strlen($data)) { fclose($conn); $loop->removeStream($conn); } else { $data = substr($data, $written); } }); }); $loop->run();
PHP-PM
None
Sugar and Cream? (PHP is not enough ...)
Async IO
File I/O (and some tagline to go along)
TCP Clients MySQL / Redis / HTTP / WebSocket
"Reality Distortion" BENCHMARKS
300.000 Req/Sec
wrk -t4 -c400 -d10s http://127.0.0.1:1337/ Running 10s test @ http://127.0.0.1:1337/
4 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.46ms 1.42ms 27.96ms 85.66% Req/Sec 75.29k 36.43k 183.55k 72.75% 3007806 requests in 10.06s, 605.25MB read Requests/sec: 299103.32 Transfer/sec: 60.19MB
wrk -t16 -c400 -d30s http://localhost:9000/ Running 30s test @ http://localhost:9000/
16 threads and 400 connections Thread Stats Avg Stdev Max +/- Stdev Latency 6.97ms 7.07ms 226.95ms 93.28% Req/Sec 4.00k 0.96k 15.36k 76.15% 1909179 requests in 30.09s, 282.21MB read Requests/sec: 63442.77 Transfer/sec: 9.38MB
Demo
Real World(tm) References?
None
None
To good to be true...? DRAWBACKS
中文
None
Thanks! Questions? Christoph Lühr
[email protected]
[email protected]
@chluehr Slides license Attribution-NonCommercial-ShareAlike
3.0 http://creativecommons.org/licenses/by-nc-sa/3.0/
• Swoole 2.0 https://www.swoole.co.uk/