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
PHP ステートレス VS ステートフル 状態管理と並行性 / php-stateless-s...
Search
yuuki takezawa
February 05, 2025
Programming
0
140
PHP ステートレス VS ステートフル 状態管理と並行性 / php-stateless-stateful
つよナレ #1 PHPにまつわる話
https://techtrain.connpass.com/event/330882/
でのお話です
yuuki takezawa
February 05, 2025
Tweet
Share
More Decks by yuuki takezawa
See All by yuuki takezawa
PHPでアクターモデルを活用したSagaパターンの実践法 / php-saga-pattern-with-actor-model
ytake
0
1.5k
PHPでアクターモデルを理解・体験しよう / Understand and experience the actor model in PHP
ytake
2
500
再考 アクターモデル/ reconsider actor model
ytake
0
1.2k
GoとアクターモデルでES+CQRSを実践! / proto_actor_es_cqrs
ytake
1
450
Phluxorでアクターモデルを 理解・体験しよう / toolkit-for-flexible-actor-models-in-php-phluxor
ytake
1
290
オブジェクトのおしゃべり大失敗 メッセージングアンチパターン集 / messaging anti-pattern collection
ytake
2
1.1k
DRE/SREのプラクティス融合によるクラウドネイティブなデータ基盤作り / dre_sre
ytake
0
820
技術的負債と向き合う取り組みでよかったもの / positive_efforts_to_tackle_technical_debt
ytake
10
3.9k
アプリケーションエンジニアから強いデータエンジニアへの歩き方 / How to transition and become a Data Engineer from an Application Engineer
ytake
1
590
Other Decks in Programming
See All in Programming
VitestのIn-Source Testingが便利
taro28
8
2.3k
複雑なフォームの jotai 設計 / Designing jotai(state) for Complex Forms #layerx_frontend
izumin5210
6
1.4k
GitHub Copilot for Azureを使い倒したい
ymd65536
1
270
By the way Google Cloud Next 2025に行ってみてどうだった
ymd65536
0
110
プロダクト横断分析に役立つ、事前集計しないサマリーテーブル設計
hanon52_
2
500
カオスに立ち向かう小規模チームの装備の選択〜フルスタックTSという装備の強み _ 弱み〜/Choosing equipment for a small team facing chaos ~ Strengths and weaknesses of full-stack TS~
bitkey
1
120
2ヶ月で生産性2倍、お買い物アプリ「カウシェ」4チーム同時改善の取り組み
ike002jp
1
110
UMAPをざっくりと理解 / Overview of UMAP
kaityo256
PRO
2
1.2k
Being an ethical software engineer
xgouchet
PRO
0
230
The Missing Link in Angular’s Signal Story: Resource API and httpResource
manfredsteyer
PRO
0
110
State of Namespace
tagomoris
5
2.2k
Amazon CloudWatchの地味だけど強力な機能紹介!
itotsum
0
210
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
5
550
Building a Scalable Design System with Sketch
lauravandoore
462
33k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
47
2.7k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
14
1.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.6k
How STYLIGHT went responsive
nonsquared
100
5.5k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
For a Future-Friendly Web
brad_frost
177
9.7k
GraphQLの誤解/rethinking-graphql
sonatard
71
10k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
680
Transcript
εςʔτϨε VS εςʔτϑϧ ঢ়ଶཧͱฒߦੑ TechTrain ͭΑφϨ #1 PHPʹ·ͭΘΔ ytake
Pro fi le • ᖒ ༗و a.k.a ytake • ઍגࣜձࣾ
CTO / ΄͔ٕज़ސ • Go / Scala / Kotlin • ΞΫλʔϞσϧɺσʔλج൫ɺDDD·ΘΓɺࢄॲཧͳͲ
ঢ়ଶͱϥϯλΠϜ • ϥϯλΠϜͷҧ͍Λཧղ͓͖ͯ͠·͠ΐ͏ • εςʔτϨε͔εςʔτϑϧ ͲͪΒ͔Ͱͳ྆͘ํ͏·͘ѻ͏ • PHPͰฒߦॲཧΛ͏·͘Δʹঢ়ଶཧ͕ඞཁʂ
PHP • WebΞϓϦέʔγϣϯͱͯ͠ੈքͰͨ͘͞ΜΘΕ͍ͯΔݴޠ • FacebookݩʑPHP / PHPͷݱࡏͷਐԽʹେ͖͘ߩݙ • ͳΜ͔ͩΜͩWordpressҒେ •
WebαʔόͷϞδϡʔϧɺ͘͠࿈ܞͯ͠ಈ͘ࣄ͕ଟ͍
Go • goroutineͱ͍͏ΈΛͬͯฒߦॲཧΛಘҙͱ͢Δݴޠ • γϯάϧόΠφϦͰϓϩηεͱͯ͠ಈ࡞ • ίϯςφͱͷ૬ੑྑ͍ • ΞϓϦέʔγϣϯαʔόͱͯ͠ػೳʢWebαʔόෆཁʣ
Scala • ScalaؔܕϓϩάϥϛϯάͱΦϒδΣΫτࢦ • ޮతͳฒߦॲཧΛαϙʔτ͢ΔFutureͳͲ • σʔλॲཧܥେنͳΈΛࢧ͑Δ͜ͱ͕ଟ͍ • ΞϓϦέʔγϣϯαʔόͱͯ͠ػೳʢWebαʔόෆཁʣ
ͦͦฒߦͬͯʁ • ฒྻ"શʹಠཱ"ͯ͠ϦιʔεΛফඅ͢Δͷ • ฒߦϦιʔεΛڞ༗͠ͳ͕Βަޓʹফඅ ॲཧத"ฒྻʹݟ͑Δࣄ͕͋Δ" • PHPͰ؆୯ʹѻ͑ΔͷͦΜͳʹଟ͘ͳ͍
ͦͦฒߦͬͯʁ • खΛୟ͘ͷ͕ऴΘ͔ͬͯΒΛୟ͘ͷ͕ஞ࣍ • खΛୟ͍͍͚ͯͨͲ్தͰΊͯΛୟ͍ͯ ·ͨखΛୟ͘Έ͍ͨͳͷ͕ฒߦ • खͱΛಉ࣌ୟ͘ͷ͕ฒྻ • खΛୟ͖͍ͨͳ͊ͱࢥ͍͔ͬͯͭୟ͘ͷ͕ඇಉظ
• खΛୟͧ͘ʂͰୟ͘ͷ͕ಉظ
େ͖ͳҧ͍ͬͯʁ • PHP HTTPϦΫΤετ͕དྷͨΒͦͷϓϩηεΛ্ཱͪ͛ͯऴྃ • جຊతʹঢ়ଶΛ࣋ͨͣʢ࣋ͯͳ͍ʣɺ ঢ়ଶอ࣋֎෦ʹ͓ئ͍͢ΔΈ • ނʹඇৗʹγϯϓϧ
େ͖ͳҧ͍ͬͯʁ • GoScalaϓϩηεͱͯ͠ಈ࡞͢ΔͨΊɺ ঢ়ଶΛཧ͠ͳ͕ΒޮతʹॲཧΛߦ͏ • ͕ࣗσʔλετϨʔδʹͳΔ͜ͱͪΖΜOK • ϓϩηεͱͯ͠ঢ়ଶΛࣗͰ࣋ͭͨΊɺ ฒߦॲཧͳͲ༰қ
PHPͰฒߦॲཧ͍ͨ͠ɾɾʁ • ผϓϩηεͰىಈͨ͠PHPϓϩηεಉ࢜ͷ ίϛϡχέʔγϣϯ͕͍͠ɾɾ • εϨουతͳͷͳ͍ʢextentionআ͘ʣ • ॏ͍ͨॲཧඇಉظʹ͢Δ͔͠ͳ͍ɾɾ
None
PHPͰඇಉظॲཧ͍ͨ͠ɾɾʁ • QueueͳͲͷϛυϧΣΞΛͬͯ ผϓϩηεɾΞϓϦέʔγϣϯͱͯ͠औΓʹߦͬͯॲཧ • SwooleReactPHPͳͲΛซ༻ͯ͠ؤுΔ • ϓϩηεͱͯ͠ಈ࡞ͤ͞ΔͨΊʹsupervisorͳͲͰཧ͠ͳ͚Εɾ
ॱ൪ • Ͳ͕ͬͪૣ͘ऴΘΔ͔ • ࢄͨ͠ͱ͖ૢ࡞ෆՄ
PHPͰৗ࣌ϓϩηεʹ͢ΔͱϋϚΔͷ • εςʔτϨεલఏͷίʔυΛॻ͘ͱϝϞϦϦʔΫʹɾɾ • ඞཁ͕ͳ͘ͳͬͨมͱʹ͔͘ϝϞϦ͔Βଈղ์͢Δʂ • σʔλϕʔεconnectͱdisconnectΛ͖ͪΜͱཧ͢Δ • ࣋ଓଓ͕ۤखͳͷͰɺphp.iniWebαʔόͷઃఆΛ
GoScalaͰɾɾʁ • ͦͦϙΠϯλεϨουͳͲͰޮతʹॲཧ͢ΔΈ • ΞυϨεʹଓͳͲΛ֬อ͍ͯ͠ճͨ͠Γ͢Δ • ScalaͰΞΫλʔΛར༻ͯ͠ҙਤతʹϦιʔεؔ࿈ૢ࡞Ͱ͖Δ
<?php use Swoole\Http\Server; $server = new Server("127.0.0.1", 9501); $leakyArray =
[]; $server->on("request", function ($request, $response) use (&$leakyArray) { $leakyArray[] = str_repeat("leak", 1000); $tempFile = fopen("/tmp/tempfile", "w"); fwrite($tempFile, "temporary data"); $response->end("Hello World\n"); }); $server->start();
<?php use Swoole\Http\Server; $server = new Server("127.0.0.1", 9501); $leakyArray =
[]; $server->on("request", function ($request, $response) use (&$leakyArray) { $leakyArray[] = str_repeat("leak", 1000); $tempFile = fopen("/tmp/tempfile", "w"); fwrite($tempFile, "temporary data"); $response->end("Hello World\n"); }); $server->start(); ϦΫΤετͷͨͼʹ Ճ
<?php use Swoole\Http\Server; $server = new Server("127.0.0.1", 9501); $leakyArray =
[]; $server->on("request", function ($request, $response) use (&$leakyArray) { $leakyArray[] = str_repeat("leak", 1000); $tempFile = fopen("/tmp/tempfile", "w"); fwrite($tempFile, "temporary data"); $response->end("Hello World\n"); }); $server->start(); Ϧιʔε։์Ε '%͕Ұഋʹɾɾ
None
PHPͰΞΫλʔϞσϧΛཧղɾମݧ͠Α͏ Understand and experience the actor model in PHP phpcon
okinawa 2024 yuuki takezawa a.k.a ytake
γϯάϧτϯ • PHPͷγϯάϧτϯHTTPͷϥΠϑαΠΫϧͷΈͷͷ • PHPͰৗ࣌ϓϩηεͰγϯάϧτϯʹ͢Δͱ ଞͷॴͰॻ͖ࠐ·ΕΔ͜ͱ͋Γɺঢ়ଶมΘΔ • mutexͳͲซ༻͠Α͏ʂ • DIίϯςφ͕ରԠ͍ͯ͠ͳ͍߹ଟ͋Γ
͓·͚ PHP͋Δ͋Δ1 • ޮՌతʹΩϟογϡ͢ΔͨΊʹphpserialize͠Α͏ʂ • ଞݴޠ͔Βར༻Ͱ͖ͳ͍ɾɾ ͔ͭ෮ݩ͠Α͏ͱ͢ΔPHPΞϓϦέʔγϣϯ ಉ͡ΫϥεͳͲΛߏͱ͍ͯ࣋ͬͯ͠ͳ͚ΕͳΒͳ͍ • ଞݴޠͱΓऔΓΛߦ͏߹ϚΠΫϩαʔϏεͰආ͚Α͏ʂ
·ͱΊ • ϥΠϑαΠΫϧϥϯλΠϜͷҧ͍Λཧղ͠·͠ΐ͏ʂ • ݴޠ͕ѱ͍ͷͰͳͯ͘େମ࡞Γํͷ • ͍ΖΜͳݴޠΛ৮ͬͯࣝΛ͚ͭΑ͏ʂ