爆速WEBサーバ”H2O”に触れてみよう / handson-for-h2o

12a5cec7a54018170b1a009731acf477?s=47 VTRyo
November 09, 2017

爆速WEBサーバ”H2O”に触れてみよう / handson-for-h2o

12a5cec7a54018170b1a009731acf477?s=128

VTRyo

November 09, 2017
Tweet

Transcript

  1. ര଎WEBαʔό”H2O”ʹ৮ΕͯΈΑ͏ Infra/SRE RYO

  2. ΞδΣϯμ ❖ ࣗݾ঺հ ❖ H2OͬͯͳΜͧʁ ❖ H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ❖ ࣮ࡍʹ৮ͬͯΈΑ͏ʂ

  3. ࣗݾ঺հ ϓϩϑΝΠϧ ɾ౦ژ౎ҏ౾େౡग़਎ ɾ๭ࢲେ৺ཧֶՊ ࣾձ৺ཧֶઐ߈ ɾSIۀք SESΠϯϑϥΤϯδχΞͱͯ͠ΩϟϦΞελʔτ ɾݱࡏ͸WEBܥاۀͷΠϯϑϥΤϯδχΞ ɾٕज़ϒϩάझຯͷൃ৴ ʢIUUQTCMPHWUSZPNFʣ

  4. ฐࣾͰ࢖༻͍ͯ͠Δओͳٕज़

  5. H2OͬͯͳΜͧʁ H2Oͱ͸ ɾHTTP/2ʹରԠͨ͠HTTPαʔόʔιϑτ΢ΤΞ ɾݩDeNAԞҰึࢯΛத৺ʹ։ൃ͞Εͨ ɾʮWEB͕஗͘ͳ͖ͬͯͨʯ͔Β஀ੜͨ͠ ɾઃఆϑΝΠϧ͕ڻ͖ͷγϯϓϧ͞ʢݸਓͷײ૝ʣ

  6. H2OͬͯͳΜͧʁ H2Oͱ͸ H2Oͱಉ౳ͷνϡʔχϯάΛNginxɺApacheͰ࣮૷͠ Α͏ͱ͢Δͱɺதʑͷٕज़ྗΛཁ͢Δ͔ͱࢥ͍·͢ɻ ͦΕΒΛγϯϓϧʹɺ؆୯ʹ࣮૷Ͱ͖ΔH2O͸ͦΕͩ ͚ͰՁ஋͕͋Δͱࢥ͏ͷͰ͢ɻ

  7. H2OͬͯͳΜͧʁ H2Oͱ͸ ࠓճ͸Ή͔ͣ͠ʙࣄ͸ஔ͍ͱ͍ͯ H2Oͱ͍͏WEBαʔό͕ɺ ͍͔ʹγϯϓϧ͔Λ͝ମݧ௖͖͍ͨͱࢥ͍·͢ʂ

  8. H2OͬͯͳΜͧʁ H2Oͱ͸ ·ͣ͸ΞΫηεͯ͠ΈΑ͏ʂ Compare resource loading between HTTP/2 (H2O) and

    HTTP/1.1 (Nginx) https://goo.gl/qFH99c
  9. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ “the optimized HTTP/1.x, HTTP/2 server” ࠷దԽ͞ΕͨHTTP/2

  10. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/2ʁ

  11. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ͦ΋ͦ΋HTTP/1ͱ͸ʁ

  12. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTPͱ͸ ɾ1ϦΫΤετ ɹ1Ϩεϙϯε

  13. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/1.x(ύΠϓϥΠϯ)ͱ͸ ɾෳ਺ϦΫΤετ ɹॱʹϨεϙϯε

  14. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/2

  15. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/2ͱ͸ ɹɾετϦʔϜʹΑΔଟॏԽ ɹɹෳ਺ϦΫΤετɺॱෆಉϨεϙϯε ɹɾϔομѹॖ ɹɾαʔόϓογϡ ɹɾ༏ઌ౓੍ޚ

  16. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/2ͱ͸ ɾετϦʔϜʹΑΔଟॏԽ ɹෳ਺ϦΫΤετ ɹॱෆಉϨεϙϯε Ծ૝తͳ૒ํ޲γʔέϯε

  17. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ɾϔομѹॖ ɹɾ੬ऑੑʹ΋ରԠͨ͠ѹॖํࣜHPACKͰѹॖ ɹɹҰ౓ૹ৴ͨ͠ϔομʔ͸جຊతʹ࠶ૹ৴͠ͳ͍ ɹɹ৽ͨʹඞཁͳϔομʔͷΈΛࠩ෼ૹ৴͢Δ HTTP/2ͱ͸

  18. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ HTTP/2ͱ͸ ɾαʔόϓογϡ ɹϨΠςϯγΛ୹ॖ

  19. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ͜͜·Ͱ͸ϓϩτίϧͷ͓࿩Αʂ

  20. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ͋Εʁ༏ઌ౓੍ޚͬͯ΍ͭ͸ʁ

  21. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ H2O͕଎͍ཧ༝ͷͻͱͭʹ༏ઌ౓੍ޚ

  22. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ༏ઌ౓੍ޚ ɾΫϥΠΞϯτ͕αʔόʹͲͷίϯςϯπ͔Β༏ઌతʹಡ ΈࠐΈ͍͔ͨఏҊ͢Δ ɾαʔό͸ͦΕΛʮࢀߟʹʯετϦʔϜͰసૹ͢Δ ΫϥΠΞϯτ͕ૣ͘ϩʔυ͍ͨ͠ॴʹϦιʔεΛͨ͘͞Μ ׂ͚Ε͹଎͘ͳΔΑͶʂ

  23. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ H2Oͷ༏ઌ౓੍ޚ ɾϒϥ΢βͷఏҊʹै͍όϯυ෯Λ഑෼ ɹˠେྔͷը૾ͳͲɺ෯Λ࢖ͬͯΔॴʹ ɾ༏ઌ౓੍ޚΛΑΓࡉ੍͔͘ޚͰ͖Δ ɾ༏ઌ౓੍ޚͳ͠ͷϒϥ΢βʹରͯ͠΋࠷దԽ͍ͯ͠Δ

  24. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ Αʔ͠ɺͬͦ͘͞ઃఆ͢Δ͔ʂ

  25. None
  26. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ H2Oʮͳʹ΋͠ͳͯ͘΋ΠΠϤʂʯ

  27. None
  28. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ H2O͸HTTP/2ͷϝϦοτΛ࠷େݶʹҾ͖ग़͢

  29. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ ͦ͏Ͱ͢ɻσϑΥϧτͰ΍ͬͯ·͢ɻ

  30. H2O͕଎͍ͱݴΘΕΔͷ͸ʁ H2O͞Μ͕͍͍ͩͨͷ͜ͱ ྑ͖ʹ͸͔Βͬͯ͘Ε͍ͯ·͢ʂʂʢসʣ ͭ·ΓͲ͏͍͏͜ͱͩͬͯ͹Αɾɾɾʁ

  31. ͓·͚ ΞΫηεͯ͠ΈΑ͏ʂ ϒϩά https://blog.vtryo.me ద౰ͳϖʔδʹΞΫηεͯ͠Ϧϩʔυ͠ ͯΈ·͠ΐ͏

  32. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ ͔͜͜Β͸ϋϯζΦϯ https://github.com/VTRyo/handson-vagrant https://github.com/VTRyo/handson-amazonlinux Vagrantͷͻͱ AmazonLinuxͷͻͱ

  33. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ git clone https://github.com/VTRyo/handson.gitɹ cd handson vagrant up VirtualBoxʴVagrant؀ڥͷ৔߹ mkdir

    h2o ; cd h2o
  34. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ git clone https://github.com/VTRyo/handson-amazonlinux.git cd handson-amazonlinux/ansible /usr/local/bin/ansible-playbook -i hosts playbook.yml

    AmazonLinuxͷ৔߹ sudo pip install ansible sudo yum install git mkdir h2o ; cd h2o
  35. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ ϒϥ΢βʢChrome, FirefoxͳͲʣ localhost:8080(΋͘͠͸IPΞυϨε)ʹΞΫηε

  36. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ vim /etc/php-fpm.d/www.conf php-fpmͱ࿈ܞͯ͠ΈΔ listen = /var/run/php-fpm/php-fpm.sock

  37. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ vim /etc/php-fpm.d/www.conf php-fpmͱ࿈ܞͯ͠ΈΔ listen.owner = nobody listen.group = nobodyɹίϝϯτΞ΢τΛ͸ͣ͢

  38. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ vim /etc/h2o/h2o.conf user: nobodyɹͷԼʹ௥ه͓͖ͯ͠·͠ΐ͏ php-fpmͱ࿈ܞͯ͠ΈΔ

  39. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ /etc/init.d/php-fpm restart αʔϏε࠶ىಈ /etc/init.d/h2o restart

  40. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ netstat -a --unix | grep php-fpm ௨৴֬ೝ

  41. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ BasicೝূઃఆΛͯ͠ΈΔ Α͋͘ΔઃఆΛΈ͓ͯ͜͏

  42. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ h2o -t -c h2o.conf Syntax ֬ೝίϚϯυ /etc/init.d/h2o restart αʔϏε࠶ىಈ

  43. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ ϒϥ΢βʢChrome, FirefoxͳͲʣ localhost:8080(΋͘͠͸IPΞυϨε)ʹΞΫηε

  44. ࣮ࡍʹ৮ͬͯΈΑ͏ʂ ϋϯζΦϯ͓ΘΓ

  45. ·ͱΊ ·ͱΊ ɾH2O͸HTTP/2ͷϝϦοτΛ࠷େݶʹ׆͔͢ʂ ɾͦͷઃఆ͸σϑΥϧτʂ ɾconfigͷجૅ͸͍ͨͬͯγϯϓϧʂ

  46. ࢀߟจݙ ɾH2Oʢhttps://h2o.examp1e.net/ʣ ɾH2O - making HTTP betterʢhttps://www.slideshare.net/kazuho/h2o-43944586ʣ ɾHTTP/2 ೖ໳ʢhttps://techblog.yahoo.co.jp/infrastructure/http2/introduction_to_http2/ʣ ɾීٴ͕ਐΉʮ)551ʯͷ࢓૊ΈͱϝϦοτͱ͸ʢhttps://knowledge.sakura.ad.jp/7734/ʣ

    ɾϨΠςϯγʹෛ͚ͳ͍ϓϩτίϧͱͯ͠ొ৔ͨ͠)551ʙԞҰึࢯʹΑΔʮ)551ͱαʔό ٕज़ͷ࠷৽ಈ޲ʯʢલฤʣɻ%FWFMPQFST4VNNJUʢIUUQXXXQVCMJDLFZKQCMPH IUUQIUUQEFWFMPQFST@TVNNJU@IUNMʣ Ͱɺ)551ରԠͬͯԿΛ͢Ε͹͍͍ͷʁʢIUUQETLTUIBUFOBCMPHDPNFOUSZ ʣ ɾ)551ͷϓϥΠΦϦςΟ੍ޚʢIUUQTRJJUBDPN+YDL@JUFNT BBFFFBGʣ
  47. ര଎WEBαʔό”H2O”ʹ৮ΕͯΈΑ͏ Infra/SRE RYO ׬