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

プロダクションで使うGo Pluginの利便性とパフォーマンス性 / Simplicity and Performance of Go plugin for Production

linyows
December 02, 2023

プロダクションで使うGo Pluginの利便性とパフォーマンス性 / Simplicity and Performance of Go plugin for Production

Dec 2, 2023, Go Conference mini Winter in Kyotoでの発表資料です。

linyows

December 02, 2023
Tweet

More Decks by linyows

Other Decks in Programming

Transcript

  1. 小 田
    Software Engineer
    @Go Conference mini
    2 0 2 3
    Winter in Kyoto
    Go Plugin

    View full-size slide

  2. https://tomohisaoda.com
    🍜
    A
    ff
    i
    liation:
    COGNANO
    Community: Fukuoka.go
    Weight Training
    Tomohisa Oda / @linyows

    View full-size slide

  3. https://research.sakura.ad.jp/
    Mission:

    人 ・ ・文

    Mission:

    View full-size slide

  4. Outline
    1
    . Computing Plugin
    2
    . Go Plugin Mechanism
    3
    . Plugin Mechanism
    4
    . Plugin Mechanism Benchmark

    5
    . Conclusion
    🙏

    View full-size slide

  5. Computing Plugin

    View full-size slide

  6. Plugin
    Plugin
    心 高
    Attack Surface

    Plugin

    Host Application
    Plugins

    .

    View full-size slide

  7. Plugin

    Plugin

    Browser Plugin

    Capability Extension
    Extension

    View full-size slide

  8. Go Plugin Mechanism

    View full-size slide

  9. Plugin

    Host Application

    Shared Library

    Host Application
    API

    CLI

    Host Application Plugin

    View full-size slide

  10. Plugin

    Shared Library

    https://pkg.go.dev/plugin

    API

    https://github.com/hashicorp/go-plugin HashiCorp Products

    Host Plugin GRPC
    CLI

    https://github.com/kubernetes/kubectl git-style

    View full-size slide

  11. Plugin Mechanism

    ⾒ ** **
    Performance Maintainability Deployability Reliability Scalability Security
    Shared Library
    👍 👍 👍 ⏳ ⏳ ⏳
    API
    ⏳ ⏳ ⏳ 👍 👍 👍
    CLI
    ⏳ 👍 👍 👍 ⏳ ⏳

    View full-size slide

  12. Plugin Mechanism

    View full-size slide

  13. SMTP

    Proxy: WARP

    Mail Transfer Agent MTA MTA SMTP

    View full-size slide

  14. SMTP

    Proxy: WARP
    https://github.com/linyows/warp
    Multi-Tenancy
    Plugin
    自 用

    View full-size slide

  15. Shared Library
    力 見
    Multi-Tenancy
    自 自
    用 自
    Performance Maintainability Deployability Reliability Scalability Security
    Shared Library
    👍 👍 👍 ⏳ ⏳ ⏳

    View full-size slide

  16. HashiCorp Products
    API Plugin
    🥢 🏢 🤔 🔌

    View full-size slide

  17. "
    "
    What About Shared Libraries?
    When we started using plugins (late
    2
    0
    1
    2
    , early
    2
    0
    1
    3
    ), plugins over RPC were the only
    option since Go didn't support dynamic library loading. Today, Go supports the plugin
    standard library with a number of limitations. Since
    2
    0
    1
    2
    , our plugin system has stabilized
    from tens of millions of users using it, and has many benefits we've come to value
    greatly.For example, we use this plugin system in Vault where dynamic library loading is not
    acceptable for security reasons. That is an extreme example, but we believe our library
    system has more upsides than downsides over dynamic library loading and since we've had
    it built and tested for years, we'll continue to use it.Shared libraries have one major
    advantage over our system which is much higher performance. In real world scenarios
    across our various tools, we've never required any more performance out of our plugin
    system and it has seen very high throughput, so this isn't a concern for us at the moment.
    https://github.com/hashicorp/go-plugin#what-about-shared-libraries

    View full-size slide

  18. Shared Library
    go-plugin plugin library
    plugin
    go-plugin
    人 用 入 高

    View full-size slide

  19. Plugin
    Plugin
    =>
    面 見
    ok, ok..
    Application Plugin
    v
    1
    .
    21
    .
    4
    v
    1
    .
    20
    .
    1
    1
    🙅

    View full-size slide

  20. Shared Library

    !

    View full-size slide

  21. Plugin
    cgo glibc
    Production
    GoReleaser GitHub Actions
    Production
    Actions

    Self-Hosted Runner
    🙅

    View full-size slide

  22. Plugin Mechanism


    Performance Maintainability Deployability Reliability Scalability Security
    Shared Library
    👍 👍 👍 ⏳ ⏳ ⏳
    API
    ⏳ ⏳ ⏳ 👍 👍 👍
    CLI
    ⏳ 👍 👍 👍 ⏳ ⏳
    ❌ ❌

    View full-size slide

  23. Plugin Mechanism
    Benchmark

    View full-size slide

  24. Shared Library API CLI Benchmark
    Plugin

    echo Web
    Shared Library API 5 CLI 29
    CLI

    一方

    View full-size slide

  25. "
    "
    Warnings
    The ability to dynamically load parts of an application during
    execution, perhaps based on user-defined configuration, may
    be a useful building block in some designs. In particular,
    because applications and dynamically loaded functions can
    share data structures directly, plugins may enable very high-
    performance integration of separate parts. However, the plugin
    mechanism has many significant drawbacks that should be
    considered carefully during the design. For example:

    .
    Ref: https://github.com/golang/go/issues/
    5 68
    93
    https://pkg.go.dev/plugin#hdr-Warnings

    View full-size slide

  26. Plugin
    大 欠
    欠 一
    Go Plugin
    Linux, FreeBSD, macOS
    目 用

    View full-size slide

  27. WASM Plugin Mechanism
    https://github.com/knqyf
    2
    6 3
    /go-plugin
    @knqyf
    2
    6 3

    HashiCorp go-plugin GRPC
    README

    `It uses the same
    de
    fi
    nition as gRPC, but go-plugin
    communicates with plugins in memory, not
    over RPC.`
    WASM Sandbox Secure by Default

    View full-size slide

  28. Conclusion
    Plugin
    一方
    Plugin

    Plugin Production
    一方 高

    View full-size slide