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

Real World Migration from HTTP to gRPC #CNDT2020

Nao Minami
September 08, 2020

Real World Migration from HTTP to gRPC #CNDT2020

CloudNative Days Tokyo 2020 の発表資料です。Wantedly での gRPC 導入の取り組みについて話しました。

gRPC という通信技術についての詳細な説明から、gPRC を利用することによるメリット、gRPC を利用することで実際に得られたパフォーマンス改善、gRPC への移行を行うための実践的な Tips について話しました。移行の際にはツールやライブラリの開発や開発フローの整備など技術的、組織的な挑戦を行なっており、その詳細についても話しました。

https://event.cloudnativedays.jp/cndt2020/talks/14

Nao Minami

September 08, 2020
Tweet

More Decks by Nao Minami

Other Decks in Technology

Transcript

  1. ©2020 Wantedly, Inc. Real World Migration from HTTP to gRPC

    08.Sep.2020 - Nao Minami (@south37) Wantedly, Inc. CloudNative Days Tokyo 2020
  2. ©2019 Wantedly, Inc. /BP.JOBNJ *OGSBTUSVDUVSF5FBN 8BOUFEMZ *OD (JU)VCTPVUI 5XJUUFSTPVUI ϚΠΫϩαʔϏεؒ௨৴΁ͷH31$ಋೖʹऔΓ૊Ή

     43&ͱͯ͠ͷ໾ׂʢαʔϏεͷ৴པੑʹ੹೚ʣ  ։ൃج൫ͱͯ͠ͷ໾ׂʢΤϯδχΞͷੜ࢈ੑʹ੹೚ʣ
  3. ©2020 Wantedly, Inc. gRPC ͱ͸ Google ੡ͷ high performance ͳ

    RPC framework w 3FNPUF1SPDFEVSF$BMM 31$  w DMJFOU͕ؔ਺ݺͼग़͠SFNPUFTFSWFS্Ͱؔ਺ݺͼग़͕͠ॲཧ͞Εͯ݁Ռ͕ฦ͞ΕΔ w )551Λ௨৴ϓϩτίϧͱͯ͠ར༻ w 1SPUPDPM#V⒎FSTΛαʔϏεఆٛʢTFSWFSͰ࣮૷͞Εͨ ؔ਺ͷܕʣͷهड़ʹར༻ H31$ͷެࣜEPDVNFOUΑΓҾ༻
  4. ©2020 Wantedly, Inc. HTTP/2 ͱ͸ ޮ཰తͳ Hypertext Transfer Protocol (HTTP)

    w (PPHMF੡41%:QSPUPDPM͕ݩʹͳͬͯඪ४Խ w 5SBOTQPSUΛޮ཰Խ͢Δ͍ͭ͘΋ͷ༏ΕͨػೳଟॏԽɺϔομѹॖɺFUD H31$ͷIJHIQFSGPSNBODFʹߩݙ IUUQTEFWFMPQFSTHPPHMFDPNXFCGVOEBNFOUBMTQFSGPSNBODFIUUQΑΓҾ༻
  5. ©2020 Wantedly, Inc. Protocol Buffers ͱ͸ Google ੡ IDL +

    ίϯύΠϥ + serialization library w *OUFSGBDF%FpOJUJPO-BOHVBHF *%- αʔϏεఆٛΛهड़͢ΔͨΊͷಠࣗݴޠ w *%-ͰαʔϏεఆٛΛهड़͢Δͱɺ1SPUPDPM#V⒎FSTίϯύΠϥʢQSPUPDʣ͕ ޮ཰తͳTFSJBMJ[BUJPOͷҝͷίʔυΛࣗಈੜ੒ w αʔϏεఆٛ͸"1*4DIFNBͱͯ͠ͷ໾ׂΛՌͨ͢ 4DIFNB%SJWFO%FWFMPQNFOUͰߴ͍ੜ࢈ੑΛ࣮ݱՄೳ API Schema = proto ϑΝΠϧ 4FSWFS։ൃ $MJFOU։ൃ
  6. ©2020 Wantedly, Inc. എܠ: Wantedly Visit ͱ Wantedly People ͷΞʔΩςΫνϟ

    ໿ 100 ͷϚΠΫϩαʔϏεΛ૊Έ߹Θͤͨ ΞʔΩςΫνϟ w 3VCZ (P 1ZUIPO /PEFKTͳͲ༷ʑͳݴޠͰϚΠΫϩαʔϏεΛ࣮૷ w ݩʑϚΠΫϩαʔϏεؒ௨৴ʹ͸)551Λར༻ LTDMVTUFS $PSF4FSWJDFT
  7. ©2020 Wantedly, Inc. HTTP/1.1 Λར༻͢ΔࣄͰੜ͡Δ௨৴ latency ͕໰୊ w ,FFQBMJWFແ͠ͷૉ๿ͳ)551͸༷ʑͳཁҼͰ஗͘ͳΔ w

    FH%/4MPPLVQ 5$1XBZIBOETIBLF 5$1TMPXTUBSU FUD ՝୊1 ϚΠΫϩαʔϏε -BUFODZDBVTFECZVTJOH)551
  8. ©2020 Wantedly, Inc. ϚΠΫϩαʔϏεͰ͸௨৴ latency ͷӨڹ͕େ͖͍ w ௨৴૬ख͕૿͑Δ΄Ͳɺ௨৴MBUFODZʢಛʹUBJMMBUFODZʣͷӨڹΛड͚΍͘͢ͳΔ w ྫϚΠΫϩαʔϏεؒ௨৴͕ͷ֬཰Ͱ஗͘ͳΔέʔεΛߟ͑Δ

    w ݸͷϚΠΫϩαʔϏεͱ௨৴͢Δ৔߹શମͱͯ͠͸ͷ֬཰Ͱ஗͍ w ݸͷϚΠΫϩαʔϏεͱ௨৴͢Δ৔߹શମͱͯ͠͸ͷ֬཰Ͱ஗͍ w ࣮ࡍʹUBJMMBUFODZͷد༩Ͱ஗͘ͳͬͯΔϚΠΫϩαʔϏε͕ଘࡏͨ͠ w ྫଞͷϚΠΫϩαʔϏεͱͷ௨৴MBUFODZ͕ࢧ഑తͳϚΠΫϩαʔϏεͰ BWFSBHFSFTQPOTFUJNFNTʹରͯ͠UJMFSFTQPOTFUJNF͕ NT ϚΠΫϩαʔϏεؒ௨৴ͷUBJMMBUFODZվળ͕ඞཁͱ͞Ε͍ͯͨ ϚΠΫϩαʔϏεʹ͓͚Δ௨৴ latency ͷ໰୊
  9. ©2020 Wantedly, Inc. Protocol Buffers ͷԸܙΛҰ෦ͷνʔϜͷΈ͕ڗड w ݩʑɺҰ෦νʔϜͰ͸1SPUPDPM#V⒎FSTΛϚΠΫϩαʔϏεͷ"1*4DIFNBͱͯ͠ར༻ 4DIFNB%SJWFO%FWFMPQNFOUͰߴ͍ੜ࢈ੑΛ࣮ݱ ՝୊2

    CVJMEFSTDPOUPLZPl8FC"1*ʹடংΛ༩͑Δ1SPUPDPM#V⒎FSTl w ͔͠͠ɺ1SPUPDPM#V⒎FSTPWFS)551Ͱ͸ʮQBZMPBEΛMJCSBSZ͔Βར༻ͮ͠Β͍ʯ ͳͲ͍͔ͭ͘໰୊͋Γ ࣾ಺શମʹ͸1SPUPDPM#V⒎FSTΛ޿͛ͮΒ͍ঢ়گͩͬͨ
  10. ©2020 Wantedly, Inc. gRPC ͷύϑΥʔϚϯεΛ։ൃ༻ k8s cluster Ͱݕূ w ݩʑɺຊ൪LTDMVTUFSͱ΄΅ಉ͡ߏ੒ͷLTDMVTUFS͕։ൃ༻్ͱͯ͠ଘࡏ

    w ϚΠΫϩαʔϏεͷίʔυΛH31$Λར༻͢Δ΋ͷ΁ͱॻ͖׵͑ͯ-BUFODZΛܭଌ 2-1. ݕূ ຊ൪LTDMVTUFS )551ϚΠΫϩαʔϏε )551 H31$ϚΠΫϩαʔϏε ։ൃ༻LTDMVTUFS 5SZH31$
  11. ©2020 Wantedly, Inc. ௨৴෦෼ͷ latency ͷܶతͳվળΛ؍ଌ w "WFSBHFMBUFODZഒߴ଎Խ NTNT 

    w 5BJMMBUFODZ UJMF ഒߴ଎Խ NTNT Latency [ms] percentile gRPC ։ൃ༻ k8s cluster Ͱͷ Benchmark ݁Ռ HTTP/1.1 20 40 60 80 100 100 150 50 0
  12. ©2020 Wantedly, Inc. gRPC ʹ͓͍ͯ͸ɺL4 load-balancer ͸ෆద੾ w H31$͸)551Λ׆༻ͯ͠ʮҰ౓ཱ֬ͨ͠MPOHMJWFEͳ5$1DPOOFDUJPOΛԿ౓΋ SFRVFTUʹར༻͢Δʯલఏͷઃܭ

    w -MPBECBMBODFS͸5$1DPOOFDUJPOཱ֬ͷෛՙ෼ࢄ͔͠ߦΘͳ͍ͨΊɺH31$Ͱ͸ USB⒏Dͷෛՙ෼ࢄ͕͏·͘ߦΘΕͳ͍ Load Balancing ௨৴૬ख͕ݻఆ͞ΕΔ
  13. ©2020 Wantedly, Inc. ղܾࡦ: Istio Λ L7 load-balancing ʹར༻ w

    *TUJP͸ɺ,VCFSOFUFTͳͲͰར༻Ͱ͖ΔαʔϏεϝογϡɾϓϥοτϑΥʔϜ w *TUJPʹΑͬͯDPOpHVSF͞Εͨ&OWPZΛTJEFDBSQSPYZͱͯ͠JOKFDUͯ͠ɺ -MPBECBMBODJOHʹར༻ͨ͠ Load Balancing &OWPZ
  14. ©2020 Wantedly, Inc. Monitoring gRPC server ͷϞχλϦϯάΛͲ͏࣮ݱ͢Δ͔ʁ => gRPC interceptor

    Λར༻ w H31$JOUFSDFQUPSΛར༻͢ΔࣄͰɺʮH31$SFRVFTUSFTQPOTFͷϥΠϑαΠΫϧʹ NFUSJDTૹ৴ͳͲͷ೚ҙͷॲཧΛࠩ͠ࠐΉʯ͜ͱ͕Մೳ $MJFOUH31$JOUFSDFQUPST $MJFOU 4FSWFSH31$JOUFSDFQUPST 4FSWFS 3FRVFTU 3FTQPOTF
  15. ©2020 Wantedly, Inc. ͳͥϢʔβʔαʔϏεΛબΜͩͷ͔ʁ ಛ௃: traffic ͕ଟ͘ low latency ͕ඞཁ

    w ଟ͘ͷϚΠΫϩαʔϏε͔Βར༻͍ͯ͠ΔͨΊUSB⒏D͕ଟ͍ w Ϣʔβʔ͔ΒͷSFRVFTUॲཧͰಉظతʹSFRVFTU͞ΕΔέʔεଟ਺MPXMBUFODZ͕ඞཁ H31$ಋೖʹΑΔΠϯύΫτ͕ݦஶʹݱΕΔ͜ͱ͕ظ଴ग़དྷΔ ϢʔβʔαʔϏε Ϣʔβʔͷઃఆ஋΍ϓϩϑΟʔϧͷऔಘɾߋ৽
  16. ©2020 Wantedly, Inc. k8s objects Λ 2 ηοτ༻ҙ w ύϑΥʔϚϯεಛੑͳͲ͕ҧ͏ͷͰɺ%FQMPZNFOUͱ)1"Λݸผʹ༻ҙ

    w )5513VCZPO3BJMTTFSWFS͕ىಈ͢Δ%FQMPZNFOU )1" 4FSWJDF w H31$H31$TFSWFS͕ىಈ͢Δ%FQMPZNFOU )1" 4FSWJDF w $MJFOUଆͰ௨৴ઌIPTU໊ LT4FSWJDF Λ੾Γସ͑ͯ௨৴खஈΛ੍ޚ gRPC ಋೖͷਐΊํ H31$ H31$TFSWFS $MJFOUϚΠΫϩαʔϏε )551 3VCZPO3BJMT
  17. ©2020 Wantedly, Inc. Client ϚΠΫϩαʔϏεͰ gRPC ͷར༻Λ૿΍͢ w Ұ෦ϦΫΤετʹH31$Λಋೖ༷ͯ͠ࢠΛݟͳ͕Βɺঃʑʹׂ߹Λ૿Ճ׬શʹҠߦ gRPC

    ಋೖͷਐΊํ ϢʔβʔαʔϏε ϢʔβʔαʔϏε )551  H31$  H31$ͷׂ߹Λ૿Ճ )551  H31$  $MJFOU $MJFOU
  18. ©2020 Wantedly, Inc. gRPC ΛҰ෦ϚΠΫϩαʔϏεʹಋೖͨ݁͠Ռ ௨৴෦෼ͷ Latency ͕ܶతʹվળ w ϢʔβʔαʔϏεͱͷ௨৴ͷBWFSBHFMBUFODZ͕SFRVFTU͋ͨΓ໿NTվળ

    w ౓ͷSFRVFTUॲཧͷதͰϢʔβʔαʔϏε΁Կ౓΋SFRVFTU͢Δέʔε͕ଘࡏ ௨৴ͷBWFSBHFMBUFODZ͕਺े਺ඦͷܶతվળ e.g. ϢʔβʔαʔϏε௨৴෦෼ͷ average latency ͕ 153ms ͔Β 45ms ʹ 240% վળͨ͠ྫ HTTP/1.1 gRPC
  19. ©2020 Wantedly, Inc. gRPC ΛҰ෦ϚΠΫϩαʔϏεʹಋೖͨ݁͠Ռ શͯͷॲཧΛؚΉ response time ΋ݦஶʹվળ w

    ϢʔβʔαʔϏεͱͷ௨৴͕ଟ͍FOEQPJOU͸ɺશମͷSFTQPOTFUJNF΋ܶతʹվળ w શମͱͯ͠ૣ͘ͳ͚ͬͨͩͰͳ͘ɺʮۃ୺ʹ஗͘ͳΔέʔεʯ͕ܹݮͨ͠ 5BJMMBUFODZվળͷޮՌΛ࣮ײ UJMFSFTQPOTFUJNF HTTP/1.1 gRPC e.g. 99%tile response time ͷϐʔΫ͕ 5,000ms ͔Β 1,900ms ʹ 3,000ms Ҏ্վળͨ͠ྫ
  20. ©2020 Wantedly, Inc. Ͳ͏΍ͬͯ proto ϑΝΠϧΛڞ༗͢Δ͔ʁ w खಈ$PQZ1BTUFʁ ෳ਺SFQPTJUPSZΛ੔߹ੑΛอͬͯߋ৽͠ଓ͚Δͷ͕೉͍͠ w

    QSPUPϑΝΠϧΛࣗಈμ΢ϯϩʔυ͢ΔػߏΛ༻ҙ͢Δʁ ֤ϨϙδτϦͷ։ൃऀ͕ίʔυੜ੒Λߦ͏ඞཁ͕͋ΓɺQSPUPDWFSTJPO΍ QMVHJOͷ༗ແͳͲɺ։ൃऀؒͷ؀ڥͷҧ͍ʹۤ͠Ή ͦ͜Ͱɺcentral repository Λ༻ҙͨ͠ εΩʔϚ؅ཧ = proto ϑΝΠϧ؅ཧ
  21. ©2020 Wantedly, Inc. “apis” repository ΛͲ͏ར༻͢Δͷ͔ʁ “apis” ͷ CI ύΠϓϥΠϯͰίʔυੜ੒͕ߦΘΕΔ

    w 3VCZ (P 1ZUIPO /PEFKTͦΕͧΕͷݴޠ޲͚ͷίʔυΛQSPUPϑΝΠϧ͔Βੜ੒ w ੜ੒͞Εͨίʔυ͸֤ݴޠͷ1BDLBHF.BOBHFSͰ഑৴ FH#VOEMFS (P.PEVMFT FUD  w ։ൃऀ͕ࣗ෼Ͱίʔυੜ੒Λߦ͏ඞཁ͕ͳ͍ঢ়ଶΛ࣮ݱ
  22. ©2020 Wantedly, Inc. ֤ݴޠ޲͚ʹϥΠϒϥϦͰ֤छػೳΛఏڙ w ݴޠ w 3VCZ (P 1ZUIPO

    /PEFKT w ػೳ w H31$4FSWFS $MJFOU։ൃ༻VUJMJUZ w H31$JOUFSDFQUPST w 1SPUPDPM#V⒎FSTར༻ͷͨΊͷVUJMJUZ ϥΠϒϥϦ੔උ
  23. ©2020 Wantedly, Inc. “servicex” ͱݺ͹ΕΔࣾ಺ڞ௨ library Λར༻ w ݩʑɺ)551ͷ࣌୅͔ΒʮͲͷϚΠΫϩαʔϏε͔Β΋ڞ௨Ͱ࢖ΘΕΔػೳʯΛ TFSWJDFYͰఏڙ͖ͯͨ͠H31$։ൃΛศརʹ͢ΔMJCSBSZ΋TFSWJDFYͰఏڙ

    w TFSWJDFY͸֤ݴޠ޲͚ʹଘࡏ w 3VCZ (P 1ZUIPO ϥΠϒϥϦ͸Ͳ͏͍ͬͨܗͰ੔උͨ͠ͷ͔ʁ ϚΠΫϩαʔϏε" ϚΠΫϩαʔϏε# ϚΠΫϩαʔϏε$ lTFSWJDFYz
  24. ©2020 Wantedly, Inc. gRPC server ։ൃͷͨΊͷ grpc-server ίϚϯυ w H31$TFSWJDFDMBTT͸ࣗಈͰIBOEMFSͱͯ͠ొ࿥

    w H31$JOUFSDFQUPS΋ඞཁͳ΋ͷ͸ࣗಈͰઃఆ w 3VCZPO3BJMTͷΑ͏ͳ)PUSFMPBEJOHػೳΛఏڙ w ։ൃऀ͸ɺH31$TFSWJDFDMBTTͷ࣮૷ʹूதߴ͍ੜ࢈ੑΛ࣮ݱ “servicex-ruby” ͷػೳ $ bundle exec grpc-server handling /grpc.health.v1.Health/Check with #<Method: Grpc::Health::Checker#check> handling /grpc.health.v1.Health/Watch with #<Method: Grpc::Health::Checker(Grpc::Health::V1::Health::Service)#watch> handling /wantedly.users.UserService/ListUsers with #<Method: UsersGrpcService#list_users> . . . gRPC server starting... * Listening on tcp://0.0.0.0:6046 * Environment: development
  25. ©2020 Wantedly, Inc. gRPC client ͷͨΊͷ Servicex::Grpc.stub_for w H31$JOUFSDFQUPSͱͯ͠ඞཁͳ΋ͷ͸ࣗಈͰઃఆ w

    6TFS"HFOU΋ࣗಈͰઃఆ w ։ൃऀ͸ʮH31$ͷ࢖͍ํʯΛؾʹ͢Δࣄͳ͘ɺϩδοΫͷ࣮૷ʹूதߴ͍ੜ࢈ੑ # NOTE: Load UsersPb::UserService from apis require "wantedly/users/users_services_pb" grpc_server_url = “xxx” client = Servicex::Grpc.stub_for( UsersPb::UserService, grpc_server_url, ) client.get_user(UsersPb::GetUserRequest.new(…)) “servicex-ruby” ͷػೳ
  26. ©2020 Wantedly, Inc. Pb: Protocol Buffers ͷར༻Λ؆୯ʹ͢Δ utility w 1CΛར༻͢ΔࣄͰQSPUPCVGPCKFDUΛ؆୯ʹ࡞੒Մೳ

    w ྫ͑͹ɺ4USJOH͔ΒUJNFTUBNQΦϒδΣΫτΛ࡞੒͢Δ͜ͱ͕Մೳ [1] pry(main)> Pb.to_timestamp("2019-05-15T00:00:00+09:00") => <Google::Protobuf::Timestamp: seconds: 1557846000, nanos: 0> 8JUIl1Cz [1] pry(main)> Google::Protobuf::Timestamp.new( [1] pry(main)* seconds: Time.parse("2019-05-15T00:00:00+09:00").to_i [1] pry(main)* ) => <Google::Protobuf::Timestamp: seconds: 1557846000, nanos: 0> 8JUIPVUl1Cz “servicex-ruby” ͷػೳ
  27. ©2020 Wantedly, Inc. “grapi” + “servicex-go” Λར༻ w HSBQJH31$ HSQDHBUFXBZߏ੒ͷ"1*TFSWFS޲͚DPEFHFOFSBUPS

    MJCSBSZ 044  w H31$TFSWFS୯ಠར༻΋Մೳ w TFSWJDFYHPHSBQJͷਪ঑ઃఆ H31$JOUFSDFQUPS౳Λఏڙ͢Δࣾ಺ڞ௨MJCSBSZ Go ͷ gRPC ։ൃ؀ڥ (P$POGFSFODF4QSJOH lHSBQJ#VMEJOH+40/"1*TFSWFSXJUIHSQDHBUFXBZGPSNJDSPTFSWJDFTz
  28. ©2020 Wantedly, Inc. Go ͷ gRPC ։ൃ؀ڥ package main import

    ( ... "github.com/izumin5210/grapi/pkg/grapiserver" "github.com/wantedly/servicex-go/v2/pkg/servicex" "github.com/wantedly/servicex-go/v2/pkg/grpcx" "github.com/wantedly/spath/to/server" ) func InitializeGrapiServerEngine(ctx context.Context) (*grapiserver.Engine, error) { userServiceServer := server.NewUserServiceServer(ctx) engine := grapiserver.New( grpcx.WithDefault(), grapiserver.WithServers(userServiceServer), ) return engine, nil } func run() error { ctx := context.Background() defer servicex.Close() s, err := InitializeGrapiServerEngine(ctx) if err != nil { return fail.Wrap(err) } return s.ServeContext(ctx) }
  29. ©2020 Wantedly, Inc. “servicex-python” ͱ͍͏ࣾ಺ڞ௨ library Λར༻ w lHSQDYzQBDLBHFͱͯ͠HSQDY4FSWFSDMBTTͳͲͷVUJMJUZΛ༻ҙ w

    ։ൃऀ͸ɺH31$TFSWJDFDMBTTͷ࣮૷ʹूதߴ͍ੜ࢈ੑΛ࣮ݱ Python ͷ gRPC ։ൃ؀ڥ import servicex.grpcx as grpcx class UserService(users_pb2_grpc.UserServiceServicer): ... server = grpcx.Server( port=os.getenv("APP_GRPC_PORT", "3000"), max_workers=10, grpc_services=[ grpcx.ServiceInfo( name=users_pb2.DESCRIPTOR.services_by_name['UserService'].full_name, adder=users_pb2_grpc.add_UserServiceServicer_to_server, servicer=UserService(), ) ] ) server.run()
  30. ©2020 Wantedly, Inc. gRPC client ։ൃʹ͸ grpc package Λ௚઀ར༻ w

    1ZUIPO͸.-ϚΠΫϩαʔϏεͱͯ͠຤୺Ͱͷར༻͕ଟ͍ H31$DMJFOUར༻͸গͳ͘VUJMJUZͷχʔζ͸গͳ͍ w χʔζ͕૿͑ͨλΠϛϯάͰࣾ಺ڞ௨MJCSBSZԽͷ༧ఆ Python ͷ gRPC ։ൃ؀ڥ from grpc.experimental import aio class UsersService: def __init__(self) -> None: self.base_url = ... async def get(self, user_id: int) -> users_pb2.User: async with aio.insecure_channel(target=self.base_url) as channel: stub = users_pb2_grpc.UserServiceStub(channel) req = users_pb2.GetUserRequest(...) res = await stub.GetUser(req, timeout=2) return res.user #SPXTFS H31$ 1ZUIPO.-ϚΠΫϩαʔϏε
  31. ©2020 Wantedly, Inc. Node.js ੡ Backend for Frontend (BFF) Ͱ

    gRPC client Λར༻ w 6UJMJUZMJCSBSZΛར༻͢ΔࣄͰɺH31$DMJFOUΛར༻ͨ͠։ൃΛޮ཰Խ w lBQJTOPEFzͰܕఆٛϑΝΠϧΛੜ੒ͯ͠5ZQF4DSJQUͷ੩తܕݕࠪʹ׆༻ Node.js ͷ gRPC ։ൃ؀ڥ /PEFKT#'' (SBQI2- H31$ )551 #SPXTFS import { UserServiceClient, IUserServiceClient, } from "@wantedly_private/apis-node/path/to/users_pb"; import { serviceClientCreator } from "../../utils/grpc/"; export class UserService extends serviceClientCreator<IUserServiceClient>( UserServiceClient, “127.0.0.1:3000”, ) {}
  32. ©2020 Wantedly, Inc. લఏ: ։ൃνʔϜʹ gRPC ͷར༻Λڧ੍͸ग़དྷͳ͍ w ։ൃνʔϜ͸ͦΕͧΕ͕ʮࣗ෼ͨͪͷ࠾༻͢Δٕज़ελοΫʯΛબఆ 3-2.

    ࣾ಺΁એ఻ͯ͠޿͍͛ͯ͘ Infra (k8s, gRPC, etc.) ։ൃ νʔϜ A w ج൫ΛUPPMMJCSBSZͱͯ͠ఏڙ w LTͷ֦ு౳ʢFHDVTUPNDPOUSPMMFSʣ w ϓϩμΫτΛ։ൃ w ࣗ෼ͨͪͰٕज़બఆ ։ൃ νʔϜ B ։ൃ νʔϜ C
  33. ©2020 Wantedly, Inc. gRPC ͕ࣾ಺Ͱ޿͘ར༻͞ΕΔΑ͏ʹͳͬͨ w ΞΫςΟϒʹ։ൃ͞Ε͍ͯΔओཁͳϚΠΫϩαʔϏε͕H31$Խ w ৽نͷϚΠΫϩαʔϏε։ൃʹ͸΄΅H31$Λར༻ w

    όοΫΤϯυ։ൃऀͷ໿ׂ͕H31$Λར༻ͨ͠։ൃΛܦݧ gRPC Λࣾ಺ʹ޿ΊΔऔΓ૊Έͷ݁Ռ )551 H31$ ϢʔβʔαʔϏε $PSF4FSWJDFT
  34. ©2020 Wantedly, Inc. ϚΠΫϩαʔϏεͷύϑΥʔϚϯε͕վળग़དྷͨ w H31$͕޿͘ར༻͞ΕΔΑ͏ʹͳͬͨࣄͰɺଟ͘ͷFOEQPJOUͰԸܙΛड͚ΔΑ͏ʹͳͬͨ Protocol Buffers Λར༻ͨ͠։ൃ͕޿͕ͬͨ w

    H31$͕޿·ͬͨ݁Ռɺଟ͘ͷ։ൃऀ͕1SPUPDPM#V⒎FSTΛར༻͢ΔΑ͏ʹͳͬͨ εΩʔϚۦಈ։ൃͷԸܙΛड͚ΒΕΔػձ͕૿͑ͨ gRPC ͕޿·ͬͨ݁Ռ
  35. ©2020 Wantedly, Inc. ύϑΥʔϚϯε΍։ൃੜ࢈ੑͷ؍఺Ͱ gRPC ʹண໨ w ՝୊)551ͷ௨৴MBUFODZ w ՝୊1SPUPDPM#V⒎FSTʹΑΔ։ൃੜ࢈ੑ޲্ͷԸܙ͕Ұ෦νʔϜʹݶఆ

    ૉૣ͘ಋೖ͠։ൃ؀ڥ੔උΛߦ্ͬͨͰར༻Λ޿͛ͨ w Ұ෦ͷϚΠΫϩαʔϏεͰH31$Λૉૣ͘ݕূɾಋೖ w ϝϦοτૌٻ΍ࣾ಺ษڧձͱͱ΋ʹ஍ಓʹίʔυΛมߋ͠ɺࣾ಺ʹ޿Ίͨ ͦͷ݁Ռ gRPC ͸޿͘࢖ΘΕΔΑ͏ʹͳͬͨ w ଟ਺ͷϚΠΫϩαʔϏεͰH31$͕ར༻͞ΕͯύϑΥʔϚϯε͕վળ w ଟ਺ͷ։ൃऀ͕H31$Λར༻͢ΔࣄͰɺ૊৫શମͱͯ͠։ൃੜ࢈ੑ͕޲্ ·ͱΊ