[go-nuts] Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread Sokolov Yura
You didn't buffer writes. libevent does a good job at buffer managment. Go's net.Conn and os.File are unbuffered, ie they are almost "raw" file descriptors. You should use bufio.Writer and bufio.Reader, or make buffering by hands. (Just don't forget to flush bufio.Writer if response channel is

[go-nuts] Why is the cpu usage so high in a golang tcp server?

2017-12-18 Thread eric . shen881027
I try to implement a golang tcp server, and I found the concurrency is satisfied for me, but the CPU usage is too high(concurrency is 15W+/s, but the CPU usage is about 800% in a 24 cores linux machine). At the same time, a C++ tcp server is only about 200% usage with a similar