How to promote accept qps in golang?

Hi everybody:
I write a server program and it listens in an address.I only create a goroutine to accept new connection.I make a test, the result: 2.5w qps for accept new connection. Then i create >=2 goroutine for accept new connection, sadly the qps is not improved.

Why?For that linux kernal function accept has lock?

And How to improve the qps.

If you provide more details about your test scenario, it would be easier to help you troubleshooting this.

In general, if spawning more goroutines does not improve the throughput, then the code within the goroutine is not the limiting factor.

Rather, either of the following might apply:

  • Your test client is already on max speed and thus cannot generate more throughput.
  • Your network has limited bandwidth.
  • Something else in your code is limiting the throughput.
    • Consider writing benchmarks that test all involved methods separately. Here is an introduction to writing benchmark tests.
    • Consider profiling your server - a quick HowTo is here, and the original Go blog post is here.

Maybe you don’t know my meaning. I has exclude the cases you list. I more want to know explanation by original function accept(linux c)'s limitation.

Apologies for the misunderstanding. I am afraid I cannot answer your question about the accept() function of the Linux kernel.

Tip: Ask this in a Linux forum. The question is not related to Go, and in a Linux forum it is more likely that you find someone who is familiar with the accept() function.

:joy:Very very … sorry, I should go to a linux forum. Thank you very much.

Good luck. Sorry that I could not help, I really have no clue about accept().

If it turns out that accept() is not the culprit, feel free to return here and perhaps share some code that we can discuss. Maybe there is something within the Go code itself.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.