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
5.1k
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
110
日本PHPカンファレンス2024スタンプラリーとその実装/phpcon-stamprally
koyhoge
1
950
日本の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.4k
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
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
23
10k
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
510
弊社の「意識チョット低いアーキテクチャ」10選
texmeijin
5
23k
Vitest Browser Mode への期待 / Vitest Browser Mode
odanado
PRO
2
1.7k
macOS でできる リアルタイム動画像処理
biacco42
3
1.4k
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
190
qmuntal/stateless のススメ
sgash708
0
120
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
240
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
790
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
330
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
7
420
Featured
See All Featured
Building Applications with DynamoDB
mza
90
6.1k
Documentation Writing (for coders)
carmenintech
65
4.4k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Side Projects
sachag
452
42k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Being A Developer After 40
akosma
86
590k
Visualization
eitanlees
144
15k
Gamification - CAS2011
davidbonilla
80
5k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
How GitHub (no longer) Works
holman
311
140k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
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