2
Im使用gocraft/health來檢查我的服務的健康狀況並確定每個endPoint的指標。但我有一個問題: CPU開始服務5小時後達到100%我不知道爲什麼。 不使用「gocraft /健康」它只需0.7%的CPU 的沒有人Golang:gocraft/health package 100%CPU
var stream = health.NewStream()
func main() {
// Log to stdout! (can also use WriterSink to write to a log file, Syslog, etc)
stream.AddSink(&health.WriterSink{os.Stdout})
http.HandleFunc("/api/getVastPlayer", vastPlayer)
http.HandleFunc("/static/", func(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, r.URL.Path[1:])
})
log.Println("Listening...")
panic(http.ListenAndServe(":2001", nil))
}
之前,這個包工作;
func vastPlayer(w http.ResponseWriter, r *http.Request) {
job_1 := stream.NewJob("/api/getVastPlayer")
//job_2 := stream.NewJob("/api/html/")
sink := health.NewJsonPollingSink(time.Minute*5, time.Minute*5)
stream.AddSink(sink)
//http://creative.health.spoti.io/health
adr:="127.0.0.1:5001"
sink.StartServer(adr)
......
......
if bol{
job_1.Complete(health.Success)
}
else{
job_1.Complete(health.ValidationError)
}
您使用('bugsnag','statsd'等)下沉?你使用'健康'嗎? – lnmx
您是否嘗試過配置文件以查看CPU的使用情況? – JimB
免責聲明:還沒有使用過這個庫,但沒有檢查出源代碼。您是否在每個傳入的http請求中移除您在vastPlayer處理程序中添加的接收器? 「stream」對象似乎遍歷所有的Sink實例,並且它似乎在每個請求中都添加了一個接收器。 –