Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ロリポップ!で目指す PHPのためのセキュリティと性能要件を 同時に満たすサーバホスティング技術 / loli-next

ロリポップ!で目指す PHPのためのセキュリティと性能要件を 同時に満たすサーバホスティング技術 / loli-next

PHP実行基盤の高速化・セキュリティ・省メモリ・ペパボKernel

MATSUMOTO Ryosuke

May 21, 2016
Tweet

More Decks by MATSUMOTO Ryosuke

Other Decks in Technology

Transcript

  1. 1)1࣮ߦج൫ͷߴ଎ԽɾηΩϡϦςΟɾলϝϞϦɾϖύϘ,FSOFM
    2016/05/21 PHPΧϯϑΝϨϯε෱Ԭ2016
    ϩϦϙοϓʂͰ໨ࢦ͢
    1)1ͷͨΊͷηΩϡϦςΟͱੑೳཁ݅Λ
    ಉ࣌ʹຬͨ͢αʔόϗεςΟϯάٕज़
    GMOϖύϘגࣜձࣾ
    γχΞɾϓϦϯγύϧΤϯδχΞ
    MATSUMOTO, Ryosuke
    @matsumotory

    View full-size slide

  2. ࣗݾ঺հ
    (.0ϖύϘגࣜձٕࣾज़ج൫νʔϜ
    γχΞɾϓϦϯγύϧΤϯδχΞ
    দຊ྄հ!NBUTVNPUPSZ
    ઐ໳͸Πϯλʔωοτͱӡ༻ٕज़
    શࣾతʹ৽ٕज़ͷԠ༻΍৽نݚڀɾ։ൃΛ୲౰
    IUUQSFTFBSDINBUTVNPUPSKQ

    View full-size slide

  3. ໨࣍
    ߴूੵϗεςΟϯάαʔϏε
    1)1࣮ߦج൫ͷηΩϡϦςΟͱੑೳͷཱ྆
    1)1࣮ߦج൫ͷϝϞϦޮ཰Խ
    1)1࣮ߦج൫҆ఆԽͷͨΊʹϖύϘ,FSOFMར༻
    ·ͱΊ

    View full-size slide

  4. ߴूੵϗεςΟϯάαʔϏε

    View full-size slide

  5. ϗεςΟϯάαʔϏεͷಛ௃
    ࣄۀऀ͸͓٬༷ͷ8FCίϯςϯπΛ੍ޚͰ͖ͳ͍
    ϛυϧ΢ΣΞɾ04Ͱ੍ޚ͢Δඞཁ͕͋Δ
    ڞ༗ͷ৔߹͸Ϧιʔε੍ޚ΍ηΩϡϦςΟ͕ॏཁ
    ಛʹੑೳͱ͍͔ʹόϥϯεΛͱΔ͔
    ฐࣾͰ͸௒ߴूੵͷڞ༗ϗεςΟϯάʹ߆͍ͬͯΔ

    View full-size slide

  6. ͳͥߴूੵʹͩ͜ΘΔͷ͔

    View full-size slide

  7. ݸਓ޲͚αΠτத৺
    ໿ສαΠτΛӡӦ
    ֶੜ΍ओ්ͩͬͨΓݸਓ͕झຯͰ࢖͏༻్
    ϋʔυ΢ΣΞʹͲΕ͚ͩߴूੵͰ͖Δ͔ʹ௅ઓ
    ͱʹ͔҆͘͘ੑೳͷྑ͍΋ͷΛఏڙ͍ͨ͠
    ιϑτ΢ΣΞʹΑΔٕज़ྗʹΑͬͯղܾՄೳ

    View full-size slide

  8. 8FCαʔόͷΞʔΩςΫνϟ

    View full-size slide

  9. ϓϩηε਺ͱऩ༰αΠτ਺
    ϝϞϦ͸(#Ͱ$16ίΞ͸ݸ
    αΠτ਺Λ਺ສ͔ΒສαΠτͰऩ༰
    ϓϩηε਺͕αΠτ਺ʹґଘ͠ͳ͍Α͏ͳߏ੒
    ෳ਺αΠτڞ༗ͷIUUQEϓϩηε͕ϦΫΤετ͞Εͨϗετ
    ໊͔ΒಈతʹίϯςϯπΛݕग़ͯ͠ॲཧʢ7JSUVBM)PTU˞
    ʣ
    ˞IUUQIUUQEBQBDIFPSHEPDTDVSSFOUFOWIPTUT

    View full-size slide

  10. IUUQE
    ߴूੵͷͨΊͷΞʔΩςΫνϟ
    IUUQEϓϩηεݸºສສϓϩηεʢϢʔβݸผʹϓϩηεىಈʣ
    IUUQEϓϩηεݸ͙Β͍ͷԾ૝ϗετͰશϢʔβڞ༗
    Ϣʔβ"
    IUUQE
    Ϣʔβ#
    IUUQE
    Ϣʔβ$
    IUUQE
    Ϣʔβ"
    Ϣʔβ#
    Ϣʔβ$
    ޮ཰ྑ͘࢒ϦιʔεΛ࢖͑Δ
    ىಈʹඞཁ
    ͳϦιʔε
    ىಈʹඞཁ
    ͳϦιʔε
    ىಈʹඞཁ
    ͳϦιʔε
    ىಈʹඞཁͳϦιʔε
    04 04

    View full-size slide

  11. ߴूੵͷͨΊͷ
    ΞʔΩςΫνϟͷ՝୊

    View full-size slide

  12. ηΩϡϦςΟͱੑೳͷཱ྆
    ϗεςΟϯάͷಛੑ্Ϣʔβຖʹݫີʹݖݶ෼཭
    ߴूੵ؀ڥͷ1)1ͷݖݶ෼཭ͷੑೳͷޮ཰Խ
    ୯ҰͷBQBDIFݖݶͰىಈ͍ͯ͠ΔϓϩηεͰηΩϡϦ
    ςΟͱੑೳΛཱ͍͔྆ͭͭ͠ʹద੾ʹݖݶ෼཭͢Δ͔

    View full-size slide

  13. ֶज़ݚڀͷΞϓϩʔνͰ
    ৽ٕज़Λ։ൃɾಋೖ

    View full-size slide

  14. 1)1࣮ߦج൫ͷ
    ηΩϡϦςΟͱੑೳͷཱ྆

    View full-size slide

  15. ߴूੵʹ͓͚Δ1)1ͷݖݶ෼཭
    TV&9&$͸ϦΫΤετຖʹϓϩηεੜ੒ഁغ͕ඞཁͰ஗͍
    'BTU$(*͸Ϣʔβ਺ʹԠͯ͡ϓϩηε਺ͱϝϞϦྔ૿Ճ
    NPE@SVJE΍TVJE͸ੑೳɾηΩϡϦςΟ໘Ͱ໰୊͋Γ˞

    ݖݶ෼཭ͷͨΊͷίετΛͲ͏Լ͛Δ͔
    େن໛ߴूੵͷͨΊͷݖݶ෼཭ΞʔΩςΫνϟݕ౼
    ˞দຊ྄հ Ԭ෦णஉ εϨου୯ҐͰݖݶ෼཭Λߦ͏8FCαʔόͷΞΫηε੍ޚΞʔΩςΫνϟ ిࢠ৘ใ௨৴ֶձ࿦จࢽ
    7PM+# /P QQ 0DU

    View full-size slide

  16. NPE@QSPDFTT@TFDVSJUZ
    "QBDIFͷεϨου୯ҐͰݖݶ෼཭ΞʔΩςΫνϟ˞

    NPE@QIQͳͲͷݖݶ෼཭Λߴ଎ʹߦ͑Δ
    ϦΫΤετ࣌ͷݖݶ෼཭ͷίετΛ௿ݮ
    ϓϩηεੜ੒ഁغ͔ΒεϨουੜ੒ഁغ΁
    ˞দຊ྄հ Ԭ෦णஉ εϨου୯ҐͰݖݶ෼཭Λߦ͏8FCαʔόͷΞΫηε੍ޚΞʔΩςΫνϟ ిࢠ৘ใ௨৴ֶձ࿦จࢽ
    7PM+# /P QQ 0DU
    IUUQTHJUIVCDPNNBUTVNPUPSNPE@QSPDFTT@TFDVSJUZ

    View full-size slide

  17. $(*QSPDFTT
    PXOFSVTFS

    $(*QSPDFTT
    PXOFSSPPU

    QIQDHJJOEFYQIQ
    PXOFSVTFS

    $(*QSPDFTT
    PXOFSVTFS

    TFUVJE
    TFUHJE
    ʜ
    GPSL

    FYFDWF
    TVFYFDQSPHSBN TFUVJESPPU

    UFSNJOBUFQSPDFTT
    FYFDWF

    1BSFOUIUUQEQSPDFTT
    PXOFSSPPU

    $IJMEIUUQEQSPDFTT
    PXOFSBQBDIF

    ˞$(*TV&9&$NPEFM

    View full-size slide

  18. εϨουͱ-JOVY$BQBCJMJUZ
    ਌ϓϩηε͔Βݖݶ෼཭ͷDBQBCJMJUZ DBQ
    ͷΈΛҾ͖ܧ͙
    ಈతίϯςϯπ࣮ߦલʹεϨουΛ࡞Δ
    εϨου্ͰݖݶมߋޙʹDBQΛམͱͯ͠ίϯςϯπ࣮ߦ
    7JSUVBMJOH˞
    Λ࢖ͬͯɺ"QBDIFͦͷ΋ͷΛ֤छಛݖΛམͱ
    ͭͭ͠3FBEPOMZͷCJOEϚ΢ϯτͱඞཁϑΝΠϧͱϦιʔ
    ε੍ݶԽͷDISPPU؀ڥʹͯىಈͤ͞Δ͓ͯ͘ͱΑΓڧݻ
    ˞IUUQTHJUIVCDPNNBUTVNPUPSNSVCZWJSUVBMJOH

    View full-size slide

  19. 1BSFOUIUUQEQSPDFTT
    PXOFSSPPU

    $IJMEIUUQEQSPDFTT
    PXOFSBQBDIF

    NQTUISFBE
    PXOFSVTFS

    NQTUISFBE
    PXOFSBQBDIF

    JOEFYQIQ
    PXOFSVTFS

    TFUVJE
    TFUHJE
    ʜ VOTFUDBQT
    DSFBUFUISFBE TFUDBQT
    EFTUSPZUISFBE
    QBSTF SVO
    QSDUM
    TFUVJETFUHJEDBQT
    NQTUISFBE
    PXOFSVTFS

    ˞%40NPE@QSPDFTT@TFDVSJUZNPEFM
    7JSUVBMJOH&OWJSPONFOU

    View full-size slide

  20. γεςϜίʔϧͷ਺
    QIQJOGP
    ΁ͷΞΫηεΛTUSBDF͔Βղੳ˞

    $(*TV&9&$ճ
    NPE@QIQNPE@QSPDFTT@TFDVSJUZճ
    ΦʔόʔϔουʹͳͬͯΔγεςϜίʔϧ˞

    DMPOF
    PQFO
    DMPTF
    FYFDWF
    ͳͲͳͲ
    ˞TUSBDFDGQ1*%
    ˞DBUDHJMPHcHSFQWFQPMM@XBJUcHSFQWGVUFYcQFSMBOF
    QSJOU@JG

    View full-size slide

  21. ͦͷଞͷϝϦοτ΋͋ͬͨ
    ෛՙ͕େ෯ʹ௿ݮʢ1)1ར༻ऀ͕ଟ਺ʣ
    ϩʔυΞϕϨʔδʹͳΔΑ͏ͳΞΫηε͕ҎԼ
    ࠓ͸$(*ͱ%40ͷڞଘ͍ͯ͠Δঢ়ଶ
    %40ઐ༻ʹ͢Ε͹΋ͬͱऩ༰ޮ཰্͕͕Δ

    View full-size slide

  22. ಋೖલޙͷ$16࢖༻ྔൺֱ
    Ұ೔ͷΞΫηε਺͸ͲͪΒͷαʔό΋໿ສʢαʔϏεશମͰ͸਺ेԯʣ
    $(*ʴTV&9&$ %40ʴNPE@QSPDFTT@TFDVSJUZ
    ˙TZTUFN
    ˙VTFS
    ˙JEMF

    View full-size slide

  23. ͞Βʹ҆͘ɺ͞Βʹߴੑೳ΁

    View full-size slide

  24. 1)1࣮ߦج൫ͷϝϞϦޮ཰Խ

    View full-size slide

  25. ϩϦϙοϓʂ͸௒ߴूੵ
    ͱʹ͔͘ϓϩηεΛઅ໿͍ͨ͠
    ͱʹ͔͘ϝϞϦΛઅ໿͍ͨ͠
    NPE@QIQ݁ߏϝϞϦΛ৯͏
    ಛʹϓϩηεͷ13*7"5&ͳϝϞϦ͸અ໿͍ͨ͠

    View full-size slide

  26. NFNPSZ@MJNJUʹΑΔ੍ݶ
    NFNPSZ@MJNJUͰ13*7"5&ϝϞϦ͸੍ݶͰ͖Δ͕ʜ
    1)1࣮ߦޙʹ13*7"5&ϝϞϦ͕ཷ·Δͷ͕໰୊
    NFNPSZ@MJNJUΛԼ͛Δͱ͓٬༷͕໎࿭
    NFNPSZ@MJNJU͸े෼ʹ͋Δ͕࣮ߦޙʹ͸࢖͍ͬͯ
    ͳ͍13*7"5&ϝϞϦΛݮΒ͢ʹ͸Ͳ͏͢Ε͹Α͍͔

    View full-size slide

  27. ;&/%@..@4&(@4*;&
    ϝϞϦϒϩοΫΛׂΓ౰ͯΔࡍͷηάϝϯταΠζ
    ॲཧޙʹϝϞϦ͕ແବʹ࢒Δύλʔϯ͕͋Δ
    ׂ౰ͯྔΛνϡʔχϯάͯ͠࢒Βͳ͍Α͏ʹͰ͖Δ
    ৚͕݅߹͑͹େ͖ͳޮՌ͕ಘΒΕΔ͸ͣ
    ίʔυΛݟΔݶΓ؀ڥม਺Ͱ੍ޚՄೳ

    View full-size slide

  28. NPE@QIQىಈ࣌
    PID VSZ RSS PRIVATE SHARED[KB]
    10280 51188 49824 128 49696 ( 99%)
    10281 51188 49824 124 49700 ( 99%)
    10282 51188 49824 124 49700 ( 99%)
    10283 51188 49824 124 49700 ( 99%)
    10284 51188 49824 124 49700 ( 99%)
    10285 51188 49824 124 49700 ( 99%)
    10286 51188 49824 124 49700 ( 99%)
    10287 51188 49824 124 49700 ( 99%)
    10288 51188 49824 124 49700 ( 99%)
    IUUQTHJUIVCDPNIJSPTFTIBSFENFNPSZTJ[F

    View full-size slide

  29. σϑΥϧτʢ81ΞΫηεޙʣ
    PID VSZ RSS PRIVATE SHARED[KB]
    10281 125628 67372 18428 48944 ( 72%)
    10282 125628 67368 18400 48968 ( 72%)
    10286 125628 67368 18400 48968 ( 72%)
    10291 125628 67368 18400 48968 ( 72%)
    10293 125628 67368 18400 48968 ( 72%)
    10294 125628 67368 18400 48968 ( 72%)
    10300 125628 67368 18400 48968 ( 72%)
    10301 125628 67368 18400 48968 ( 72%)
    10303 125628 67368 18400 48968 ( 72%)
    8PSE1SFTTͷॲཧޙͷ13*7"5&ͷϝϞϦ֬อྔ͸.#

    View full-size slide

  30. νϡʔχϯάޙʢ81ΞΫηεޙʣ
    PID VSZ RSS PRIVATE SHARED[KB]
    20908 129212 55076 6108 48968 ( 88%)
    20909 129212 55076 6108 48968 ( 88%)
    20910 129212 55076 6108 48968 ( 88%)
    20911 129212 55076 6108 48968 ( 88%)
    20912 129212 55076 6108 48968 ( 88%)
    20913 129212 55076 6108 48968 ( 88%)
    20914 129212 55076 6108 48968 ( 88%)
    20915 129212 55076 6108 48968 ( 88%)
    20916 129212 55076 6108 48968 ( 88%)
    ϓϩηεͰ13*7"5&Λ.#࡟ݮɺϓϩηεͩͱ(#ͷ࡟ݮ

    View full-size slide

  31. ͓٬༷ͷϝϞϦΛ੍ݶ͢Δ͜
    ͱͳ͘1)1ଆͰઅ໿͕Ͱ͖ͨ

    View full-size slide

  32. 1)1࣮ߦج൫҆ఆԽͷͨΊ
    ϖύϘ,FSOFMར༻

    View full-size slide

  33. 1)1͕LFSOFMΛ௒͑ͨ೔

    View full-size slide

  34. USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
    apache 10241 55636314 0.0 0 0 ? R 12:36 21115121:16 [httpd]

    View full-size slide

  35. ϖύϘ,FSOFM
    ,FSOFMܥͷDHSPVQͰ͸,FSOFMύχοΫ΍ϋϯάසൃ
    $16ສͷQIQͷLFSOFMεϨου ͷ༷ʹݟ͑Δʣ
    ࡴͤͳ͍ɺIBMUͰ͖ͳ͍ɺϋʔυϦηοτ͢Δ͔͠ͳ͍
    $FOU04ʹ,FSOFMܥϕʔεͷϖύϘ,FSOFMΛಋೖ
    .BDͰ΋ಈ͘,FSOFMͷSQNϏϧυγεςϜ։ൃ
    IUUQTHJUIVCDPNNBUTVNPUPSLFSOFMCVJMETZTUFNGPSDFOUPT

    View full-size slide

  36. ಛఆͷ1)1͕๫૸ͨ͠Γ੬ऑͰ͋ͬͯ΋
    ଞϗετʹඃ֐͕Ͱͳ͍Α͏ʹ͖ͪΜͱ੍ޚ

    View full-size slide

  37. ͥͻϩϦϙοϓʂͷ1)1Λ
    ࢖ͬͯԼ͍͞
    IUUQTMPMJQPQKQ

    View full-size slide

  38. ϖύϘɾ͸ͯͳٕज़େձ։࠵
    ओʹ8FCαʔϏεاۀʹڵຯͷ͋Δֶੜ޲͚
    ژ౎ͱ෱ԬͰि࿈ଓͰ։࠵ʢͱʣ
    ୈҰճ͸8FCαʔϏεͷج൫ٕज़
    ৄ͘͠͸ҎԼͷ63-Ͱ
    IUUQEFWFMPQFSIBUFOBTUBGGDPNFOUSZ

    View full-size slide