Skip to content

Investigating performance issues

Alexander Emelin edited this page Oct 14, 2021 · 7 revisions

First step to investigate what's going on with your Centrifugo is looking at information provided by info command. There are 2 ways to get this information:

  • send info command with HTTP API client
  • send info command from actions tab of admin web interface

In general you should configure Centrifugo monitoring to periodically send Centrifugo metrics to external monitoring system.

But sometimes looking at metrics is not enough. In this case you can additionally capture CPU and heap profiles from running Centrifugo node.

To be able to do this Centrifugo must be run with debug configuration option enabled:

centrifugo --config=config.json --debug

Or with "debug": true in configuration file.

When debug enabled extra HTTP handlers become available on internal port.

Assuming your Centrifugo address is https://centrifugo.example.com then go to https://centrifugo.example.com/debug/pprof/ and you will find debug information.

If you modified internal address or port when starting Centrifugo you should use that custom address and port to access debug data.

To capture CPU profile:

curl "https://centrifugo.example.com/debug/pprof/profile" > /tmp/cpu.profile

To capture heap memory profile:

curl "https://centrifugo.example.com/debug/pprof/heap" > /tmp/heap.profile

To capture goroutine dump:

curl "https://centrifugo.example.com/debug/pprof/goroutine?debug=1" > /tmp/goroutine.txt

All profiles can provide some insights to what's going on and why Centrifugo consumes a lot of memory or lot of CPU time. Goroutine profile can help to find goroutine leaks or deadlocks.

There many articles describing how to work with profiles in Go, some of them:

But you can just show you profiles to us (please put profiles into ZIP archive before uploading).

Clone this wiki locally