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

HTTPレイヤーで行うパフォーマンスチューニング (WEBエンジニア勉強会 #05)

OSCA
February 02, 2018

HTTPレイヤーで行うパフォーマンスチューニング (WEBエンジニア勉強会 #05)

OSCA

February 02, 2018
Tweet

More Decks by OSCA

Other Decks in Technology

Transcript

  1. 04$" ᖛ໺ Ұೋࡾ

    !FOHJOFFS@PTDB
    )551ϨΠϠʔͰߦ͏
    ύϑΥʔϚϯενϡʔχϯά

    View full-size slide

  2. © OSCA
    • ๻ࣗ਎͕೥຤ʹɺࣗ෼Ͱ։ൃ͍ͯ͠Δ8αʔϏεͷ
    ύϑΥʔϚϯενϡʔχϯάΛ΍͔ͬͨΒɻ
    (PPHMF1BHF*OTJHIUT ͷείΞΞοϓ

    • ͳΜͰ΋ج൫ٕज़Λ஌Δ͜ͱ͕ॏཁͰɺ8ͷ౔୆ͱ
    ͳΔ)551ͷ஌ࣝͷڞ༗Λ͍ͨ͠ɻ
    • લճͷʮ8ΤϯδχΞษڧձ ʯͰɺ8PSE1SFTT
    ͷνϡʔχϯάͷ࿩͕͋ͬͨͷͰɺͦΕͷิ଍ͱͯ͠ɻ
    ࠓ೔͜ͷςʔϚΛબΜͩཧ༝

    View full-size slide

  3. ࣗݾ঺հ
    © OSCA
    04$"ᖛ໺ Ұೋࡾ ͸·ͷ ͔ͣ;Έ

    ϓϩδΣΫτϚωʔδϟʔ ໷ܠࣸਅՈ
    +BWB 1)1ϝΠϯͷ8ΤϯδχΞ
    ਓ޻஌ೳ "*
    ؔ࿈΋΍ͬͯΔ
    ݸਓͰ΋714आΓͯ8αʔϏεΛӡӦத
    ເͷࠃ ెาݍ಺ॅΈ
    !FOHJOFFS@PTDB !PTDBQIPUP!EJTOFZ@PTDB

    View full-size slide

  4. © OSCA
    • ͸͡Ίʹ
    • ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ ֓ཁ

    • )551௨৴ѹॖΛ͢Δ ֓ཁ

    • ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ ࣮ԋ

    • )551௨৴ѹॖΛ͢Δ ࣮ԋ

    • "QBDIFIUUQE ʹ͓͚Δઃఆ
    • OHJOY ʹ͓͚Δઃఆ
    • ϓϩάϥϜ͔Βར༻͢Δ)551ΫϥΠΞϯτʹ͍ͭͯ
    • ·ͱΊ
    ໨࣍

    View full-size slide

  5. © OSCA
    8αΠτΞΫηεʹɺ)551Λར༻͍ͯ͠Δ͜ͱ͸0,ʁ
    ॳ৺ऀͷํͷͨΊͷ)551ͷ͓͞Β͍
    αʔόʔ
    ϒϥ΢β
    ΫϥΠΞϯτ

    GET /index.html HTTP/1.1
    Host: www.yahoo.co.jp
    HTTP1.1 200 OK




    View full-size slide

  6. © OSCA
    ͠͹Β͘ߋ৽͕ͳͦ͞͏ͳಉҰίϯςϯπ΁ͷΞΫηεΛݮ
    Β͠ɺΩϟογϡΛར༻ͤ͞Δ͜ͱͰදࣔΛߴ଎Խͤ͞Δɻ
    ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    ΫϥΠΞϯτ αʔόʔ

    View full-size slide

  7. © OSCA
    ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    BCDQOH ͪΐ͏͍ͩʂ
    ೥݄೔·Ͱ͸ɺ
    ͜ΕΛ࢖ͬͯʂ
    ͠͹Β͘ߋ৽͕ͳͦ͞͏ͳಉҰίϯςϯπ΁ͷΞΫηεΛݮ
    Β͠ɺΩϟογϡΛར༻ͤ͞Δ͜ͱͰදࣔΛߴ଎Խͤ͞Δɻ
    ΫϥΠΞϯτ αʔόʔ

    View full-size slide

  8. © OSCA
    ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ
    )551Ϩεϙϯεϔομʹ &YQJSFTϔομΛ෇༩ͯ͠ɺί
    ϯςϯπͷΩϟογϡ༗ޮظݶΛ஌ΒͤΔɻ
    αʔόʔ
    ϒϥ΢β
    ΫϥΠΞϯτ

    GET /logo.png HTTP/1.1
    Host: www.hogemoge.co.jp
    HTTP1.1 200 OK
    Expires: Wed, 24 Jan 2018 06:53:29 GMT
    (
    )

    View full-size slide

  9. © OSCA
    )5.- $44 +BWB4DSJQU 9.- +40/ͳͲͷςΩετ
    ϑΝΠϧΛѹॖͯ͠ड৴͢Δɻ ड৴σʔλྔ͕ݮΓɺߴ଎
    ʹͳΔɻ
    ͨͩ͠ɺΫϥΠΞϯτͱαʔόʔͷ྆ํ͕ɺಉ͡ѹॖܗࣜΛ
    αϙʔτ͍ͯ͠Δඞཁ͕͋Δɻ
    ͦ͜Ͱɺ"DDFQU&ODPEJOH ϔομͱ$POUFOU&ODPEJOH
    ϔομΛར༻͢Δɻ
    )551௨৴ѹॖΛ͢Δ

    View full-size slide

  10. © OSCA
    )551௨৴ѹॖΛ͢Δ
    αʔόʔ
    ϒϥ΢β
    ΫϥΠΞϯτ

    GET /index.html HTTP/1.1
    Host: www.hogemoge.co.jp
    Accept-Encoding: gzip, deflate
    HTTP1.1 200 OK
    Content-Encoding: gzip
    (HTML)

    View full-size slide

  11. © OSCA
    ϒϥ΢βΩϟογϡ
    • NPE@FYQJSFT ϞδϡʔϧͷಡࠐΈ͕ඞཁ
    • ྫ
    1/(ը૾ͷϒϥ΢βΩϟογϡظؒΛϲ݄ʹઃఆ
    "QBDIFIUUQE ʹ͓͚Δઃఆ
    LoadModule expires_module modules/mod_expires.so

    ExpiresActive On
    ExpiresByType image/png "access plus 1 month"

    View full-size slide

  12. © OSCA
    )551ѹॖ
    • H[JQѹॖ͸ NPE@EFGMBUF ϞδϡʔϧͷಡࠐΈ͕ඞཁ
    • ྫ
    ςΩετ )5.- $44 +BWB4DSJQUΛѹॖ͢Δ
    "QBDIFIUUQE ʹ͓͚Δઃఆ
    LoadModule deflate_module modules/mod_deflate.so

    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE text/javascript

    View full-size slide

  13. © OSCA
    OHJOYʹ͓͚Δઃఆ
    ϒϥ΢βΩϟογϡ
    • FYQJSFTͷهड़Λ͢Δ͚ͩɻ
    • ର৅Λ֦ுࢠͰߜΔ৔߹͸࣍ͷΑ͏ͳهड़ɻ
    expires 30d;
    location ~ .*¥.(html|jpg|gif|png|css|js) {
    expires 30d;
    }

    View full-size slide

  14. © OSCA
    )551ѹॖ
    • H[JQ POͱ H[JQ@UZQFT ͷهड़Ͱࢦఆ͢Δɻ
    OHJOYʹ͓͚Δઃఆ
    gzip on;
    gzip_types text/html text/css text/javascript

    View full-size slide

  15. © OSCA
    ϓϩάϥϜதͰ +40/΍ 9.-ͳͲ"1*Λݺͼग़͢͜ͱ͕
    ͋Δͱࢥ͍·͢ɻ ͦͷࡍʹ)551ѹॖͬͯؾʹ͍ͯ͠·͢
    ͔ʁ
    ݴޠඪ४ͷωοτϫʔΫܥΫϥεɾؔ਺Λར༻͢Δ৔߹ɺࣗ
    ෼Ͱ $POUFOU&ODPEJOHϔομΛ൑அͯ͠ղౚ͠ͳ͍ͱ͍
    ͚ͳ͍৔߹͕ଟ͍͕ɺߴػೳͳ)551$MJFOUϥΠϒϥϦΛར
    ༻͢Ε͹ɺ)551ѹॖͷ෦෼΋Ӆṭͯ͠΍ͬͯ͘ΕΔ৔߹͕
    ͋Δɻ
    ϓϩάϥϜ͔Βར༻͢Δ)551ΫϥΠΞϯτ

    View full-size slide

  16. © OSCA
    ͓ΘΓʹ
    • ຊεϥΠυͷͭͷνϡʔχϯά͸ɺ͋ͳͨͷ8αʔ
    Ϗεʹߩݙ͢Δ͚ͩͰ͸ͳ͘ɺΠϯλʔωοτ໢ͷύ
    έοτΛݮΒ͢͜ͱ͕Ͱ͖ΔΫϦʔϯͳςΫχοΫͰ͢ɻ
    • 8ͷলΤωɾলίετʹߩݙͷ͸͍͔͕Ͱ͠ΐ͏͔ɻ

    View full-size slide