Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
NewRelicと戦うレガシーPHP
Search
uzulla
March 16, 2022
Programming
1.1k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
NewRelicと戦うレガシーPHP
意識低いテクです
at: NRUG (New Relic User Group) Vol.2
when: 2022/03/16
by: @uzulla
uzulla
March 16, 2022
More Decks by uzulla
See All by uzulla
ALL CODE BASE ARE BELONG TO STUDY
uzulla
30
7.9k
バイブスあるコーディングで ~PHP~ 便利ツールをつくるプラクティス
uzulla
1
610
PHPer's Guide to Daemon Crafting Taming and Summoning
uzulla
2
2.9k
似たもの同士のPerlとPHP
uzulla
1
320
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
240
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
340
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
240
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
3.4k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
6
1.5k
Other Decks in Programming
See All in Programming
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
120
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5k
The Good Stuff, Not the Slop: Engineering High-Quality Android Apps with Modern AI Tooling
danybony
1
260
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
210
すこし踏み込む CancellationToken
htkym
2
960
Omarchy Tokyo やると聞いて UMPC 買ってセットアップしてきた
mtsmfm
0
160
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
240
海上で動くGoサーバー: goroutineとchannelでさばく航行データストリーム
atsuki_seo
0
920
速習iPhone Duo対応
yuukiw00w
2
720
Verilogで学ぶCPU自作入門.pdf
uyuki234
6
2.7k
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.2k
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
570
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
600
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Odyssey Design
rkendrick25
PRO
2
810
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Test your architecture with Archunit
thirion
2
2.4k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
470
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
300
Thoughts on Productivity
jonyablonski
76
5.4k
The untapped power of vector embeddings
frankvandijk
2
1.9k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
340
Designing Powerful Visuals for Engaging Learning
tmiket
1
580
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Transcript
NewRelicͱઓ͏ ϨΨγʔPHP at: NRUG (New Relic User Group) Vol.2 when:
2022/03/16 by: @uzulla
ࣗݾհ • uzulla • ϑϦʔͷPHPΤϯδχΞ • N+1ࣾͷMՕॴͷݱͰՔಇத • ྫ PR
TIMES ͞Μ
:͜ͷτʔΫಛఆͷاۀʹ͍ͭͯޠ͍ͬͯ·ͤΜ • ࢲݱࡏਐߦͰɺNࣾ x MݱͰՔಇத • աڈͷݱ֮͑ͯ͢Βډͳ͍ • ͨͩ͠ɺ৭ʑͳݱͰࣅ͍ͯΔ͜ͱ͋Δ
ࣗࣾհͱ͔ͳ͍ΜͰએ • PHPerKaigi 2022 • PHPͳํͥͻ • PR TIMESͷਓؒొஃ͠·͢
NewRelic ❤ PHP • ϙϯͱ(ϛυϧΣΞతʹ)͍ΕΔ͚ͩͰಈ͘ • ύοʂͱ֎ͤΔ • ຊ൪ʹೖΕ͓͚ͯΔ΄ͲੑೳྼԽ͍ •
Τϥʔɾྫ֎͕͍͍ײ͡ʹϦΞϧλΠϜूܭ • = ࠷ߴʂ
ࢲͱNewRelic • ׂͱੲ͔Βɺ͔ͭͣΕͣϢʔβʔ • ʮ͓٬༷͕͍Εͯ͘ΕΔ͔ʯ࣍ୈ • ʢ·͋ɺ͝༧ࢉ͋ΔΑͶ…Θ͔Δ…ʣ • ͨͱ͑PR TIMES͞ΜೖΕͯ͘ΕͯΔ
• ʮ͑ͯϥοΩʔʂʂʯ
ࣗෲ()ͱͷ૬ੑͷΑ͞ • ༧ࢉग़ͳ͍͕ɺ͍͍ͬͯͱ͍͏ݱ͋Δ • ͢Δͱɺ֎͍͢͜͠ͱॏཁͰ͢ΑͶ… • PHP + NewRelic֎͍͢͠ʂ •
(ίʔυʹೖΕͳͯ͘ྑ͍ͷͰ) • ISUCONͱ͔ͰɺඵͰ֎ͤΔͷͰ͑Δ
ͯ͞ɺϨΨγʔPHP • ݹ͍ίʔυϕʔεͷPHP • PHP<=7…PHP<=5… • ࠷ۙPHP8ະຬΛΔ͕࣌ͩʢྫ: Laravel9ʣ NewRelicͪΌΜͱಈ͘ʢخʣ
ϨΨγʔPHPͱઓ͏Έ • ੵΈॏͳͬͨෛ࠴ίʔυ • error_reporting, display_errors=offͰݱ࣮ಀආ • ΤϥʔϩάΛݟͯͳ͍ʢ݁ߏଟ͘ͷݱʣ • ͱ͍͏͔ɺϩά͕ࣺͯΒΕ͍ͯΔ
• ͋;ΕΔNotice, WarningΤϥʔ
NewRelicͳΒʂ • ΤϥʔϩάΛಠࣗʹरͬͯूܭͯ͘͠ΕΔʂ • ͳʹ͠ͳͯࣗ͘ಈతʹϝτϦοΫʹ • ελοΫτϨʔε͖ʂ • ಉ͡ΤϥʔΛྨʂ •
Error Inbox͔Βर͚ͬͯͩ͢Ͱվળ͞ΕΔ • ෳͰtail -f͠ͳ͍͍ͯ͘ͷָʂ()
NewRelicΛΘͳ͍߹… • ϩάج൫…fluentd…kibana… • ूܭɾϝτϦΫε… • ϩʔςʔγϣϯ…DiskFull… • ෛՙ… •
༨ͳαʔόʔӡ༻… • etc,etc... େมͩͶ…
ͯ͞ຊ • ʮϦϑΝΫλϦϯά͍ͨ͠ʂʯ • ͦͼཱ͑ͭϨΨγʔ • ʮσουίʔυΛ҆શʹফ͍ͨ͠ʯ • ʮͰɺຊʹࢮΜͰΔͷ͔ͳ…ʯ
ʮͦΕɺNRͰ؆୯ʹऩूͰ͖ΔΑʂʯ
E_USER_WARNING()Λ͏ trigger_error( "This code is NOT DEAD", E_USER_WARNING ); •
https://www.php.net/manual/ja/function.trigger-error.php • ϢʔβʔϨϕϧͷΤϥʔ/ܯࠂ/௨ϝοηʔδΛੜ͢Δ
None
None
Error InboxʹΨϯΨϯ͍ͬͯ͘Δ • (ͪΖΜϑΟϧλͰ͖Δ)
ิɿE_USER_*ͱʁ • PHPʹྫ֎ʹࣅͨ(?) ผͷΤϥʔػߏ͕͋Δ • DBଓࣦഊE_WARNINGͱ͔ɺΑ͘Έ·͢ΑͶʢനʣ • E_USER_* ɺϢʔβʔ͕ൃߦͰ͖ΔΤϥʔܕ •
DEPRECATED, NOTICE, WARNING, ERROR,ͷ4छ • WARN·Ͱ࣮ߦ͕ࢭ·Βͳ͍ (͜ͱ͕׆༻ͷϛι̍) • display_errors=offͰӅͤΔ (͜ͱ͕׆༻ͷϛι̎)
ո͍͠ॴʹೖΕ·͘Δ͚ͩ • ෛՙͰ • ར༻ॴ͕Θ͔Δ • ूܭࣗಈతʹ͞ΕΔ • ຊʹফ͔ͤͨλΠϜϥΠϯͰΘ͔Δ •
શ෦͕Θ͔Δɻͦ͏ɺNewRelicͳΒͶ
͞Βʹݴ͑ • ༷ʑͳཧ༝ͰσϓϩΠͰ͖ͳ͍߹Ͱ… • ී௨ͷPHPͳΒɺຊ൪ʹsshͯ͠ɺ viͯ͠ίʔυΛͿͬ͢·ͰͰ͖Δ ʢίϨͰͬͯΔΘ͚Ͱͳ͍Ͱ͢ʂʂʣ
ͬͱͬͱ׆༻!!!!! • ༷ʑͳ݅ͰಈతʹൃߦͰ͖Δɻ ͨͱ͑ifͰʮ͋Γ͑ͳ͍ݕʯൃՐͰ͖Δ if(!in_array($type, $allow_type_list)){ trigger_error("OOB!!", E_USER_WARNING); }
• REQUEST_URIΛਖ਼نදݱͰҾֻ͚ͬΔͱ͔Α͍ if(preg_match( "|\A/v0.1/old_api/|u", $_SERVER['REQUEST_URI'] ){ trigger_error("deprecated...",E_USER_WARNING); }
• ʮഇࢭ͞Εͨύϥϝλ͕͋Δʯͱ͔ʁ • php.iniͷauto_prepend_fileΛ׆༻͢Δͱָ͔ if(isset($_GET['session_id'])){ trigger_error("OMG!!",E_USER_WARNING); }
ເ͕͕Δʂʂ • (ී௨ͷߦҝͰͳ͍Ͱ͢Ͷɺ͍)
ޙย͚ • શจݕࡧͰফͤOK • (E_USER_WARNINGͱ͔ී௨͔ͭΘͳ͍ͷͰ…) • Ծʹ͍ͬͯͯΤϥʔϩάʹग़Δ͔Β୳ͤΔ͠ɺ ѱӨڹͳ͍
ͱ͍͏͜ͱͰ(?)PHPʹNewRelic࠷ߴʂ • ݹ͍PHPݱͦ͜ɺඞܞ • ͱʹ͔͘ೖΕͯɺͲΜͲΜίʔυվળ • ύϑΥʔϚϯενϡʔχϯά͚ͩͰͳ͍ʂ • (ɺࣗಈతʹ࣮ߦαϯϓϧͯ͠վળ) •
Error Inbox ͚ͩͰศརʂ
Ҏ্ʂ
ҟৗͳཁ • ϨϯαόΈ͍ͨͳͷͰ͏͍ͯ͝΄͍͠ͳ • ʢREST APIΛ͖ͨͨ·͘ΕͰ͖Δ…ʁʣ • ʮdl("newrelic.so")Ͱ͏͍ͨ͝Γ͠ͳ͍͔ͳ…ʯ • ʢҟৗͳཁͩͱཧղ͍ͯ͠·͢ʣ
• ʮPHPʹৄ͍͠ʯNRͷਓ ͱͯ͠Έ͍ͨ͆
ΏΔ͍ئ • (ʮ͘͝Ұൠతͳ͓٬༷ʯʹ͓͍ͯ…ʣ • ʮͰɺ͜Ε͍͘Β͔͔Δͷʁʯ • Ͱɺ༧ࢉ͕ΊͣɺೖΕΒΕͳ͍͜ͱ͕ଟ͍… • ʢࢼࢉ͕͍͠ʣ •
!
I ❤ NewRelic • NRͱPHPΛτϦοΩʔʹͬͯΔਓͱΓ߹͍͍ͨ • ࠷ޙʹɺPHPͳਓPHPerKaigiʹ͝ࢀՃݕ౼͍ͩ͘͞