HTTP/2 最速実装 v3

4ab3fec3e82ddb19bcadd93ef909a443?s=47 Ryo Okubo
September 06, 2014

HTTP/2 最速実装 v3

4ab3fec3e82ddb19bcadd93ef909a443?s=128

Ryo Okubo

September 06, 2014
Tweet

Transcript

  1. )551࠷଎࣮૷W IUUQESBGUରԠ൛ !TZV@DSFBN

  2. ໨࣍ w )551ͷ؆୯ͳઆ໌ w )551Yͷ͓͞Β͍ w )551ͷಛ௃ w )551࠷଎࣮૷ͷղઆ w

    ࠷௿ݶߦ͏΂͖࣮૷ʹ͍ͭͯ w ಈ࡞֬ೝํ๏ w ֤छࢿྉ
  3. )551ͷ ؆୯ͳઆ໌

  4. )551YͷϦΫΤετ w ݪଇDPOOFDUJPOSFRVFTU w Ұൠతͳϒϥ΢β͸ಉ࣌ʹίωΫγϣϯ͔͠։͔ͳ͍

  5. )551ͷ1JQFMJOJOH w ίωΫγϣϯͰෳ਺ϦΫΤετΛ౤͛ΒΕΔ w ͨͩ͠ॱংΛकΒͳ͚Ε͹ͳΒͳ͍ w ͜ͷ੍໿ͷͨΊϨεϙϯε͕ϒϩοΫ͢ΔةݥੑΞϦ )FBEPG-JOF#MPDLJOH server client

    1   1.,GET,/hoge.gif 2.,GET,/fuga.html 3.,GET,/piyo.css     
  6. )551Yͷϔομ w ςΩετͰϔομΛ΍ΓऔΓ w ϔομͱϘσΟͷ۠੾Γ͸ۭվߦ w 6TFS"HBOUͳͲ΄ͱΜͲมΘΒͳ͍ͷʹԿ౓΋ૹ৴͢Δඞཁ͕͋Γɺ৑௕ (&5)551 )PTUMPDBMIPTU "DDFQU

      $3 -' )5510, 4FSWFSOHJOY %BUF'SJ 4FQ(.5 $POUFOU5ZQFUFYUIUNM $POUFOU-FOHUI -BTU.PEJpFE'SJ 4FQ(.5 $POOFDUJPOLFFQBMJWF &5BHBGF "DDFQU3BOHFTCZUFT $3 -' ϦΫΤετϔομͷྫ Ϩεϙϯεϔομͷྫ
  7. )551ͷಛ௃ w ࿦ཧతͳίωΫγϣϯ ετϦʔϜ ʹΑΔฒྻ௨৴ w ݪଇతʹίωΫγϣϯ͸ຊ͚ͩுΔ w ϝοηʔδΛόΠφϦϑϨʔϜͰදݱ w

    ϔομΛಠࣗͷܗࣜͰѹॖ )1"$,  w αʔό͔Βͷࣗൃతͳ௨৴ αʔόϓογϡ  w ετϦʔϜͷ༏ઌ౓෇͚
  8. ετϦʔϜ w ͭͷίωΫγϣϯ͚ͩுΓɺͦͷ্ͰετϦʔϜΛ։͘ w )551௨৴͸ετϦʔϜ্ͰߦΘΕΔ w ετϦʔϜͷॲཧ͸ϒϩοΫ͠߹Θͳ͍ w ετϦʔϜʹ͸Ұҙͳ*%͕ৼΒΕΔ w

    ΫϥΠΞϯτ͔Β։͘৔߹ح਺ɺαʔό͔Β։͘৔߹ۮ਺Λ࢖༻ w 4USFBN*%͸؅ཧ༻ʹ࢖༻͞ΕΔ server client TCP  HTTP/2   HTTP/20  HTTP/20  
  9. όΠφϦϑϨʔϜ w ϝοηʔδΛόΠφϦͷʮϑϨʔϜʯͰදݱ w ϑϨʔϜʹ͸ϔομ͕෇༩͞ΕΔ w ϑϨʔϜ௕ɺλΠϓɺϑϥάɺετϦʔϜ*% w ϑϨʔϜͷϑΥʔϚοτ͸Լهͷ௨Γ

  10. ϑϨʔϜλΠϓ w ϑϨʔϜ͸༻్ʹԠͯ͡Լهͷ༷ʹ෼ྨ͞ΕΔ w %"5" ϘσΟΛදݱ  w )&"%&34 ϔομΛදݱ

     w 13*03*5: ετϦʔϜͷ༏ઌ౓ઃఆ  w 345@453&". ετϦʔϜΛҟৗऴྃ  w 4&55*/(4 ίωΫγϣϯͷઃఆ  w 164)@130.*4& αʔόϓογϡͷ௨஌  w 1*/( ίωΫγϣϯͷࢮ׆֬ೝ  w (0"8": ίωΫγϣϯͷऴྃ௨஌  w 8*/%08@61%"5& ϑϩʔ੍ޚ  w $0/5*/6"5*0/ )&"%&34ʹೲ·Βͳ͍෼ͷϔομͷૹ৴
  11. ϔομѹॖ w )1"$,ͱ͍͏ܗࣜͰѹॖ͞ΕΔ w IUUQUPPMTJFUGPSHIUNMESBGUJFUGIUUQCJTIFBEFS DPNQSFTTJPO w ѹॖํ๏ w ϔομͷ໊લ΍஋ΛϋϑϚϯූ߸Խ

    w Α͘࢖ΘΕΔϔομͷηοτΛJOEFYͰࢦఆ w ҎલૹͬͨϔομΛJOEFYͰࢦఆ
  12. )551࠷଎࣮૷ͷ ղઆ

  13. )551࠷଎࣮૷ͱ͸ w )551͸Yͱࠩ෼͕ଟ͍ w ਅ໘໨ʹ࣮૷͍ͯ͠Δͱ͕͔͔࣌ؒΔʜ w ࠷௿ݶϦΫΤετ͕ॲཧ͞ΕΔͱ͜Ζ·ͰΛ࣮૷͠Α͏ʂ w IUUQTHJUIVCDPNIUUQKQIUUQKQHJUIVCJPXJLJ)551 &$&'&"&'

    &"&# w ΫϥΠΞϯτ͔Β࣮૷ͨ͠ํָ͕ w ຊࢿྉ΋ΫϥΠΞϯτͷ࣮૷Λ૝ఆͯ͠࡞੒͍ͯ͠·͢
  14. ࠷଎࣮૷Ͱ΍Δ΂͖ൣғ w όΠφϦϑϨʔϜॲཧ w ಛఆछྨͷϑϨʔϜ͚ͩ΍Γ·͢ w %"5" )&"%&34 4&55*/(4 (0"8":

    w ετϦʔϜ؅ཧ w αϘΓ·͢ɻTUSFBNJE͚ͩΛ࢖༻ w ঢ়ଶ΋؅ཧ͠ͳ͍ɻ͋ΔॱংͰϑϨʔϜ͕དྷΔ͜ͱΛ૝ఆɻ w ϔομѹॖ w αϘΓ·͢ɻFODPEF͚ͩ͸)1"$,ͷϑΥʔϚοτʹͳΔ΂͘߹Θͤ·͢ɻ
  15. ࠷଎࣮૷ʹΑΔ ΫϥΠΞϯταʔόͷ΍ΓऔΓ server client 0.,$"& % 1.,Connec0on,Preface( 24,octets,),  2.,

    ,SETTINGS,frame,  3.,SETTINGS,frame ACK  5.,HEADERS,frame !   6.,HEADERS,frame,(#%)  7.,DATA,frame,(#%)  8.,GOAWAY,frame,  4.,ACK 
  16. ϓϩτίϧ ωΰγΤʔγϣϯ w )551Λ࢖͏ࣄΛDMJFOUTFSWFSؒͰͲ͏ܾఆ͢Δ͔ʁ w ਅ໘໨ʹ΍Δ৔߹ w IUUQTͳΒ5-4/1/PS5-4"-1/ w IUUQͳΒ6QHSBEF

    "MU4WD w ࠷଎࣮૷Ͱ͸%JSFDU ωΰγΤʔγϣϯ͠ͳ͍ Ͱߦ͖·͢ w ૬ख͕)551͠Ό΂ΕΔ૝ఆͰ௨৴
  17. $POOFDUJPO1SFGBDF w )551ηογϣϯ։࢝࣌ʹΦΫςοτͷจࣈྻΛૹ৴ w 13* )551aSaOaSaO4.aSaOaSaOz w )551YͰ͸l13*ϝιου͕དྷͨzͱղऍ͞ΕΔ w )551͠Ό΂Εͳ͍αʔόʹૣظʹηογϣϯΛ੾ͬͯ໯͑Δ

    ! w ࢀߟIUUQTVNNFSXJOEKQEPDTESBGUJFUGIUUQCJTIUUQ TFDUJPO
  18.  4&55*/(4GSBNF w ίωΫγϣϯશମʹؔΘΔઃఆΛ΍ΓऔΓ͢Δ w αʔόϓογϡڐՄɺಉ࣌ετϦʔϜͷ࠷େ਺ͳͲ w ϖΠϩʔυ͸ۭ ϑϨʔϜͷMFOHUI Ͱ΋Α͍

    w ϖΠϩʔυͷϑΥʔϚοτ͸Լهͷ௨Γ ! w ࢀߟIUUQTVNNFSXJOEKQEPDTESBGUJFUGIUUQCJTIUUQTFDUJPO
  19.  4&55*/(4GSBNF "$, w 4&55*/(4डऔଆ͸"$,Λฦ͢ඞཁ͕͋Δ w ϑϨʔϜϔομͷϑϥάͰYΛཱͯΔ w ϖΠϩʔυ͸ۭʹ͢Δ !

    w ࢀߟIUUQTVNNFSXJOEKQEPDTESBGUJFUG IUUQCJTIUUQTFDUJPO
  20. )&"%&34 ϦΫΤετ w ϦΫΤετϔομΛૹ৴ w )FBEFS#MPDL'SBHNFOUҎ֎೚ҙ w )FBEFS#MPDL'SBHNFOU͸)1"$,ͷܗࣜʹΤϯίʔυ͢Δ ޙड़ 

    ! w ࢀߟIUUQTVNNFSXJOEKQEPDTESBGUJFUGIUUQCJTIUUQTFDUJPO
  21. )1"$, w )551ͷϔομѹॖܗࣜ w IUUQUPPMTJFUGPSHIUNMESBGUJFUGIUUQCJTIFBEFS DPNQSFTTJPO w ࠷଎࣮૷Ͱ͸-JUFSBM)FBEFS'JFMEXJUIPVU*OEFYJOHΛ࢖༻ w ϋϑϚϯූ߸ԽɺΠϯσΫγϯάΛߦΘͳ͍

    w ඞਢͷϔομ͕͋ΔͷͰͦΕ͸ؚ·ͤΔ͜ͱ w ϦΫΤετͰ͸NFUIPE TDIFNF BVUIPSJUZ QBUI w ϨεϙϯεͰ͸TUBUVT
  22. )1"$,ΤϯίʔυͷΠϝʔδ w ϑΥʔϚοτ͸ࠨԼͷਤͷ௨Γ w )͸ϋϑϚϯූ߸Խϑϥάɻʹ͓ͯ͘͠ w -FOHUIͷ  ͸೚ҙ௕ɻࠓճ͸Ϗοτʹೲ·Δ૝ఆͰ࣮૷ɻ w

    ਅ໘໨ʹ࣮૷͢ΔͳΒ*OUFHFS3FQSFTFOUBUJPOΛࢀর w 4USJOHͷ෦෼͸"4$**ίʔυΛೖΕΔ w /BNF͕lNFUIPEzɺ7BMVF͕l(&5zͷ৔߹ɺӈͷΠϝʔδͷΑ͏ʹ͢Δ -JUFSBM)FBEFS'JFMEXJUIPVU*OEFYJOHϑΥʔϚοτ         cccccc     ccc    clNFUIPEzc    ccc    cl(&5zc  ΤϯίʔυޙͷΠϝʔδ 4USJOH෦෼͸࣮ࡍʹ͸จࣈྻ෼ͷPDUFUΛ࢖༻
  23. )&"%&34 Ϩεϙϯε w ϨεϙϯεϔομΛड৴ w ϖΠϩʔυ͸)1"$,ͷΤϯίʔυͱٯͷ࣮૷Λॻ͚͹0, w ͨͩ͠૬ख͕ϋϑϚϯූ߸ɺΠϯσΫγϯάͯ͘͠ΔՄೳੑ͋Γ w ࠷଎Ͱ͸࣮૷ΛαϘΓ·͠ΐ͏X

    w ϑϨʔϜͷ-FOHUI෼͚ͩόοϑΝΛಡΈඈ͹ͦ͏ɻɻɻ w ༨༟͕͋Ε͹࣮૷ͯ͠Έ͍ͯͩ͘͞
  24. %"5" Ϩεϙϯε w ϨεϙϯεϘσΟΛड৴ w ϖΠϩʔυ͸%BUB ͷ෦෼͚ͩΛ૝ఆ w όοϑΝΛͻͨ͢ΒಡΈग़͚ͩ͢Ͱ0, w

    ϨεϙϯεϘσΟ͕ςΩετͳΒɺͦͷ··ग़ྗͯ͠ΈΑ͏ʂ
  25. (0"8": w ηογϣϯऴྃΛ௨஌͢Δ w -BTU4USFBN*%ɺ&SSPS$PEF w "EEJUJJPOBM%FCVH%BUB͸ෆཁ ! w ࢀߟIUUQTVNNFSXJOEKQEPDTESBGUJFUGIUUQCJTIUUQ

    TFDUJPO
  26. ͜͜·ͰͰ͖Ε͹࠷଎࣮૷ ׬ྃͰ͢ ͓ർΕ͞·Ͱͨ͠

  27. ಈ࡞֬ೝํ๏ w ΫϥΠΞϯτΛ࣮૷͢Δ৔߹ w 1VCMJD5FTU4FSWFSΛ࢖͏ w IUUQTOHIUUQPSH w OHIUUQEΛ࢖͏ %PDLFSJNBHF༻ҙ͠·ͨ͠

     w ࠷଎࣮૷αʔόΛ࢖͏ w αʔόΛ࣮૷͢Δ৔߹ w OHIUUQ ΫϥΠΞϯτ࣮૷ Λ࢖͏ %PDLFSJNBHF༻ҙ͠·ͨ͠  w ࠷଎࣮૷ΫϥΠΞϯτΛ࢖͏
  28. OHIUUQ༻%PDLFSJNBHF w OHIUUQ࢖͑Δ%PDLFSJNBHF༻ҙ͠·ͨ͠ w ࢖༻ํ๏ w EPDLFSQVMMTZVDSFBNOHIUUQI w EPDLFSSVOJQUTZVDSFBN OHIUUQICJOCBTI

    w ίϯςφ಺ OHIUUQEWŠOPUMT
  29. ࠷଎࣮૷ྫ w ࠷଎࣮૷ͯ͠Έ·ͨ͠ɻࢀߟʹ͍ͯͩ͘͠͞ɻ w IUUQTHJUIVCDPNTZVDSFBN .JOJNVN)551

  30. ࢀߟࢿྉ w IUUQESBGU೔ຊޠ༁ w IUUQTVNNFSXJOEKQEPDTESBGUJFUGIUUQCJTIUUQ w )1"$,ESBGU w IUUQUPPMTJFUGPSHIUNMESBGUJFUGIUUQCJTIFBEFS DPNQSFTTJPO

    w )551ϋοΧιϯୈҰճɺୈೋճͷࢿྉ w IUUQXXXTMJEFTIBSFOFU,BPSV.BFEBIUUQTJNQMF w IUUQXXXTMJEFTIBSFOFU:PTIJIJSP*XBOBHBIUUQ
  31. ൃల՝୊ w ࠷଎࣮૷͕ऴΘͬͨΒԼه΋௅ઓͯ͠ΈͯԼ͍͞ w )1"$,FODPEFSEFDPEFSϑϧ࣮૷ w ετϦʔϜͷঢ়ଶ؅ཧ w ଞλΠϓͷϑϨʔϜॲཧ࣮૷