gpt4 book ai didi

go - 可以在生产中使用 golang pprof 而不影响性能吗?

转载 作者:行者123 更新时间:2023-12-01 20:08:15 91 4
gpt4 key购买 nike

我对 pprof 有点陌生工具,我想知道在生产中继续运行它是否可以。从我看过的文章来看,它似乎还可以且标准,但是我很困惑这不会影响性能,因为它进行了采样 N每秒一次,为什么这不会导致性能下降。

最佳答案

Jaana Dogan确实在她的文章“Continuous Profiling of Go programs”中说

Profiling in production

pprof is safe to use in production.
We target an additional 5% overhead for CPU and heap allocation profiling.

The collection is happening for 10 seconds for every minute from a single instance. If you have multiple replicas of a Kubernetes pod, we make sure we do amortized collection.
For example, if you have 10 replicas of a pod, the overhead will be 0.5%. This makes it possible for users to keep the profiling always on.

We currently support CPU, heap, mutex and thread profiles for Go programs.

Why?

Before explaining how you can use the profiler in production, it would be helpful to explain why you would ever want to profile in production. Some very common cases are:

  • Debug performance problems only visible in production.
  • Understand the CPU usage to reduce billing.
  • Understand where the contention cumulates and optimize.
  • Understand the impact of new releases, e.g. seeing the difference between canary and production.
  • Enrich your distributed traces by correlating them with profiling samples to understand the root cause of latency.

因此,如果您使用的是 pprof出于正确的原因,是的,您可以将其留在生产中。
但是对于基本监控,正如评论的那样,该系统就足够了。
正如 Continuous Profiling and Go 在“ Vladimir Varankin ”中所述

Depending on the state of the infrastructure in the company, an “unexpected” HTTP server inside the application’s process can raise questions from your systems operations department ;)

At the same time, depending on the peculiar nature of a company, the very ability to access something inside a production application, that doesn’t directly relate to application’s business logic, can raise questions from the security department ;)) I


因此,在启用此类功能时,开销并不是要考虑的唯一标准。

关于go - 可以在生产中使用 golang pprof 而不影响性能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64057727/

91 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com