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

PHPでgRPCって どこまでいけるの?

PHPでgRPCって どこまでいけるの?

PHPConferenceTokyo2019のLT発表資料です

近年、マイクロサービスの流行とともにプロトコルとして
gRPCが使われるのをよく目にします
PHPでgRPCを使おうと思ったとき、他の言語できるけれど
PHPでできないことはあるでしょうか?
Swooleを用いて、gRPCサーバを検証してみました

CyberAgent SGE Engineer

December 01, 2019
Tweet

More Decks by CyberAgent SGE Engineer

Other Decks in Technology

Transcript

  1. 1)1ͰH31$ͬͯ
    Ͳ͜·Ͱ͍͚Δͷʁ
    גࣜձࣾαΠόʔΤʔδΣϯτനҪӳ

    QIQDPO

    View full-size slide

  2. • גࣜձࣾαΠόʔΤʔδΣϯτ
    • 4(&౷ׅຊ෦ٕज़౷ׅࣨࣨ௕
    • ࢠձࣾࣾ$50
    • גࣜձࣾ$SBGU&HH
    • גࣜձࣾαϜβοϓ
    • നҪɹӳ
    • ΤϯδχΞ
    • #MPH
    IUUQBNFCMPKQHPPEPP
    ͓લɺ୭Α
    • 5XJUUFS
    !HPPEPP
    • %2
    ͙ͪ͢Ή '#

    ϓΫϦϙ ཱྀܳਓ

    View full-size slide

  3. "HFOEB
    w͸͡Ίʹ
    wH31$
    wH31$ͱ1)1
    w1)1ͷ࣮૷
    w·ͱΊ

    View full-size slide

  4. H31$ͬͯ࠷ۙΊͬͪΌ
    ฉ͖·͢Ͷ ࢲݟ

    View full-size slide

  5. ஫໨౓͕ߴ͍ͬͯ͜ͱ
    Ͱ͢Ͷ

    View full-size slide

  6. ϓϩϙʔβϧΛग़͢ͱ͖ʹ
    ؾ͍͍ͮͯͳ͔ͬͨ͜ͱɾɾɾ

    View full-size slide

  7. IUUQTTQFBLFSEFDLDPNTINVSBLBNJQIQHSQDDMJFOUJOQIQDPO
    1)1$POGFSFODFͰ࿩͞Εͯͨɾɾɾ

    View full-size slide

  8. -BSWFM+1$POGFSFODFͰ࿩͞Εͯͨɾɾɾ
    IUUQTTQFBLFSEFDLDPNOQIQEFNPHSQDTBCBXPMJUFUBJEBLFGBMTFSFOTIFOHEBUVUB

    View full-size slide

  9. ఆظతʹ࿩͞Ε͍ͯΔ
    ࿩୊
    ̎ͭͷ͓࿩͸ඇৗʹྑ͍ࢿྉͰ͢

    View full-size slide

  10. ΈΜͳؾʹͳ͍ͬͯΔ
    ͱ͍͏͜ͱͰ
    ϙδςΟϒʹ͍͖·͢

    View full-size slide

  11. ͍ͭ΋࣌ؒ੾ΕʹͳΔͷ
    Ͱ͸͡Ίʹ݁࿦

    View full-size slide

  12. ·ͩ͸΍͔ͬͨ
    ͳʹ͕͸΍͔͔ͬͨ͸ͳ͍͖ͯ͠·͢

    View full-size slide

  13. w (PPHMF͕։ൃΛ։࢝ͨ͠Φʔϓϯιʔεͷ
    ϦϞʔτϓϩγʔδϟίʔϧ 31$
    γεςϜ
    w )551Λτϥϯεϙʔτͱͯ͠ར༻
    w 1SPUPDPM#VGGFSTΛΠϯλϑΣʔεهड़
    ݴޠͱͯ͠ར༻
    Ҿ༻ɿhttps://ja.wikipedia.org/wiki/GRPC

    View full-size slide

  14. ௨৴ͷछྨ
    w6OBSZ31$
    w4FSWFSTUSFBNJOH31$
    w$MJFOUTUSFBNJOH31$
    w#JEJSFDUJPOBMTUSFBNJOH31$

    View full-size slide

  15. Ҿ༻ɿhttps://grpc.io/docs/guides/

    View full-size slide

  16. Ҿ༻ɿhttps://grpc.io/docs/

    View full-size slide

  17. 1)1΋αϙʔτ
    ͞Ε͍ͯΔ

    View full-size slide

  18. (PPHMFάϧʔϓͷ΍ΓͱΓ
    It appears as of right now you can only create
    CLIENTS in PHP, but not servers. I was
    wondering what the technical blockers behind
    this were and if it's on the roadmap for a future
    release?
    Ҿ༻ɿhttps://groups.google.com/forum/#!topic/grpc-io/F3IyYaI_6S0
    (ҙ༁)PHPͰ͸gRPCͷΫϥΞϯτ͸࡞ΕΔ͚
    Ͳɺαʔόʔ͸࡞Ε·ͤΜɻকདྷతͳϩʔυ
    Ϛοϓ͋Γ·͔͢ʁ

    View full-size slide

  19. (PPHMFάϧʔϓͷ΍ΓͱΓ
    Ҿ༻ɿhttps://groups.google.com/forum/#!topic/grpc-io/F3IyYaI_6S0
    There are several problems with the idea of a gRPC
    server in PHP, and we have no plans for that.
    Basically, the only way it would work, is if you run
    PHP "naked", without its typical nginx or apache
    frontend.
    (ҙ༁)PHPͷgRPCαʔό͸͍͔ͭ͘໰୊͕͋Γɺղ
    ܾํ๏͕ݟ౰ͨΓ·ͤΜ
    جຊతʹɺ།Ұͷํ๏͸ɺnginx·ͨ͸Apacheͷϑ
    ϩϯτΤϯυͳ͠ʹ”ૉ”ͷPHPͰಈ͔͢͜ͱͰ͢

    View full-size slide

  20. 1)1ͰH31$ͷαʔόʔ
    ͸Ͱ͖ͳ͍
    4USFBNJOH͕Ͱ͖ͳ͍ʣ

    View full-size slide

  21. 1)1ࣗ਎͕ιέοτϦεχ
    ϯά͢Ε͹Մೳੑ͸͋Δ

    View full-size slide

  22. 4XPPMFͳΒͰ͖ΔͷͰ͸ʁ

    View full-size slide

  23. 4XPPMFΛ༻͍ͨϑϨʔϜϫʔΫ
    )ZQFSGͳΔ΋ͷ͕͋Δ
    ϦϙδτϦʹHSQDTFSWFSͷ
    ࣮૷͕͋Δʂ
    https://github.com/hyperf/hyperf

    View full-size slide

  24. 4XPPMFΛ༻͍ͨϑϨʔϜϫʔΫʹ
    ͍ͭͯ͸աڈͷࢿྉΛݟ͍ͯͩ͘͞
    https://speakerdeck.com/
    sgeengineer/isucon8deyu-xuan-luo-
    tisitafalsede-swoole-easyswoole-
    deshu-kihuan-ete-gan-xiang-zhan-
    debentizou-rasetemitahua
    https://speakerdeck.com/
    sgeengineer/
    swoolewotukatutahuremuwakusw
    oftwotafalsesimu
    https://speakerdeck.com/
    sgeengineer/
    swoolefalsehuremuwakuwokur
    abetemita

    View full-size slide

  25. H31$ͷ1)1αʔό͍͚Δ
    ͷͰ͸ʁ

    View full-size slide

  26. HSQDJPͷ
    νϡʔτϦΞϧΛ
    )ZQFSGͰ
    ࣮૷ͯ͠ΈΔ

    View full-size slide


  27. 6OBSZ31$4FSWFS
    QSPUPϑΝΠϧ͸͜Μͳײ͡

    View full-size slide


  28. 6OBSZ31$4FSWFS

    View full-size slide


  29. 6OBSZ31$4FSWFS
    ϧʔςΟϯά

    View full-size slide


  30. 6OBSZ
    ɹɹ$MJFOU

    View full-size slide

  31. TUSFBNJOH͸ʁ

    View full-size slide

  32. ΫϥΠΞϯτͷ࣮૷͸͋Δ

    View full-size slide

  33. αʔόʔ͸ແ͍ɾɾɾ

    View full-size slide

  34. w 1)1Ͱ΋H31$͍ͨ͠
    w 4XPPMFΛ࢖ͬͨ)ZQFSG͸
    H31$αʔόαϙʔτ
    w 6OBSZ31$͸Ͱ͖Δ
    w 4USFBNJOH31$͸·ͩ͸
    ΍͔ͬͨ

    View full-size slide

  35. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠

    View full-size slide