eclipse-vertx / vert.x

Vert.x is a tool-kit for building reactive applications on the JVM
http://vertx.io
Other
14.25k stars 2.07k forks source link

When the NUMBER of TCP connections exceeds the number of logical cores, it is always in a waiting state #3515

Open BornToRain opened 4 years ago

BornToRain commented 4 years ago

Questions

I have some old project code that uses tcp, and I want to use vertx-tcp to proxy them.

I use tcp server and client as a Proxy,tcp-server is running at 8080,tcp-client is running at random port.

when set the verticle instance number greater than or equal to logical cpu number,tcp connection is always waiting.

In my environment, the number is 12, when set the TestVerticle instance number < 12,it can proxy tcp.

Version

vertx-lang-scala_2.12:3.9.1

Code snippet

class TestVerticle extends ScalaVerticle {
  private[this] lazy val proxy = vertx.createNetServer
  // 60000-65535
  private[this] lazy val randomPort = Random.nextInt(5536) + 60000
  override def startFuture() = {
    proxy.connectHandler { proxy =>
      log.info(s"0.0.0.0:${randomPort} create connection")
      vertx.createNetClient.connectFuture(randomPort, "0.0.0.0").map { client =>
        log.info("proxy connect success")
        Pump.pump(proxy, client).start
        Pump.pump(client, proxy).start
      }
      proxy.closeHandler(_ => log.info("0.0.0.0:${randomPort} disconnect connection"))
    }
    proxy.listenFuture(8080)
  }
  override def stop(): Unit = proxy.close(_ => log.info(s"proxy disconnect connection"))
}

Extra

vietj commented 4 years ago

@BornToRain can you share a similar projects in Java that we can run to reproduce the issue ?