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
76
Search, Embeddings & Vector-DBs
chluehr
0
93
Reality Check: Automated Content Production at Enterprise Scale with Pimcore
chluehr
0
57
The how and why of getting Freelancers
chluehr
0
67
Content & Master Data Management with Pimcore
chluehr
1
590
Master Data Management with Pimcore
chluehr
0
190
PIM & Master Data Management with Pimcore 5 [en]
chluehr
2
300
Digital Transformation & Master Data Management with Pimcore 5
chluehr
0
220
LXD System Containers [en]
chluehr
0
310
Other Decks in Technology
See All in Technology
Houtou.pm #1
papix
0
670
人とAIとの共創を夢見た2か月 #共創AIミートアップ / Co-Creation with Keito-chan
kondoyuko
1
720
CSSDay, Amsterdam
brucel
0
150
Flutterアプリを⾃然⾔語で操作する
yukisakai1225
0
160
Introduction to Bill One Development Engineer
sansan33
PRO
0
240
コードの考古学 〜労務システムから発掘した成長の糧〜
kenta_smarthr
1
1.2k
Azure Developer CLI と Azure Deployment Environment / Azure Developer CLI and Azure Deployment Environment
nnstt1
1
140
RDRA3.0を知ろう
kanzaki
2
440
libsyncrpcってなに?
uhyo
0
160
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
8
65k
Java で学ぶ 代数的データ型
ysknsid25
1
870
S3 Tables を図解でやさしくおさらい~基本から QuickSight 連携まで/s3-tables-illustrated-basics-quicksight
emiki
2
340
Featured
See All Featured
Balancing Empowerment & Direction
lara
1
90
Art, The Web, and Tiny UX
lynnandtonic
298
21k
Unsuck your backbone
ammeep
671
58k
Building Better People: How to give real-time feedback that sticks.
wjessup
368
19k
A designer walks into a library…
pauljervisheath
205
24k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
29
1.7k
Practical Orchestrator
shlominoach
188
11k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
34
3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
15
890
Rebuilding a faster, lazier Slack
samanthasiow
81
9k
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 luehr@r-pentomino.de christoph.luehr@basilicom.de @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/