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
NewRelicと戦うレガシーPHP
Search
uzulla
March 16, 2022
Programming
0
890
NewRelicと戦うレガシーPHP
意識低いテクです
at: NRUG (New Relic User Group) Vol.2
when: 2022/03/16
by: @uzulla
uzulla
March 16, 2022
Tweet
Share
More Decks by uzulla
See All by uzulla
More Context, Better Code. 既存コードやOAS等をコンテキストとしてLLMに与える事で、よりよいコード生成を行う話
uzulla
1
99
あなたのアプリ、ログはでてますか?あるいはログをだしてますか? (Funabashi.dev用 軽量版)
uzulla
3
170
セッションのトークセッション / Traps for PHP session features in growing web apps
uzulla
2
110
Crafting a Own PHP - ウキウキ手作りミニマリストPHP
uzulla
5
1.9k
例外を投げるのをやめてみないか? あるいは受け入れてみないか? - How to use exceptions other than throwing
uzulla
4
890
PHPerが ISUCONでやるべき事
uzulla
1
830
開発生産性は上がらない - N Ways to Reduce Development Productivity
uzulla
1
220
test is not a job
uzulla
1
480
あなたのPHPアプリ、ログはでてますか?あるいはログをだしてますか? / Are you writing a log? Or just out a log?
uzulla
17
7.4k
Other Decks in Programming
See All in Programming
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
subpath importsで始めるモック生活
10tera
0
300
RubyLSPのマルチバイト文字対応
notfounds
0
120
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Better Code Design in PHP
afilina
PRO
0
120
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
100
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
EventSourcingの理想と現実
wenas
6
2.3k
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
470
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
For a Future-Friendly Web
brad_frost
175
9.4k
The Pragmatic Product Professional
lauravandoore
31
6.3k
GraphQLとの向き合い方2022年版
quramy
43
13k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
BBQ
matthewcrist
85
9.3k
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ʹ͝ࢀՃݕ౼͍ͩ͘͞