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

なぜ Go はマイクロサービスのための言語なのか - Why Go is a language for microservices

Kohei
July 13, 2019

なぜ Go はマイクロサービスのための言語なのか - Why Go is a language for microservices

Kohei

July 13, 2019
Tweet

More Decks by Kohei

Other Decks in Technology

Transcript

  1. ͳͥ Go ͸ϚΠΫϩαʔϏεͷͨΊͷݴޠͳͷ͔
    Kohei Kimura
    Software Engineer at Nulab Inc.
    @cohhei

    View full-size slide

  2. ☝ࠓ೔Ұ൪ݴ͍͍ͨ͜ͱ☝

    View full-size slide

  3. εϙϯαʔηογϣϯͰ͸
    ͋Γ·ͤΜ
    ※ͪΌΜͱϓϩϙʔβϧॻ͖·ͨ͠ɻ΄Ίͯɻ

    View full-size slide

  4. SIerɺࠃ಺Ϋϥ΢υϕϯμʔΛܦͯ2018೥1݄ Nulab ೖࣾ
    Cacoo νʔϜͷόοΫΤϯυΤϯδχΞ
    ։ൃݴޠ ΄΅ ≡, ·Εʹ Java, Node.js
    ొஃ࣮੷
    Kubernetes Meetup Tokyo #14
    CloudNative Days Fukuoka 2019
    AWS Summit Osaka
    Kohei Kimura
    @cohhei

    View full-size slide

  5. Ϋϥ΢υωΠςΟϒ΍ͬͯ·͔͢ʁ

    View full-size slide

  6. Ϋϥ΢υωΠςΟϒͱ͸
    εέʔϥϒϧͳΞϓϦέʔγϣϯΛߏங͓Αͼ࣮ߦ͢ΔͨΊͷٕज़ͷ૯শ
    ୅දతͳٕज़: ίϯςφɺαʔϏεϝογϡɺϚΠΫϩαʔϏεɺ
    ΠϛϡʔλϒϧΠϯϑϥετϥΫνϟɺએݴܕAPI
    ճ෮ੑʢresilientʣɺ؅ཧ͠΍͢͞ʢmanageableʣɺՄ؍ଌੑ
    ʢobservableʣ͕ಘΒΕΔ

    View full-size slide

  7. ίϯςφɺCI/CDɺΦʔέετϨʔ
    γϣϯ…
    ͑ɺαʔϏεϓϩΩγɾϝογϡɾ
    σΟεΧόϦʔͰ΍ͬͱ൒෼ʁ
    ಓͷΓ͸௕͍…

    View full-size slide

  8. Ϋϥ΢υωΠςΟϒ͸প

    View full-size slide

  9. https://www.youtube.com/watch?v=1qVj1vXbuX0
    ෳࡶɺ৑௕
    ॲཧͷݪ࢝ੑɺҰ؏ੑͷ೉͠͞
    ؅ཧίετͷ૿େ

    View full-size slide

  10. ࠓ೔ͷ࿩ɿ ͸͍͍ͧ

    View full-size slide

  11. Go ͕ Google Ͱੜ·ΕͨܦҢ
    ແ਺ͷϋʔυ΢ΣΞɺແ਺ͷιϑτ΢ΣΞ
    Լ͕Γଓ͚Δ։ൃޮ཰ʹର߅͢Δ

    View full-size slide

  12. "Go was designed by and for people who write
    —and read and debug and maintain—large
    software systems."
    Rob Pike, Go at Google

    View full-size slide

  13. ͳͥ Go ͸ϚΠΫϩαʔϏεͷͨΊͷݴޠͳͷ͔
    https://blog.docker.com/2019/02/weve-got-❤%EF%B8%8F-for-our-first-batch-of-dockercon-speakers/
    ཧ༝: Ϋϥ΢υωΠςΟϒͱͷ
    ૬ੑ͕ʮ͹ΓΑ͔ʯ
    γϯάϧόΠφϦɺߴ଎ͳϏϧυɺলϝϞϦ

    View full-size slide

  14. Docker and Go

    View full-size slide

  15. FROM golang:1.7.3
    WORKDIR /go/src/github.com/alexellis/href-counter/
    RUN go get -d -v golang.org/x/net/html
    COPY app.go .
    RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
    FROM alpine:latest
    RUN apk --no-cache add ca-certificates
    WORKDIR /root/
    COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
    CMD ["./app"]
    ΈΜͳ͍͖ͩ͢
    multi-stage builds

    View full-size slide

  16. FROM golang:1.7.3
    WORKDIR /go/src/github.com/alexellis/href-counter/
    RUN go get -d -v golang.org/x/net/html
    COPY app.go .
    RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
    FROM alpine:latest
    RUN apk --no-cache add ca-certificates
    WORKDIR /root/
    COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
    CMD ["./app"]
    ΈΜͳ͍͖ͩ͢
    multi-stage builds
    Ϗϧυ༻ͷεςʔδ

    View full-size slide

  17. FROM golang:1.7.3
    WORKDIR /go/src/github.com/alexellis/href-counter/
    RUN go get -d -v golang.org/x/net/html
    COPY app.go .
    RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o app .
    FROM alpine:latest
    RUN apk --no-cache add ca-certificates
    WORKDIR /root/
    COPY --from=0 /go/src/github.com/alexellis/href-counter/app .
    CMD ["./app"]
    ΈΜͳ͍͖ͩ͢
    multi-stage builds
    ࣮ߦ༻ͷεςʔδ
    Go ͸Πϯετʔϧ͞Ε͍ͯͳ͍
    Ϗϧυ༻ͷεςʔδ͔Β
    ϑΝΠϧΛίϐʔ

    View full-size slide

  18. Observability and Go

    View full-size slide

  19. Clients
    Server Side
    ࡶͳ Microservices
    Ͳ͜ͰԿ͕͓͖ͯΔ͔
    Θ͔Βͳ͍໰୊

    View full-size slide

  20. Observability
    Metrics
    Trasing Logging

    View full-size slide

  21. Ұ൪͸͡Ίʹ͖ͯΔ͎ʙʂ
    (” ՞ਊ ՞)”řŐŖŘ!!

    View full-size slide

  22. https://zipkin.apache.org

    View full-size slide

  23. Observability
    Metrics
    Trasing Logging

    View full-size slide

  24. https://prometheus.io/

    View full-size slide

  25. (” ՞ਊ ՞)”řŐŖŘ!!
    https://prometheus.io/

    View full-size slide

  26. https://prometheus.io/docs/guides/go-application/

    View full-size slide

  27. ʢΞϓϦଆ͸ʣಋೖ͕؆୯
    ࢓૊Έ͕Ͱ͖Ε͹௥Ճɾߋ৽΋ൺֱత؆୯
    πʔϧΛऔΓೖΕΔ͜ͱͰϕετϓϥΫςΟεΛ
    ͱΓ͜Ή

    View full-size slide

  28. ΦʔϓϯιʔεͷRPCϑϨʔϜϫʔΫ
    RPC = Remote Procedure Call
    ΠϯλʔϑΣʔεΛ Protocol Buffers Ͱࣗಈੜ੒
    ҟͳΔݴޠͰ࢖༻Մೳ
    HTTP/2
    ૒ํ޲ετϦʔϛϯά

    View full-size slide

  29. Protocol Buffers Ͱఆٛ
    → ίʔυੜ੒Λ࣮ߦ
    → ΫϥΠΞϯτͱαʔόʔͷΠϯλʔ
    ϑΣʔεɺܕͷίʔυ͕ੜ੒

    View full-size slide

  30. ৄ͘͠͸ @vvvatanabe ʹฉ͍͍ͯͩ͘͞

    View full-size slide

  31. ʹ͓͚Δ Proto ϑΝΠϧͱੜ੒ͨ͠ίʔυͷ؅ཧ

    View full-size slide

  32. Protofiles
    Git repositories
    Generated code
    Generate
    Webhook
    git push origin develop/
    beta/master
    Protocol Buffers ϑΝΠϧ͸୯ҰͷϦϙδτϦͰ؅ཧ
    ϑΝΠϧ͕ߋ৽͞ΕΔͱ
    → Jenkins ্Ͱ Java ͱ Go ͷίʔυੜ੒
    → ଞϓϩδΣΫτ͸ dep ensure ͳͲͰऔಘ
    Protofilesͱੜ੒͞Εͨίʔυͷϒϥϯν͸Ұக
    Other applications
    Generated code

    View full-size slide

  33. ͸͍͍ͧ
    ͍͞͝ʹ

    View full-size slide

  34. Diagram
    ΦϯϥΠϯ௨࿩͠ͳ͕Βڞಉฤू
    ͦͷ৔Ͱࢿྉ࡞੒
    ը໘ڞ༗͸ෆཁ
    ݴޠͰ఻ΘΓʹ͍͘͜ͱ΋ਤͰઆ໌

    View full-size slide

  35. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ
    ݟ͔͚ͨΒ੠͔͚͍ͯͩ͘͞ɻ
    Kohei Kimura
    Software Engineer at Nulab Inc.
    @cohhei

    View full-size slide