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

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

PHPConferenceTokyo2019のLT発表資料です

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

Ec2fcdc4ea7905b289967a2c4c43e154?s=128

CyberAgent SGE Engineer

December 01, 2019
Tweet

Transcript

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

  2. • גࣜձࣾαΠόʔΤʔδΣϯτ • 4(&౷ׅຊ෦ٕज़౷ׅࣨࣨ௕ • ࢠձࣾࣾ$50 • גࣜձࣾ$SBGU&HH • גࣜձࣾαϜβοϓ

    • നҪɹӳ • ΤϯδχΞ • #MPH IUUQBNFCMPKQHPPEPP ͓લɺ୭Α • 5XJUUFS !HPPEPP • %2 ͙ͪ͢Ή '# 
 ϓΫϦϙ ཱྀܳਓ
  3. "HFOEB w͸͡Ίʹ wH31$ wH31$ͱ1)1 w1)1ͷ࣮૷ w·ͱΊ

  4. ͸͡Ίʹ

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

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

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

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

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

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

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

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

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

  14. H31$

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

    Ҿ༻ɿhttps://ja.wikipedia.org/wiki/GRPC
  16. ௨৴ͷछྨ w6OBSZ31$ w4FSWFSTUSFBNJOH31$ w$MJFOUTUSFBNJOH31$ w#JEJSFDUJPOBMTUSFBNJOH31$

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

  18. H31$ͱ1)1

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

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

  21. ͕

  22. (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ͷΫϥΞϯτ͸࡞ΕΔ͚ Ͳɺαʔόʔ͸࡞Ε·ͤΜɻকདྷతͳϩʔυ Ϛοϓ͋Γ·͔͢ʁ
  23. (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Ͱಈ͔͢͜ͱͰ͢
  24. 1)1ͰH31$ͷαʔόʔ ͸Ͱ͖ͳ͍ 4USFBNJOH͕Ͱ͖ͳ͍ʣ

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

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

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

  28. 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
  29. H31$ͷ1)1αʔό͍͚Δ ͷͰ͸ʁ

  30. 1)1ͷ࣮૷

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

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

  33.  6OBSZ31$4FSWFS

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

  35.  6OBSZ$MJFOU

  36.  6OBSZ ɹɹ$MJFOU

  37. ࣮ߦ

  38. TUSFBNJOH͸ʁ

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

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

  41. ·ͱΊ

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

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