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で実装するPHP非同期処理の世界/phpcondo2019-swoole
Search
KOYAMA Tetsuji
September 21, 2019
Programming
3
5k
Swooleで実装するPHP非同期処理の世界/phpcondo2019-swoole
2019-09-21 に開催されたPHPカンファレンス北海道2019で発表した資料です。
KOYAMA Tetsuji
September 21, 2019
Tweet
Share
More Decks by KOYAMA Tetsuji
See All by KOYAMA Tetsuji
全日本PHPカンファレンス2024スタンプラリーについて/stamprally-php2024
koyhoge
0
100
日本PHPカンファレンス2024スタンプラリーとその実装/phpcon-stamprally
koyhoge
1
870
日本のPHPカンファレンスの歩みと、その辺もろもろ/phpcon_japan_history
koyhoge
0
240
Inside SWOOLE: 非同期処理はどのようにして動くのか/inside_swoole
koyhoge
0
18k
映画を年300本観る技術/watch_300_movies_in_a_year
koyhoge
0
1.1k
CloudFormation と FaaS のはざま - Kubernetes の設計思想を探る -/cf-faas-k8s
koyhoge
0
1.3k
ITイベントマニアから見る技術イベントの動向/techevent
koyhoge
0
300
Skaffoldを使ってKubernetes してみた/skaffold_k8s
koyhoge
2
1.2k
東京が大雪の日に何気ない写真がバズった/snow_tree_buzz
koyhoge
0
520
Other Decks in Programming
See All in Programming
Интеграционное тестирование: как приручить хаос
lamodatech
0
560
Cloud Adoption Frameworkにみる組織とクラウド導入戦略(縮小版)
tomokusaba
1
180
perl for shell, awk and sed programmers
mackee
1
680
Introduce dRuby
ledsun
0
100
Kubernetes上でOracle_Databaseの運用を楽にするOraOperatorの紹介
nnaka2992
0
150
Pydantic x Database API:turu-pyの開発
yassun7010
1
560
Infrastructure as Code でセキュリティを楽にしよう!
konokenj
6
1.4k
RemixとCloudflare Stack におけるFile Upload
ossamoon
1
130
ポケモンで考えるコミュニケーション / Communication Lessons from Pokémon
mackey0225
4
170
Vue :: Better Testing 2024
up1
1
400
CSC509 Lecture 02
javiergs
PRO
0
160
What is TDD?
urakawa_jinsei
1
220
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
26
5.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
3
230
Making the Leap to Tech Lead
cromwellryan
131
8.8k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
7
580
How GitHub (no longer) Works
holman
311
140k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Optimising Largest Contentful Paint
csswizardry
31
2.8k
Scaling GitHub
holman
458
140k
10 Git Anti Patterns You Should be Aware of
lemiorhan
653
59k
Why Our Code Smells
bkeepers
PRO
334
57k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
For a Future-Friendly Web
brad_frost
174
9.3k
Transcript
4XPPMFͰ࣮͢Δ 1)1ඇಉظॲཧͷੈք খࢁࢤ !LPZIPHF PHPΧϯϑΝϨϯεւಓ2019 2019-09-21
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ࣗݾհ খࢁࢤ ͜·ͯͭ͡ ߹ಉձࣾ΄ٕ͛ݚ Ϣʔβձ͍͔ͭ͘ ຊ6/*9Ϣʔβձ ຊ1PTUHSF42-Ϣʔβձ
ຊ1)1Ϣʔβձ SBLVNPגࣜձࣾΤϯδχΞ !LPZIPHF LPZIPHF
ʮখࢁ͞Μ ɹͲ͜ʹͰ͍·͢Ͷʯ
ʮͲ͜ʹͰ͍ͳ͍Θɺ ͍Δͱ͜Ζʹ͚ͩʯ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ͯ͞ 4XPPMF
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ʜͷલʹ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ࣮ߦͷԼཁҼ w$16 wϝϞϦ wϩδοΫ wσʔλॲཧྔ w*0
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 *0 w$16ॲཧʹൺΔͱஈҧ͍ʹ͍ wऴྃͪঢ়ଶ wಉظॲཧ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 Gregg, Brendan. “Systems Performance: Enterprise and the Cloud.”
*0Ԇ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ඇಉظ*0 w*0ॲཧͷऴྃΛͨͳ͍ wϒϩοΫ͠ͳ͍ wͦͷؒʹଞͷॲཧΛ͢Δ w*0ॲཧ͕ऴΘͬͨΒͦͪΒʹΔ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 https://twitter.com/php_swoole/status/1060181279407169538
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 1)14XPPMF $PSPVUJOFCBTFEDPODVSSFODZMJCSBSZGPS1)1 https://www.swoole.co.uk/ https://github.com/swoole/swoole-src/ @php_swoole
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 4XPPMFͱ wඇಉظॲཧΛجຊʹͨ͠ߴԽॲཧͷ ٧Ί߹ΘͤϥΠϒϥϦ w͔Β։ൃ wݩӳࠃ5SBOTGPOʹΑͬͯ wݱࡏதࠃݍͷ։ൃऀ͕ʹ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 1)14XPPMF w Φʔϓϯιʔε "QBDIFϥΠηϯε w 1)1&YUFOTJPO w
$$ #PPTU$POUFYU w ίʔϧόοΫίϧʔνϯ w Πϕϯτۦಈͷඇಉظ*0 w )551)5518FC4PDLFU5$16%1 w ϚΠΫϩඵλεΫεέδϡʔϥ w ϓϩηεϚωʔδϟ w ϓϦΤϯϓςΟϒεέδϡʔϦϯά
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 Πϯετʔϧ $ pecl install swoole extension=swoole.so ZPVSJOJ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ࠷ॳͷҰา $ php co.php start coro 1 start
to resume 1 @1 resume coro 1 @1 start to resume 1 @2 resume coro 1 @2 main
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ղઆ w4XPPMFa$PSPVUJOFʹ$Pͱ͍͏ΤΠϦ Ξε͕͍͍ͭͯΔ w࠷ॳͷVTFจͳͯ͘ಈ͘ w1)1Ϋϥε໊ͷେখจࣈ۠ผ͠ͳ͍ wHP 4XPPMFa$PSPVUJOFDSFBUF ͷΤ
ΠϦΞε
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ղઆ wDPZJFME ॲཧΛҰ୴தஅ͢Δ wDPSFTVNF ର͕ZJFME ͢Δ·Ͱϒϩο Ϋ͢Δ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 4XPPMFίϧʔνϯ w4XPPMFͷඇಉظॲཧͷࠜװ wதஅ࠶։Ͱ͖Δॲཧ୯Ґ w4XPPMFͰγϯάϧεϨουͰ࣮ ͞Ε͍ͯΔ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 swoole-src/include/coroutine.h ࣮ͷத֩෦
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ίϧʔνϯྫ $ php co2.php write...: data/00.out write...: data/01.out
write...: data/02.out write...: data/03.out write...: data/04.out write: data/00.out done write: data/01.out done write: data/02.out done write: data/03.out done write: data/04.out done
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 EFGFS wίϧʔνϯͷऴྃॲཧ wίϧʔνϯ͕FYJU͢Δ·Ͱ࣮ߦ͞Εͳ ͍ w࠷ޙʹݺΕͨEFGFS͔Βٯॱʹ࣮ߦ ͞ΕΔ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 EFGFSͷྫ $ php defer.php abc~b~a
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 DIBO wνϟϯωϧΛ࡞͢Δ wίϧʔνϯؒͷϝοηʔδड͚͠
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 DIBOͷྫ
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 https://speakerdeck.com/team/swoole-4-introducing-the-new-coroutine-design-pattern-in-php?slide=26
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 4XPPMF4FSWFS w)551 w)551 w8FC4PDLFU w5$16%16OJY4PDLFU w3FEJT
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 )5514FSWFS
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 5$14FSWFS
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 ·ͱΊ w4XPPMF1)1ߴԽͷ৽͍͠ํੑ wඇ࿈ଓతਐԽ w׆ൃʹ։ൃ͞Ε͍ͯΔ༷ࢠΛோΊ͍ͯ Δ͚ͩͰָ͍͠ wʮ1)1Ͱ͜͜·ͰͰ͖Δʯͱূ໌ͨ͠ ͜ͱʹܟҙΛධ͍ͨ͠
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 એ w ݄ʹٕज़ධࣾΑΓʮΈΜͳͷ1)1ʯ͕ग़·͢ w 1)1ΛςʔϚʹͨ͠ϜοΫ w ϖʔδલޙ w
Ձ֨ະఆ w 4PGUXBSF%FTJHO݄߸ ൃച w λΠΞοϓಛू1 w 8&# %#13&44WPM ൃച w 4XPPMFʹؔ͢ΔλΠΞοϓهࣄ1
PHPΧϯϑΝϨϯεւಓ2019 2019-09-21 3FG w IUUQTTXPPMFDPVL w IUUQTHJUIVCDPNTXPPMFTXPPMFTSD w IUUQTTQFBLFSEFDLDPNUFBNQSFFNQUJWF NVMUJUBTLJOHVTJOHDPSPVUJOFTJOQIQTXPPMF
w IUUQTTQFBLFSEFDLDPNUFBNTXPPMF JOUSPEVDJOHUIFOFXDPSPVUJOFEFTJHOQBUUFSOJO QIQ