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

265edb69bfcd5cac012ad5a14f2e6e2f?s=47 OSCA
February 02, 2018

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

265edb69bfcd5cac012ad5a14f2e6e2f?s=128

OSCA

February 02, 2018
Tweet

Transcript

  1. 04$" ᖛ໺ Ұೋࡾ !FOHJOFFS@PTDB )551ϨΠϠʔͰߦ͏ ύϑΥʔϚϯενϡʔχϯά

  2. © OSCA • ๻ࣗ਎͕೥຤ʹɺࣗ෼Ͱ։ൃ͍ͯ͠Δ8&#αʔϏεͷ ύϑΥʔϚϯενϡʔχϯάΛ΍͔ͬͨΒɻ (PPHMF1BHF*OTJHIUT ͷείΞΞοϓ • ͳΜͰ΋ج൫ٕज़Λ஌Δ͜ͱ͕ॏཁͰɺ8&#ͷ౔୆ͱ ͳΔ)551ͷ஌ࣝͷڞ༗Λ͍ͨ͠ɻ

    • લճͷʮ8&#ΤϯδχΞษڧձ ʯͰɺ8PSE1SFTT ͷνϡʔχϯάͷ࿩͕͋ͬͨͷͰɺͦΕͷิ଍ͱͯ͠ɻ ࠓ೔͜ͷςʔϚΛબΜͩཧ༝
  3. ࣗݾ঺հ © OSCA 04$"ᖛ໺ Ұೋࡾ ͸·ͷ ͔ͣ;Έ ϓϩδΣΫτϚωʔδϟʔ ໷ܠࣸਅՈ 

    +BWB 1)1ϝΠϯͷ8&#ΤϯδχΞ  ਓ޻஌ೳ "* ؔ࿈΋΍ͬͯΔ  ݸਓͰ΋714आΓͯ8&#αʔϏεΛӡӦத  ເͷࠃ ెาݍ಺ॅΈ  !FOHJOFFS@PTDB !PTDBQIPUP!EJTOFZ@PTDB
  4. © OSCA • ͸͡Ίʹ • ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ ֓ཁ • )551௨৴ѹॖΛ͢Δ ֓ཁ

    • ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ ࣮ԋ • )551௨৴ѹॖΛ͢Δ ࣮ԋ • "QBDIFIUUQE ʹ͓͚Δઃఆ • OHJOY ʹ͓͚Δઃఆ • ϓϩάϥϜ͔Βར༻͢Δ)551ΫϥΠΞϯτʹ͍ͭͯ • ·ͱΊ ໨࣍
  5. © OSCA 8&#αΠτΞΫηεʹɺ)551Λར༻͍ͯ͠Δ͜ͱ͸0,ʁ ॳ৺ऀͷํͷͨΊͷ)551ͷ͓͞Β͍ αʔόʔ ϒϥ΢β ΫϥΠΞϯτ GET /index.html HTTP/1.1

    Host: www.yahoo.co.jp HTTP1.1 200 OK <html> <head>…</head> <body>…</body> </html>
  6. © OSCA ͠͹Β͘ߋ৽͕ͳͦ͞͏ͳಉҰίϯςϯπ΁ͷΞΫηεΛݮ Β͠ɺΩϟογϡΛར༻ͤ͞Δ͜ͱͰදࣔΛߴ଎Խͤ͞Δɻ ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ BCDQOH ͪΐ͏͍ͩʂ BCDQOH ͪΐ͏͍ͩʂ BCDQOH

    ͪΐ͏͍ͩʂ BCDQOH ͪΐ͏͍ͩʂ ΫϥΠΞϯτ αʔόʔ
  7. © OSCA ίϯςϯπΛϒϥ΢βΩϟογϡͤ͞Δ BCDQOH ͪΐ͏͍ͩʂ BCDQOH ͪΐ͏͍ͩʂ BCDQOH ͪΐ͏͍ͩʂ BCDQOH

    ͪΐ͏͍ͩʂ ೥݄೔·Ͱ͸ɺ ͜ΕΛ࢖ͬͯʂ ͠͹Β͘ߋ৽͕ͳͦ͞͏ͳಉҰίϯςϯπ΁ͷΞΫηεΛݮ Β͠ɺΩϟογϡΛར༻ͤ͞Δ͜ͱͰදࣔΛߴ଎Խͤ͞Δɻ ΫϥΠΞϯτ αʔόʔ
  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 (  )
  9. © OSCA )5.- $44 +BWB4DSJQU 9.- +40/ͳͲͷςΩετ ϑΝΠϧΛѹॖͯ͠ड৴͢Δɻ ड৴σʔλྔ͕ݮΓɺߴ଎ ʹͳΔɻ

    ͨͩ͠ɺΫϥΠΞϯτͱαʔόʔͷ྆ํ͕ɺಉ͡ѹॖܗࣜΛ αϙʔτ͍ͯ͠Δඞཁ͕͋Δɻ ͦ͜Ͱɺ"DDFQU&ODPEJOH ϔομͱ$POUFOU&ODPEJOH ϔομΛར༻͢Δɻ )551௨৴ѹॖΛ͢Δ
  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)
  11. © OSCA ϒϥ΢βΩϟογϡ • NPE@FYQJSFT ϞδϡʔϧͷಡࠐΈ͕ඞཁ • ྫ 1/(ը૾ͷϒϥ΢βΩϟογϡظؒΛϲ݄ʹઃఆ "QBDIFIUUQE

    ʹ͓͚Δઃఆ LoadModule expires_module modules/mod_expires.so <ifModule mod_expires.c> ExpiresActive On ExpiresByType image/png "access plus 1 month" </ifModule>
  12. © OSCA )551ѹॖ • H[JQѹॖ͸ NPE@EFGMBUF ϞδϡʔϧͷಡࠐΈ͕ඞཁ • ྫ ςΩετ

    )5.- $44 +BWB4DSJQUΛѹॖ͢Δ "QBDIFIUUQE ʹ͓͚Δઃఆ LoadModule deflate_module modules/mod_deflate.so <IfModule mod_deflate.c> AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE text/javascript </IfModule>
  13. © OSCA OHJOYʹ͓͚Δઃఆ ϒϥ΢βΩϟογϡ • FYQJSFTͷهड़Λ͢Δ͚ͩɻ • ର৅Λ֦ுࢠͰߜΔ৔߹͸࣍ͷΑ͏ͳهड़ɻ expires 30d;

    location ~ .*¥.(html|jpg|gif|png|css|js) { expires 30d; }
  14. © OSCA )551ѹॖ • H[JQ POͱ H[JQ@UZQFT ͷهड़Ͱࢦఆ͢Δɻ OHJOYʹ͓͚Δઃఆ gzip

    on; gzip_types text/html text/css text/javascript
  15. © OSCA ϓϩάϥϜதͰ +40/΍ 9.-ͳͲ"1*Λݺͼग़͢͜ͱ͕ ͋Δͱࢥ͍·͢ɻ ͦͷࡍʹ)551ѹॖͬͯؾʹ͍ͯ͠·͢ ͔ʁ ݴޠඪ४ͷωοτϫʔΫܥΫϥεɾؔ਺Λར༻͢Δ৔߹ɺࣗ ෼Ͱ

    $POUFOU&ODPEJOHϔομΛ൑அͯ͠ղౚ͠ͳ͍ͱ͍ ͚ͳ͍৔߹͕ଟ͍͕ɺߴػೳͳ)551$MJFOUϥΠϒϥϦΛར ༻͢Ε͹ɺ)551ѹॖͷ෦෼΋Ӆṭͯ͠΍ͬͯ͘ΕΔ৔߹͕ ͋Δɻ ϓϩάϥϜ͔Βར༻͢Δ)551ΫϥΠΞϯτ
  16. © OSCA ͓ΘΓʹ • ຊεϥΠυͷͭͷνϡʔχϯά͸ɺ͋ͳͨͷ8&#αʔ Ϗεʹߩݙ͢Δ͚ͩͰ͸ͳ͘ɺΠϯλʔωοτ໢ͷύ έοτΛݮΒ͢͜ͱ͕Ͱ͖ΔΫϦʔϯͳςΫχοΫͰ͢ɻ • 8&#ͷলΤωɾলίετʹߩݙͷ͸͍͔͕Ͱ͠ΐ͏͔ɻ