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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Christoph Lühr
February 06, 2018
Technology
12k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Swoole in 5 Minutes [en]
Blazingly-Fast, Event-Driven, Asynchronous PHP. Berlin PHP Usergroup 02/06/2018
Christoph Lühr
February 06, 2018
More Decks by Christoph Lühr
See All by Christoph Lühr
Vektor-Suche & LLMs
chluehr
0
140
Search, Embeddings & Vector-DBs
chluehr
0
170
Reality Check: Automated Content Production at Enterprise Scale with Pimcore
chluehr
0
96
The how and why of getting Freelancers
chluehr
0
84
Content & Master Data Management with Pimcore
chluehr
1
750
Master Data Management with Pimcore
chluehr
0
230
PIM & Master Data Management with Pimcore 5 [en]
chluehr
2
330
Digital Transformation & Master Data Management with Pimcore 5
chluehr
0
270
LXD System Containers [en]
chluehr
0
380
Other Decks in Technology
See All in Technology
Claude Code の Sandbox 機能を Anthropic Sandbox Runtime(srt) で試そう!/lets-play-anthropic-sandbox-runtime
tomoki10
1
530
脆弱性対応、どこで線を引くか
rymiyamoto
0
360
自律型AIエージェントは何を破壊するのか
kojira
0
150
2026TECHFRESH畢業分享會 - Lightning Talk - 打造精準高效的 MCP 設計模式與測試實務
line_developers_tw
PRO
0
750
Snowflakeと仲良くなる第一歩
coco_se
4
410
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
170
小さくはじめるSLI/SLO ~育てながら組織に定着させる実践知~ / Starting Small with SLI/SLOs: Building Adoption Through Continuous Growth
nari_ex
4
1.5k
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
580
Disciplined Vibes: Scaling AI-Assisted Engineering
sheharyar
0
130
ルールやカスタム機能、どう活かす?ハンズオンで体感するIBM Bobの出力コントロール
muehara
1
130
AIの性能が向上しても未解決な組織の重大問題は何か?/An Unsolved Organizational Problem in the Age of AI
moriyuya
3
610
AmazonRoute 53ではじめてのドメイン取得!HTTPS化までの道のりを整理してみた
usanchuu
3
130
Featured
See All Featured
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
730
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
200
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
300
The browser strikes back
jonoalderson
0
1.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Designing Experiences People Love
moore
143
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6k
Automating Front-end Workflow
addyosmani
1370
210k
The Spectacular Lies of Maps
axbom
PRO
1
800
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/