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
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
610
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
340
setup-vp GitLab対応の裏側
naokihaba
0
120
動作中のプログラムの中身をリアルタイムに覗く / Realtime Debugger for CSharp with Roslyn
prota
1
1.2k
Agents on Rails - Rails at Scale 2026
irinanazarova
0
210
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.3k
モジュールの視点からSwiftを読み解く #iosdc
s_shimotori
0
190
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
0
120
マイコン向けの軽量Ruby「PicoRuby」で各種デバイスを制御するネイティブアプリの実現手法
bash0c7
0
440
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
340
速習iPhone Duo対応
yuukiw00w
2
740
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
520
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
510
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
540
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
The SEO identity crisis: Don't let AI make you average
varn
0
560
Joys of Absence: A Defence of Solitary Play
codingconduct
1
530
A designer walks into a library…
pauljervisheath
211
25k
How to Ace a Technical Interview
jacobian
281
24k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
460
My Coaching Mixtape
mlcsv
0
320
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ʹ͝ࢀՃݕ౼͍ͩ͘͞