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:

  1. Use the taskset command to limit CPU usage, such as:
taskset -c 0-3 $run_your_server
  1. Actively set the number of P, for instance:
package main

import (
	"runtime"
)

func init() {
	runtime.GOMAXPROCS(num_you_want)
}
  1. Actively set the number of pollers, e.g:
package main

import (
	"github.com/cloudwego/netpoll"
)

func init() {
	netpoll.SetNumLoops(num_you_want)
}

Last modified August 14, 2023 : docs: supplement param tag desc (#762) (e9c005c)