Need Suggestion : CPU is reaching high at 50-60 tps
Hi @dineshgowda24
Thanks for creating this library. Just need your suggestion on the CPU usage. I am seeing very high CPU (~ 80% ) while I am on 50 TPS load test. If I remove the browser detection code. Its come to 10-15%. Did you test the lib against heavy traffic and experience anything like this?
FYI, I am using a 4 VCPU and 16G RAM machine to perform the test.
Example code which I use it for each http request to detect browser from UA.
b, err := browser.NewBrowser(ua)
if err != nil {
return "unknown"
}
return b.Name()
}
@dineshgowda24 Did you get a chance to look at it? any suggestions?
Hey, are you creating a browser instance on each request?
@dineshgowda24 - I am calling the below function on each request. Is there any other way to use it? because, UA is different on each request.
func (r *Request) Browser() string {
if r.UA != nil && r.UA != "" {
b, err := browser.NewBrowser(r.UA)
if err != nil {
return "unknown"
}
return b.Name()
}
return "unknown"
}
Oh yeah! It's been so long since I looked at it.
My suspicion is that since the instance is created on request, it might be causing CPU overhead. I will spend some time over the week validating the hypothesis by running some load tests and compute pprofs and then fixing it if that's the case.
Do u happen to have a flame graph?
@dineshgowda24 Please check this. Attaching the profiling file also
cpu.txt - (added .txt extension just to upload the file, please remove it to use it with pprof tool)
Hi @dineshgowda24 Did you get a chance to look at this? thanks