Caution
Wrong setting of NumLoops
If your server is running on a physical machine, the number of P created by the Go process is equal to the number of CPUs of the machine. But the server may not use so many cores. In this case, too many pollers will cause performance degradation.
There are several solutions:
- Use the
taskset
command to limit CPU usage, such as:
taskset -c 0-3 $run_your_server
- Actively set the number of P, for instance:
package main
import (
"runtime"
)
func init() {
runtime.GOMAXPROCS(num_you_want)
}
- Actively set the number of pollers, e.g:
package main
import (
"github.com/cloudwego/netpoll"
)
func init() {
netpoll.SetNumLoops(num_you_want)
}
Last modified
September 20, 2024
: doc: sync User Guide to Generic Call for Streaming [on trial] (#1140) (5641fba)