The Future of mruby in HTTP Server - RubyKaigi 2015

The Future of mruby in HTTP Server - RubyKaigi 2015

As the HTTP/2 RFC was published, implementations of HTTP/2 have been actively developed. In this session, from the standpoint of an author of an extension mechanism using mruby for typical HTTP/1.x and HTTP/2 servers like apache, nginx and H2O, I show the possibility of design using mruby in HTTP server with new special features of HTTP/2 like server push. I explain how to design the complex web service system using both HTTP/1.x and HTTP/2 servers based on the need for HTTP/2 considering the changes in the architecture of Web service systems.

2b692bd83f4418103142a053ecf5ff59?s=128

MATSUMOTO Ryosuke

December 21, 2015
Tweet

Transcript

  1. 1.

    GMO Pepabo, Inc. Principal Engineer MATSUMOTO, Ryosuke @matsumotory 2015/12/11 RubyKaigi

    2015 5IF'VUVSFPGNSVCZ JO)5514FSWFS .JEEMFXBSF$POpHVSBUJPOBT$PEF
  2. 2.

    !NBUTVNPUPSZ  ."546.050 3ZPTVLF  1SJODJQBM&OHJOFFSBU(.01FQBCP *OD  8FCPQFSBUJPO EFWFMPQNFOUBOESFTFBSDI

     )BOEMFBDPNQBOZXJEFJOUFSOFUUFDIOPMPHZ  044 "DBEFNJD3FTFBSDI &OHJOFFSJOH  IUUQSFTFBSDINBUTVNPUPSKQ
  3. 4.

    $POUFOUT  )551JOUSPEVDUJPO  )551DIBSBDUFSJTUJDT  4FSWFSQVTI  1SJPSJUJ[BUJPO 

    NSVCZJO)5514FSWFSEFTJHOQPMJDZ  NSVCZJO)5514FSWFS  $PODMVTJPOBOE'VUVSFSFTFBSDIQMBO
  4. 6.

    )5511SPCMFNT  /PU.VMUJQMFYJOH  SFRVFTUSFTQPOTFQFS355ʢ3PVOE5SJQ5JNFʣ  )BSEUPSFBMJ[F)551QJQFMJOJOHJOQSBDUJDF  4FOENVMUJQMFSFRVFTUTXJUIPVUXBJUJOHGPSUIF DPSSFTQPOEJOHSFTQPOTFTJO355

     /FFEUPTZODISPOJ[FUIFPSEFSTPGSFRVFTUTBOE SFTQPOTFT  "TMPXSFRVFTUIBOEMJOHCMPDLTU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TJBPSHUBMLTIPXFBFGCFBBCEDB
  8. 19.

    4FSWFSQVTICZCBDLFOE)551TFSWFS  3FRVFTUGSPOUTJEF)551TFSWFSUPEPTFSWFSQVTICZBEEJOH-JOLIFBEFS  'SPOUTFSWFSDBOQVTIUPBDMJFOUEJSFDUMZCFGPSFGPSXBSEJOHUPBCBDLFOE $MJFOU )551 SFWFSTFQSPYZ )551 CBDLFOE

    TFSWFS )551DPOOFDUJPO )551DPOOFDUJPO "EE-JOLIFBEFS -JOLJOEFYKTSFMQSFMPBE 'PSXBSESFRVFTU (&5JOEFYUYU 3FTQPOTF TFSWFSQVTIJOEFYKT 3FTQPOTF JOEFYUYU
  9. 20.

    4FSWFSQVTICZCBDLFOE)551TFSWFS  $VSSFOUMZPOMZOHIUUQYDBONBLF)551DPOOFDUJPOGPSCBDLFOETFSWFS  $VSSFOUMZXFTIPVMEVTF-JOLIFBEFSFWFOJGBCBDLFOETFSWFSTVQQPSUT)551  *OUIFGVUVSFUIFSFJTTPNFQPTTJCJMJUZPGSFUVSOJOH164)@130.*4&TFOEGSPNB CBDLFOETFSWFS  5IFSFBSFTPNFQSPCMFNT

    FHIPXUPNBOBHF4&55*/(4CFUXFFOUXPIPQT $MJFOU )551 SFWFSTFQSPYZ OHIUUQY )551 CBDLFOE TFSWFS )551DPOOFDUJPO )551DPOOFDUJPO "EE-JOLIFBEFS -JOLJOEFYKTSFMQSFMPBE 'PSXBSESFRVFTU (&5JOEFYUYU 3FTQPOTF TFSWFSQVTIJOEFYKT 3FTQPOTF JOEFYUYU
  10. 21.

    1SPCMFNTBOETPMVUJPOTPGTFSWFSQVTI  5IFQSPCMFNPGCSPXTFSDBDIF  "TFSWFSDBO`UEFUFDUBCSPXTFSDBDIF  4FOEJOHBSFRVFTUUPEFUFDUBDBDIFXBTUFTF⒏DJFODZ HBJOFEXJUITFSWFSQVTI  )0IBTDBDIFBXBSFTFSWFSQVTI

     .BOBHFJOGPSNBUJPOBCPVUDBDIFCZOFXIFBEFS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