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
53
Search, Embeddings & Vector-DBs
chluehr
0
76
Reality Check: Automated Content Production at Enterprise Scale with Pimcore
chluehr
0
40
The how and why of getting Freelancers
chluehr
0
60
Content & Master Data Management with Pimcore
chluehr
1
530
Master Data Management with Pimcore
chluehr
0
180
PIM & Master Data Management with Pimcore 5 [en]
chluehr
2
290
Digital Transformation & Master Data Management with Pimcore 5
chluehr
0
220
LXD System Containers [en]
chluehr
0
280
Other Decks in Technology
See All in Technology
N=1から解き明かすAWS ソリューションアーキテクトの魅力
kiiwami
0
130
OpenID Connect for Identity Assurance の概要と翻訳版のご紹介 / 20250219-BizDay17-OIDC4IDA-Intro
oidfj
0
280
利用終了したドメイン名の最強終活〜観測環境を育てて、分析・供養している件〜 / The Ultimate End-of-Life Preparation for Discontinued Domain Names
nttcom
2
200
The Future of SEO: The Impact of AI on Search
badams
0
200
エンジニアが加速させるプロダクトディスカバリー 〜最速で価値ある機能を見つける方法〜 / product discovery accelerated by engineers
rince
4
380
RSNA2024振り返り
nanachi
0
590
個人開発から公式機能へ: PlaywrightとRailsをつなげた3年の軌跡
yusukeiwaki
11
3k
データマネジメントのトレードオフに立ち向かう
ikkimiyazaki
6
1k
データの品質が低いと何が困るのか
kzykmyzw
6
1.1k
ホワイトボードチャレンジ 説明&実行資料
ichimichi
0
130
速くて安いWebサイトを作る
nishiharatsubasa
11
13k
プロダクトエンジニア構想を立ち上げ、プロダクト志向な組織への成長を続けている話 / grow into a product-oriented organization
hiro_torii
1
220
Featured
See All Featured
Mobile First: as difficult as doing things right
swwweet
223
9.3k
The World Runs on Bad Software
bkeepers
PRO
67
11k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Automating Front-end Workflow
addyosmani
1368
200k
Adopting Sorbet at Scale
ufuk
74
9.2k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
30
2.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
348
20k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
7k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
410
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
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/